WOOCS - WooCommerce Currency Switcher

WooCommerce Subscriptions by WooCommerce

Pluginhttps://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\includes\wcs-order-functions.php add 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);
        }
    }

     

  • Add next CSS instructions:
    .price .subscription-details:nth-child(2) {
       display: none;
    }
  • in file \wp-content\plugins\woocommerce-subscriptions-master\includes\class-wcs-cart-renewal.php  add  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\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));
    }
}