Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 1 reply, has 1 voice.

Last updated by maximT-8 4 years, 12 months ago.

Author Posts
October 1, 2019 at 5:50 pm #4674471

maximT-8

I am trying to: Switch the currency back to default upon checkout

Link to a page where the issue can be seen: hidden link (IMPORTANT: Multicurrency disabled)

I expected to see: Currency reverts back to CAD

Instead, I got: Currency stays in USD, customer gets charged USD prices in CAD currency

October 1, 2019 at 10:30 pm #4675609

maximT-8

I've resolved my issue by writing the following snippet:

<?php
    /* WPML WooCommerce: Change currency back to default upon checkout 
    *   Issue:         Visitor gets charged selected currency amount in original currency, causing a 25% loss in sales.
    *   Resolution:    Hook before checkout page gets displayed to force the currency back to default.
    */
    function wa_woocommerce_revert_currency_on_checkout($currency) {

        error_log("Currency: ".$currency);
        
        if (is_checkout() && $currency != "CAD") { // Check if current page is checkout and currency is not CAD
            return "CAD"; // Set currency to CAD. TODO: Get default site currency dynamically.
        } else {
            return $currency;
        }

    }; add_filter('wcml_client_currency', 'wa_woocommerce_revert_currency_on_checkout', 10, 1);
?>

Cheers,
Maxim

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.