WOOCS - WooCommerce Currency Switcher

WCMP – WC marketplace

Plugin URL: https://wc-marketplace.com/

  • In file functions.php of your current wp child theme add next code:
    add_filter('vendor_commission_amount', function ($amount, $product_id, $variation_id, $item, $order_id, $item_id) {
        if (class_exists('WOOCS')) {
            global $WOOCS;
            $_order_currency = get_post_meta($order_id, '_order_currency', true);
            $order_rate = get_post_meta($order_id, '_woocs_order_rate', true);
            $currencies = $WOOCS->get_currencies();
            if (!$order_rate) {
                if (isset($currencies[$_order_currency])) {
                    $order_rate = $currencies[$_order_currency]['rate'];
                }
            }
            if ($order_rate) {
                $amount = $WOOCS->back_convert($amount, $order_rate, 2);
            }
        }
        return $amount;
    }, 99, 6);
    

    (This will only keep commissions in one currency)

  • to correctly convert the amount of orders In  file  – “wp-content\plugins\dc-woocommerce-multi-vendor\classes\class-wcmp-vendor-details.php”  change  code from

    to

    $sales_total_item = $order->get_total();
    $discount_amount_item = $order->get_total_discount();
    if (class_exists('WOOCS')) {
        global $WOOCS;
        $_order_currency = get_post_meta($order->get_id(), '_order_currency', true);
        $order_rate = get_post_meta($order->get_id(), '_woocs_order_rate', true);
        $currencies = $WOOCS->get_currencies();
        if (!$order_rate) {
            if (isset($currencies[$_order_currency])) {
                $order_rate = $currencies[$_order_currency]['rate'];
            }
        }
        if ($order_rate) {
            $sales_total_item = $WOOCS->back_convert($sales_total_item, $order_rate, 2);
            $discount_amount_item = $WOOCS->back_convert($discount_amount_item, $order_rate, 2);
        }
    }
    $sales_total += $sales_total_item;
    $discount_amount += $discount_amount_item;
    
  • In  file – “wp-content\plugins\dc-woocommerce-multi-vendor\templates\vendor-dashboard\vendor-orders\views\html-order-item.php” change code:
    if (class_exists('WOOCS')) {
        global $WOOCS;
        $WOOCS->reset_currency();
    }
    echo '<div class="commission">' . wc_price($commission) . '</div>';
    if (class_exists('WOOCS')) {
        $_order_currency = get_post_meta($order->get_id(), '_order_currency', true);
        $WOOCS->set_currency($_order_currency);
    }

  • AND  in  file – “wp-content\plugins\dc-woocommerce-multi-vendor\classes\class-wcmp-vendor-details.php” – add code:

    if (class_exists('WOOCS')) {
        global $WOOCS;
        $WOOCS->reset_currency();
    }
  • AND in  file – “wp-content\plugins\dc-woocommerce-multi-vendor\classes\class-wcmp-post-commission.php“- add code:

    if (class_exists('WOOCS')) {
        global $WOOCS;
        $WOOCS->reset_currency();
    }
  • + add code:

    if (class_exists('WOOCS')) {
        global $WOOCS;
        $WOOCS->reset_currency();
    }
  • also in the same file add code:
    if (class_exists('WOOCS')) {
        global $WOOCS;
        $WOOCS->reset_currency();
    }