palsushobhan

commission-calculation-and-order-details-formatiing.php

Jun 21st, 2021 (edited)
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 23.06 KB | None | 0 0
  1. function calculate_transaction_charge_for_vendor_order_item($order_item_id, $vendor_id, $commission_rule) {
  2.     $transacton_charge_meta_key = '_wcfmmp_vendor_only_transaction_charge';
  3.     if($transaction_charge = wc_get_order_item_meta( $order_item_id, $transacton_charge_meta_key, true )) {
  4.         return $transaction_charge;
  5.     }
  6.    
  7.     $line_item = new WC_Order_Item_Product($order_item_id);
  8.     $line_item_total = $line_item->get_total() + $line_item->get_total_tax();
  9.  
  10.     $order = $line_item->get_order();
  11.     $line_items = $order->get_items( 'line_item' );
  12.     $vendors = array();
  13.     foreach ($line_items as $item) {
  14.         $order_item = new WC_Order_Item_Product($item);
  15.         $product_id = $order_item->get_product_id();
  16.         $store_id = wcfm_get_vendor_id_by_post($product_id);
  17.         if ($store_id && !in_array($store_id, $vendors)) {
  18.             $vendors[] = $store_id;
  19.         }
  20.     }
  21.     $shipping_items = $order->get_items( 'shipping' );
  22.     $package_qty = 0;
  23.     foreach ( $shipping_items as $shipping_item ) {
  24.         $order_item_shipping = new WC_Order_Item_Shipping( $shipping_item );
  25.         $shipping_vendor_id = $order_item_shipping->get_meta( 'vendor_id', true );
  26.         if ( ( $shipping_vendor_id > 0 ) && ( $shipping_vendor_id == $vendor_id ) ) {
  27.             $shipping_item_total = $order_item_shipping->get_total() + $order_item_shipping->get_total_tax();
  28.             $package_qty = $order_item_shipping->get_meta('package_qty', true);
  29.             if($package_qty > 0 && $shipping_item_total > 0) {
  30.                 $line_item_total += $shipping_item_total / $package_qty;
  31.             }
  32.         }
  33.     }
  34.  
  35.     $total_transaction_charge = 0;
  36.     if( ( $commission_rule['transaction_charge_type'] == 'percent' ) || ( $commission_rule['transaction_charge_type'] == 'percent_fixed' ) ) {
  37.         $total_transaction_charge  += $line_item_total * ( (float)$commission_rule['transaction_charge_percent'] / 100 );
  38.     }
  39.     if( ( $commission_rule['transaction_charge_type'] == 'fixed' ) || ( $commission_rule['transaction_charge_type'] == 'percent_fixed' ) ) {
  40.         $total_transaction_charge  += (float)$commission_rule['transaction_charge_fixed'] / ( count($vendors) * $package_qty );
  41.     }
  42.     $transaction_charge = round( $total_transaction_charge, 2 );
  43.    
  44.     if( !get_post_meta( $order->get_id(), '_wcfmmp_vendor_transacton_charge_adjusted_'.$vendor_id, true ) ) {
  45.         update_post_meta( $order->get_id(), '_wcfmmp_vendor_transacton_charge_adjusted_'.$vendor_id, 'yes' );
  46.     }
  47.  
  48.     wc_update_order_item_meta( $order_item_id, $transacton_charge_meta_key, $transaction_charge );
  49.     return $transaction_charge;
  50. }
  51.  
  52. //Transaction charge fully bear by vendor. Admin will not contribute
  53. add_filter( 'wcfmmp_commission_deducted_transaction_charge', function($transaction_charge, $vendor_id, $product_id, $order_id, $total_commission, $commission_rule, $order_item_id ) {
  54.     return calculate_transaction_charge_for_vendor_order_item($order_item_id, $vendor_id, $commission_rule);
  55. }, 10, 7 );
  56.  
  57. function calculate_commission_tax_on_admin_commission($item_id, $commission_tax, $vendor_id, $product_id, $variation_id, $order_id, $commission_rule) {
  58.     global $WCFMmp;
  59.     if( apply_filters( 'wcfm_is_admin_fee_mode', false ) ) {        
  60.         $commission_meta_key = '_wcfmmp_commission_tax_only_on_admin_commission';
  61.         if($item_commission_tax = wc_get_order_item_meta( $item_id, $commission_meta_key, true )) {
  62.             return $item_commission_tax;
  63.         }
  64.  
  65.         if( isset( $commission_rule['tax_enable'] ) && ( $commission_rule['tax_enable'] == 'yes' ) ) {
  66.             $line_item = new WC_Order_Item_Product($item_id);
  67.             $order = $line_item->get_order();
  68.             $quantity = $line_item->get_quantity();
  69.             $refunded_qty = $item_price = $item_qty = 0;
  70.             if ( $refunded_amount = $order->get_total_refunded_for_item( absint( $item_id ) ) ) {
  71.                 $refunded_qty = $order->get_qty_refunded_for_item( absint( $item_id ) );
  72.                 $refunded_qty = $refunded_qty * -1;
  73.             }
  74.             $item_qty = $quantity - $refunded_qty;
  75.             if( $WCFMmp->wcfmmp_vendor->is_vendor_deduct_discount( $vendor_id, $order_id ) ) {
  76.                 $item_price = $line_item->get_total() - $refunded_amount;
  77.             } else {
  78.                 $item_price = $line_item->get_subtotal() - $refunded_amount;
  79.             }
  80.             if( apply_filters( 'wcfmmp_is_allow_commission_on_tax', false ) ) {
  81.                 $item_price += $line_item->get_total_tax();
  82.             }
  83.             if( apply_filters( 'wcfmmp_is_allow_commission_on_shipping', false ) ) {
  84.                 $shipping_items = $order->get_items( 'shipping' );
  85.                 $package_qty = 0;
  86.                 foreach ( $shipping_items as $shipping_item_id => $shipping_item ) {
  87.                     $order_item_shipping = new WC_Order_Item_Shipping( $shipping_item_id );
  88.                     $shipping_vendor_id = $order_item_shipping->get_meta( 'vendor_id', true );
  89.                     if ( ( $shipping_vendor_id > 0 ) && ( $shipping_vendor_id == $vendor_id ) ) {
  90.                         $shipping_item_total = $order_item_shipping->get_total() + $order_item_shipping->get_total_tax();
  91.                         $package_qty = $order_item_shipping->get_meta('package_qty', true);
  92.                         $item_price += $shipping_item_total / $package_qty;
  93.                     }
  94.                 }
  95.             }
  96.             $commission_amount = $WCFMmp->wcfmmp_commission->wcfmmp_get_order_item_commission( $order_id, $vendor_id, $product_id, $variation_id, $item_price, $item_qty, $commission_rule );
  97.             $admin_commission_amount = $item_price - $commission_amount;
  98.  
  99.             wc_update_order_item_meta( $item_id, $commission_meta_key, $admin_commission_amount );
  100.  
  101.             return $admin_commission_amount;
  102.         }
  103.     }
  104.     return $commission_tax;
  105. }
  106.  
  107. //Commission tax only on admin commission + total transaction charge.
  108. add_filter( 'wcfmmp_commission_deducted_tax', function( $commission_tax, $vendor_id, $product_id, $variation_id, $order_id, $total_commission, $commission_rule, $item_id ) {
  109.     global $WCFMmp;
  110.     if( apply_filters( 'wcfm_is_admin_fee_mode', false ) ) {
  111.         remove_filter( 'wcfmmp_commission_deducted_tax', array($WCFMmp->wcfmmp_commission, 'wcfmmp_commission_deducted_tax_admin_mode_handler' ), 100 );
  112.         $admin_commission_amount = calculate_commission_tax_on_admin_commission($item_id, $commission_tax, $vendor_id, $product_id, $variation_id, $order_id, $commission_rule);
  113.         $admin_commission_amount += calculate_transaction_charge_for_vendor_order_item($item_id, $vendor_id, $commission_rule);
  114.         $commission_tax = $admin_commission_amount * ( (float)$commission_rule['tax_percent'] / 100 );
  115.     }
  116.     return $commission_tax;
  117. }, 99, 8 );
  118.  
  119. //Delete order meta keys on Order reset
  120. add_action( 'wcfm_manual_order_processed', function( $order_id, $order_posted, $order = '' ) {
  121.     global $wpdb;
  122.     if ( ! $order_id ) return;
  123.     if ( ! $order ) $order = wc_get_order( $order_id );
  124.     if ( ! is_a( $order, 'WC_Order' ) ) return;
  125.  
  126.     $marketplace_orders = $wpdb->get_results(  $wpdb->prepare( "SELECT ID, item_id from {$wpdb->prefix}wcfm_marketplace_orders WHERE order_id = %d", $order_id ) );
  127.     foreach( $marketplace_orders as $marketplace_order ) {
  128.         wc_delete_order_item_meta( $marketplace_order->item_id, '_wcfmmp_vendor_only_transaction_charge' );
  129.         wc_delete_order_item_meta( $marketplace_order->item_id, '_wcfmmp_commission_tax_only_on_admin_commission' );
  130.     }
  131. }, 10, 3 );
  132.  
  133. add_action( 'wcfm_order_details_after_line_total_head', function($order) {
  134.     global $WCFM;
  135.     remove_action( 'wcfm_order_details_after_line_total_head', array( $WCFM->wcfm_marketplace, 'wcfmmp_after_line_total_head' ) );
  136.     if( wcfm_vendor_has_capability( $WCFM->wcfm_marketplace->vendor_id, 'view_commission' ) ) {
  137.         $admin_fee_mode = apply_filters( 'wcfm_is_admin_fee_mode', false );
  138.         if( $admin_fee_mode ) {
  139.         ?>
  140.             <th class="line_cost"><?php _e( 'Commission', 'wc-frontend-manager' ); ?></th>
  141.         <?php } else { ?>
  142.             <th class="line_cost"><?php _e( 'Earning', 'wc-frontend-manager' ); ?></th>
  143.         <?php
  144.         }
  145.     }
  146. }, 9 );
  147.  
  148. add_action('wcfm_order_totals_after_total',   function ($order_id) {
  149.     global $WCFM, $wpdb, $WCFMmp;
  150.     remove_action('wcfm_order_totals_after_total', array($WCFM->wcfm_marketplace, 'wcfmmp_order_total_commission'));
  151.  
  152.     $admin_fee_mode = apply_filters('wcfm_is_admin_fee_mode', false);
  153.     $gross_sale_order = $WCFM->wcfm_vendor_support->wcfm_get_gross_sales_by_vendor($WCFM->wcfm_marketplace->vendor_id, '', '', $order_id);
  154.     $order = wc_get_order($order_id);
  155.     $order_currency = $order->get_currency();
  156.  
  157.     $order_status = sanitize_title($order->get_status());
  158.  
  159.     $td_style = '';
  160.  
  161.     $sql = "
  162.    SELECT GROUP_CONCAT(ID) as commission_ids,
  163.    GROUP_CONCAT(item_id) as order_item_ids,
  164.    SUM(commission_amount) as line_total,
  165.    SUM(total_commission) as total_commission,
  166.    SUM(item_total) as item_total,
  167.    SUM(item_sub_total) as item_sub_total,
  168.    SUM(shipping) as shipping,
  169.    SUM(tax) as tax,
  170.    SUM(shipping_tax_amount) as shipping_tax_amount,
  171.    SUM(refunded_amount) as refunded_amount,
  172.    SUM(discount_amount) as discount_amount
  173.    FROM {$wpdb->prefix}wcfm_marketplace_orders
  174.    WHERE order_id = " . $order_id . "
  175.    AND `vendor_id` = " . $WCFM->wcfm_marketplace->vendor_id . "
  176.    AND `is_refunded` != 1";
  177.     $order_due = $wpdb->get_results($sql);
  178.     if (!$order_due || !isset($order_due[0])) return;
  179.  
  180.     $total = 0;
  181.     $subtotal = 0;
  182.     $calculated_total   = 0;
  183.     $total_tax          = 0;
  184.     $total_shipping     = 0;
  185.     $shipping_tax       = 0;
  186.     $refund_total       = 0;
  187.     $discount_total     = 0;
  188.     $commission_tax     = 0;
  189.     $aff_commission     = 0;
  190.     $transaction_charge = 0;
  191.  
  192.     $commission_rule  = array();
  193.  
  194.     $total = $order_due[0]->total_commission;
  195.     if ($WCFMmp->wcfmmp_vendor->is_vendor_deduct_discount($WCFM->wcfm_marketplace->vendor_id, $order_id)) {
  196.         $calculated_total = $order_due[0]->item_total;
  197.     } else {
  198.         $calculated_total = $order_due[0]->item_sub_total;
  199.     }
  200.  
  201.     // WC Refund Support - 3.0.4
  202.     $commission_ids = explode(",", $order_due[0]->commission_ids);
  203.     foreach ($commission_ids as $commission_id) {
  204.         if (method_exists($WCFMmp->wcfmmp_commission, 'wcfmmp_get_commission_meta')) {
  205.             $total_tax          += (float) $WCFMmp->wcfmmp_commission->wcfmmp_get_commission_meta($commission_id, 'gross_tax_cost');
  206.             $total_shipping     += (float) $WCFMmp->wcfmmp_commission->wcfmmp_get_commission_meta($commission_id, 'gross_shipping_cost');
  207.             $shipping_tax       += (float) $WCFMmp->wcfmmp_commission->wcfmmp_get_commission_meta($commission_id, 'gross_shipping_tax');
  208.             $commission_tax     += (float) $WCFMmp->wcfmmp_commission->wcfmmp_get_commission_meta($commission_id, 'commission_tax');
  209.             $aff_commission     += (float) $WCFMmp->wcfmmp_commission->wcfmmp_get_commission_meta($commission_id, '_wcfm_affiliate_commission');
  210.             $transaction_charge += (float) $WCFMmp->wcfmmp_commission->wcfmmp_get_commission_meta($commission_id, 'transaction_charge');
  211.             $commission_rule     = unserialize($WCFMmp->wcfmmp_commission->wcfmmp_get_commission_meta($commission_id, 'commission_rule'));
  212.         }
  213.     }
  214.  
  215.     $calculated_total += (float) $total_tax;
  216.     $calculated_total += (float) apply_filters('wcfmmmp_gross_sales_shipping_cost', $total_shipping, $WCFM->wcfm_marketplace->vendor_id);
  217.     $calculated_total += (float) $shipping_tax;
  218.  
  219.     $refund_total = $order_due[0]->refunded_amount;
  220.     $discount_total = $order_due[0]->discount_amount;
  221.     $get_shipping = $WCFMmp->wcfmmp_vendor->is_vendor_get_shipping($WCFM->wcfm_marketplace->vendor_id);
  222.     $get_tax = $WCFMmp->wcfmmp_vendor->is_vendor_get_tax($WCFM->wcfm_marketplace->vendor_id);
  223. ?>
  224.     <?php do_action('wcfm_vendor_order_details_before_subtotal', $order_id, $WCFM->wcfm_marketplace->vendor_id); ?>
  225.     <tr>
  226.         <th class="label" colspan="2" style="text-align:right; <?php echo $td_style; ?>"><?php _e('Subtotal', 'wc-frontend-manager'); ?>:</th>
  227.         <td class="total" style="text-align:center; <?php echo $td_style; ?>">
  228.             <div class="view">
  229.                 <?php
  230.                 $subtotal = $calculated_total - ((float) $refund_total + (float) $order_due[0]->shipping + (float) $order_due[0]->tax + (float) $order_due[0]->shipping_tax_amount);
  231.                 if ($refund_total && (round($subtotal, 2) != round($order_due[0]->item_sub_total, 2))) {
  232.                     echo "<del>" . wc_price($order_due[0]->item_sub_total, array('currency' => $order_currency)) . "</del>";
  233.                     echo "<ins>" . wc_price($subtotal, array('currency' => $order_currency)) . "</ins>";
  234.                 } else {
  235.                     echo wc_price($order_due[0]->item_sub_total, array('currency' => $order_currency));
  236.                 }
  237.                 ?>
  238.             </div>
  239.         </td>
  240.     </tr>
  241.     <?php do_action('wcfm_vendor_order_details_after_subtotal', $order_id, $WCFM->wcfm_marketplace->vendor_id); ?>
  242.     <?php if ($get_shipping && $order->get_formatted_shipping_address()) { ?>
  243.  
  244.     <?php do_action('wcfm_vendor_order_details_before_shipping', $order_id, $WCFM->wcfm_marketplace->vendor_id); ?>
  245.     <tr>
  246.         <th class="label" colspan="2" style="text-align:right; <?php echo $td_style; ?>"><?php _e('Shipping', 'wc-frontend-manager'); ?>:</th>
  247.         <td class="total" style="text-align:center; <?php echo $td_style; ?>">
  248.             <div class="view">
  249.                 <?php
  250.                 echo wc_price(apply_filters('wcfmmmp_gross_sales_shipping_cost', $total_shipping, $WCFM->wcfm_marketplace->vendor_id), array('currency' => $order_currency));
  251.                 ?>
  252.             </div>
  253.         </td>
  254.     </tr>
  255.     <?php do_action('wcfm_vendor_order_details_after_shipping', $order_id, $WCFM->wcfm_marketplace->vendor_id); ?>
  256.     <?php } ?>
  257.  
  258.     <?php if (apply_filters('wcfm_is_allow_vendor_order_details_tax_breakup_total', true)) { ?>
  259.  
  260.         <?php do_action('wcfm_vendor_order_details_before_tax', $order_id, $WCFM->wcfm_marketplace->vendor_id); ?>
  261.         <?php do_action('wcfm_vendor_order_details_before_shipping_tax', $order_id, $WCFM->wcfm_marketplace->vendor_id); ?>
  262.         <tr>
  263.             <th class="label" colspan="2" style="text-align:right; <?php echo $td_style; ?>">
  264.                 <?php _e('Total Tax Collected', 'wc-frontend-manager'); ?>:
  265.             </th>
  266.             <td class="total" style="text-align:center; <?php echo $td_style; ?>">
  267.                 <div class="view">
  268.                     <?php
  269.                         echo wc_price($total_tax + $shipping_tax, array('currency' => $order_currency));
  270.                     ?>
  271.                 </div>
  272.             </td>
  273.         </tr>
  274.         <?php do_action('wcfm_vendor_order_details_after_shipping_tax', $order_id, $WCFM->wcfm_marketplace->vendor_id); ?>
  275.         <?php do_action('wcfm_vendor_order_details_after_tax', $order_id, $WCFM->wcfm_marketplace->vendor_id); ?>
  276.  
  277.     <?php } ?>
  278.  
  279.     <?php if ($refund_total) { ?>
  280.         <?php do_action('wcfm_vendor_order_details_before_refund', $order_id, $WCFM->wcfm_marketplace->vendor_id); ?>
  281.         <tr>
  282.             <th class="label refunded-total" colspan="2" style="text-align:right; <?php echo $td_style; ?>"><?php _e('Refunded', 'wc-frontend-manager'); ?>:</th>
  283.             <td class="total refunded-total" style="text-align:center; <?php echo $td_style; ?>">-<?php echo wc_price($refund_total, array('currency' => $order_currency)); ?></td>
  284.         </tr>
  285.         <?php do_action('wcfm_vendor_order_details_before_refund', $order_id, $WCFM->wcfm_marketplace->vendor_id); ?>
  286.     <?php } ?>
  287.  
  288.     <?php if ($discount_total && $WCFMmp->wcfmmp_vendor->is_vendor_deduct_discount($WCFM->wcfm_marketplace->vendor_id, $order_id)) { ?>
  289.         <?php do_action('wcfm_vendor_order_details_before_discount', $order_id, $WCFM->wcfm_marketplace->vendor_id); ?>
  290.         <tr>
  291.             <th class="label discount-total" colspan="2" style="text-align:right; <?php echo $td_style; ?>"><?php _e('Discount', 'wc-frontend-manager'); ?>:</th>
  292.             <td class="total discount-total" style="text-align:center; <?php echo $td_style; ?>"><?php echo wc_price($discount_total, array('currency' => $order_currency)); ?></td>
  293.         </tr>
  294.         <?php do_action('wcfm_vendor_order_details_after_discount', $order_id, $WCFM->wcfm_marketplace->vendor_id); ?>
  295.     <?php } ?>
  296.  
  297.     <?php if (apply_filters('wcfm_is_allow_gross_total', true)) { ?>
  298.         <?php do_action('wcfm_vendor_order_details_before_gross_total', $order_id, $WCFM->wcfm_marketplace->vendor_id); ?>
  299.         <tr class="total_cost">
  300.             <th class="label" colspan="2" style="text-align:right; <?php echo $td_style; ?>"><?php _e('Gross Total', 'wc-frontend-manager'); ?>:</th>
  301.             <td class="total" style="text-align:center; <?php echo $td_style; ?>">
  302.                 <div class="view">
  303.                     <?php
  304.                     if ($refund_total) {
  305.                         echo "<del>" . wc_price($calculated_total, array('currency' => $order_currency)) . "</del>";
  306.                         echo "<ins>" . wc_price($gross_sale_order, array('currency' => $order_currency)) . "</ins>";
  307.                     } else {
  308.                         echo wc_price($calculated_total, array('currency' => $order_currency));
  309.                     }
  310.                     ?>
  311.                 </div>
  312.             </td>
  313.         </tr>
  314.         <?php do_action('wcfm_vendor_order_details_after_gross_total', $order_id, $WCFM->wcfm_marketplace->vendor_id); ?>
  315.     <?php } ?>
  316.  
  317.     <?php do_action('wcfm_vendor_order_details_before_admin_commission', $order_id, $WCFM->wcfm_marketplace->vendor_id); ?>
  318.     <tr class="total_cost">
  319.         <th class="label" colspan="2" style="text-align:right; <?php echo $td_style; ?>"><?php _e('Commission', 'wc-frontend-manager'); ?>:</th>
  320.         <td class="total" style="text-align:center; <?php echo $td_style; ?>">
  321.             <div class="view">
  322.                 <?php
  323.                     echo wc_price($order_due[0]->item_total - $order_due[0]->line_total, array('currency' => $order_currency));
  324.                 ?>
  325.             </div>
  326.         </td>
  327.     </tr>
  328.     <?php do_action('wcfm_vendor_order_details_after_admin_commission', $order_id, $WCFM->wcfm_marketplace->vendor_id); ?>
  329.  
  330.     <?php
  331.     if (apply_filters('wcfm_is_allow_order_details_commission_breakup_gross_earning', true) && wcfm_vendor_has_capability($WCFM->wcfm_marketplace->vendor_id, 'view_commission') && !in_array($order_status, array('failed', 'cancelled', 'refunded', 'request', 'proposal', 'proposal-sent', 'proposal-expired', 'proposal-rejected', 'proposal-canceled', 'proposal-accepted'))) {
  332.         if (!$admin_fee_mode || ($admin_fee_mode && apply_filters('wcfm_is_allow_admin_fee_mode_commission_breakup', true))) {
  333.             // Show Transaction Charges
  334.             if ($transaction_charge && apply_filters('wcfm_is_allow_view_transaction_charge', true) && isset($commission_rule['transaction_charge_type']) && ($commission_rule['transaction_charge_type'] != 'no')) {
  335.             ?>
  336.                 <?php do_action('wcfm_vendor_order_details_before_transaction_charge', $order_id, $WCFM->wcfm_marketplace->vendor_id); ?>
  337.                 <tr>
  338.                     <th class="label" colspan="2" style="text-align:right; <?php echo $td_style; ?>"><?php _e('Merchant Fees', 'wc-frontend-manager'); ?>:</th>
  339.                     <td class="total" style="text-align:center; <?php echo $td_style; ?>">
  340.                         <div class="view">
  341.                             <?php
  342.                             echo wc_price($transaction_charge, array('currency' => $order_currency));
  343.                             ?>
  344.                         </div>
  345.                     </td>
  346.                 </tr>
  347.                 <?php do_action('wcfm_vendor_order_details_after_transaction_charge', $order_id, $WCFM->wcfm_marketplace->vendor_id); ?>
  348.  
  349.             <?php
  350.             }
  351.             if (isset($commission_rule['tax_enable']) && ($commission_rule['tax_enable'] == 'yes')) {
  352.     ?>
  353.                 <?php do_action('wcfm_vendor_order_details_before_commission_tax', $order_id, $WCFM->wcfm_marketplace->vendor_id); ?>
  354.                 <tr>
  355.                     <th class="label" colspan="2" style="text-align:right; <?php echo $td_style; ?>"><?php echo 'Tax on fees'; ?>:</th>
  356.                     <td class="total" style="text-align:center; <?php echo $td_style; ?>">
  357.                         <div class="view">
  358.                             <?php
  359.                             echo wc_price($commission_tax, array('currency' => $order_currency));
  360.                             ?>
  361.                         </div>
  362.                     </td>
  363.                 </tr>
  364.                 <?php do_action('wcfm_vendor_order_details_after_commission_tax', $order_id, $WCFM->wcfm_marketplace->vendor_id); ?>
  365.  
  366.             <?php
  367.             }
  368.             ?>
  369.             <?php do_action('wcfm_vendor_order_details_before_total_earning', $order_id, $WCFM->wcfm_marketplace->vendor_id); ?>
  370.             <tr>
  371.                 <th class="label" colspan="2" style="text-align:right; <?php echo $td_style; ?>"><?php _e('Seller Earnings', 'wc-frontend-manager'); ?>:</th>
  372.                 <td class="total" style="text-align:center; <?php echo $td_style; ?>">
  373.                     <div class="view">
  374.                         <?php
  375.                         echo wc_price($total, array('currency' => $order_currency));
  376.                         if (apply_filters('wcfm_is_allow_earning_in_words', false)) {
  377.                             echo "<br/>" . wcfm_number_to_words($total);
  378.                         }
  379.                         ?>
  380.                     </div>
  381.                 </td>
  382.             </tr>
  383.             <?php do_action('wcfm_vendor_order_details_after_total_earning', $order_id, $WCFM->wcfm_marketplace->vendor_id); ?>
  384.  
  385.         <?php
  386.         }
  387.         if (apply_filters('wcfm_is_allow_order_details_admin_fee', true)) {
  388.             do_action('wcfm_vendor_order_details_before_admin_fee', $order_id, $WCFM->wcfm_marketplace->vendor_id);
  389.         ?>
  390.             <tr>
  391.                 <th class="label" colspan="2" style="text-align:right; <?php echo $td_style; ?>"><?php _e('Admin Fee', 'wc-frontend-manager'); ?>:</th>
  392.                 <td class="total" style="text-align:center; <?php echo $td_style; ?>">
  393.                     <div class="view">
  394.                         <?php
  395.                         echo wc_price(($calculated_total - $total), array('currency' => $order_currency));
  396.                         if (apply_filters('wcfm_is_allow_earning_in_words', false)) {
  397.                             echo "<br/>" . wcfm_number_to_words(($gross_sale_order - $total));
  398.                         }
  399.                         ?>
  400.                     </div>
  401.                 </td>
  402.             </tr>
  403. <?php
  404.             do_action('wcfm_vendor_order_details_after_admin_fee', $order_id, $WCFM->wcfm_marketplace->vendor_id);
  405.         }
  406.     }
  407. }, 9);
Add Comment
Please, Sign In to add comment