WOOCS - WooCommerce Currency Switcher Professional


WooCommerce Subscriptions by WooCommerce

Plugin linkhttps://woocommerce.com/products/woocommerce-subscriptions/

  • In file functions.php of your current wp theme add next code:
    add_filter('woocommerce_subscription_price_string_details', 'woocs_woocommerce_subscription_price_string_details', 100, 2);
    
    function woocs_woocommerce_subscription_price_string_details($arg, $_this) {
    
        if (class_exists('WOOCS')) {
            global $WOOCS;
    
            $order_currency = get_post_meta($_this->get_id(), '_order_currency', true);
            if ($order_currency AND $WOOCS->current_currency != $order_currency) {
                $WOOCS->set_currency($order_currency);
            }
        }
    
        return $arg;
    }
    
  • In file wp-content\plugins\woocommerce-subscriptions\vendor\woocommerce\subscriptions-core\includes\wcs-order-functions.php add next code:
    if (class_exists('WOOCS') AND 'renewal_order' == $type) {
        global $WOOCS;
        $_order_currency = get_post_meta($subscription->get_id(), '_order_currency', true);
        if ($_order_currency) {
            $WOOCS->set_currency($_order_currency);
        }
    }
    

  • And on the same file next code:
    if (class_exists('WOOCS')) {
        global $WOOCS;
        $order_currency = get_post_meta($order_id, '_order_currency', true);
        if ($order_currency AND $WOOCS->current_currency != $order_currency) {
            $WOOCS->set_currency($order_currency);
        }
    }
    

  • In file wp-content\plugins\woocommerce-subscriptions\vendor\woocommerce\subscriptions-core\includes\class-wcs-cart-renewal.php add next code:
    if (class_exists('WOOCS')) {
        global $WOOCS;
        if ($WOOCS->is_multiple_allowed) {
            $curr = get_post_meta($subscription->get_id(), '_order_currency', true);
            $currencies = $WOOCS->get_currencies();
            $rate = $currencies[$curr]['rate'];
            $price = $price / ($rate);
        }
    }
    

  • In file wp-content\plugins\woocommerce-subscriptions\vendor\woocommerce\subscriptions-core\includes\class-wc-subscriptions-product.php add next code:
    if (class_exists('WOOCS') AND $subscription_price) {
        global $WOOCS;
        if ($WOOCS->is_multiple_allowed) {
            $subscription_price = $WOOCS->woocs_exchange_value(floatval($subscription_price));
        }
    }
    

  • In file wp-content/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/includes/class-wc-product-variable-subscription.php add next code:
    if (isset($prices['price'][$min_price_variation_id])) {
        $price = $prices['price'][$min_price_variation_id];
    }