Table of Contents
Show commission as 0 for cash on delivery order #
If a buyer want to pay on the delivery, the marketplace admin, won’t have a new commission to pay as the whole payment process will be offline and there is no control over it.
So, you may set the commission amount 0 for this, using the below code
add_action( 'mvx_commission_after_save_commission_total', 'zero_commission' );
function zero_commission( $commission_id ) {
$order_id = get_post_meta( $commission_id, '_commission_order_id', true );
$payment = get_post_meta( $order_id, '_payment_method', true );
if( $payment == 'cod' ) {
$order = wc_get_order($order_id);
update_post_meta( $commission_id, '_commission_amount', $order->get_subtotal() );
update_post_meta( $commission_id, '_commission_total', 0 );
}
}
Exclude commission for offline payment #
If a customer chooses to pay COD. The money will not be going through admin, so it might be useful to exclude the commission for vendor. For this add this code in the function.php of the theme :
// paid commission automaticly for cod payment
add_action( 'after_wcmp_calculate_commission', function( $commission_id, $vendor_order_id )
{
$payemnt_method = get_post_meta( $vendor_order_id , '_payment_method' , true ); if( $payemnt_method == 'cod' ) {
update_post_meta( $commission_id , '_paid_status' , 'paid' );
}
},10,2);
Leave a Reply
You must be logged in to post a comment.