Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Marketplace (WooCommerce Multivendor Marketplace) › Tax of administrator comissions and order with many products not work
- This topic has 0 replies, 1 voice, and was last updated 4 years, 6 months ago by SoWoS.
- AuthorPosts
- May 11, 2020 at 8:31 pm #129659SoWoSParticipant
Hello,
I have a problem with the tax on the administrator commission, your following code works correctly when ordering a product (product reservation) but when there is many products in order, the vat tax of administrator commissions no working.
Do you have any idea about this problem?
Thank you!
add_action( ‘wcfmmp_order_item_processed’, function( $commission_id, $order_id, $order, $vendor_id, $product_id, $order_item_id, $grosse_total, $total_commission, $is_auto_withdrawal ) {
global $WCFM, $WCFMmp, $wpdb;if( apply_filters( ‘wcfm_is_admin_fee_mode’, false ) ) {
$commission_rule = unserialize( $WCFMmp->wcfmmp_commission->wcfmmp_get_commission_meta( $commission_id, ‘commission_rule’ ) );if( isset( $commission_rule[‘tax_enable’] ) && ( $commission_rule[‘tax_enable’] == ‘yes’ ) ) {
$gross_sale_order = (float) $WCFM->wcfm_vendor_support->wcfm_get_gross_sales_by_vendor( $vendor_id, ”, ”, $order_id );
$commission_tax = (float) $WCFMmp->wcfmmp_commission->wcfmmp_get_commission_meta( $commission_id, ‘commission_tax’ );
$total_commission += $commission_tax;$admin_fee = (float) $gross_sale_order – (float) $total_commission;
$commission_tax = $admin_fee * ( (float)$commission_rule[‘tax_percent’] / 100 );
$total_commission -= (float) $commission_tax;$WCFMmp->wcfmmp_commission->wcfmmp_delete_commission_meta( $commission_id, ‘commission_tax’ );
$WCFMmp->wcfmmp_commission->wcfmmp_update_commission_meta( $commission_id, ‘commission_tax’, round($commission_tax, 2) );
$wpdb->update(“{$wpdb->prefix}wcfm_marketplace_orders”, array(‘total_commission’ => $total_commission), array(‘ID’ => $commission_id), array(‘%s’), array(‘%d’));
$wpdb->update(“{$wpdb->prefix}wcfm_marketplace_vendor_ledger”, array( ‘credit’ => $total_commission ), array( ‘reference_id’ => $commission_id ), array( ‘%s’ ), array( ‘%d’ ) );
}
}
}, 50, 9 );Attachments:
You must be logged in to view attached files.
- AuthorPosts
- You must be logged in to reply to this topic.