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.

Our next available supporter will start replying to tickets in about 4.59 hours from now. Thank you for your understanding.

This topic contains 6 replies, has 3 voices.

Last updated by Carlos Rojas 1 year, 2 months ago.

Assigned support staff: Carlos Rojas.

Author Posts
September 5, 2018 at 8:51 am #2705956

saehoonK

Hi,

I use the following snippet for the URL parameter.
-----
add_action( 'wcml_client_currency', 'currency' );
function currency( $current_currency ) {
$currency = isset( $_GET['currency'] ) ? esc_attr( $_GET['currency'] ) : $current_currency;
return strtoupper( $currency );
}
-----

For example, I have EUR and ENG currencies and a link from EUR to ENG.
The link: example.com/test/?currency=ENG

If the link is clicked it goes to example.com/test/?currency=ENG. So far so good!

Now, I have a problem. If the currency switch changed to EUR, the URL still remains example.com/test/?currency=ENG.

Thanks.

September 5, 2018 at 9:51 am #2706147

saehoonK

updated code for other issue.
---
add_action( 'wcml_client_currency', 'currency' );
function currency( $current_currency ) {

if( !is_admin() ) {

global $woocommerce;
global $sitepress;

$currency = isset( $_GET['currency'] ) ? esc_attr( $_GET['currency'] ) : $current_currency;
$currency = strtoupper( $currency );

$woocommerce->session->set('client_currency', $currency);

return $currency;

}

}
---

September 5, 2018 at 11:25 am #2706659

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi.

When switching the currency with the currency switcher the URL does not change this is how things work with WooCommerce Multilingual's multi-currency feature.

Does your updated code work for you?
Do you have questions to ask me about this issue?

Regards,
Itamar.

September 5, 2018 at 5:13 pm #2708302

saehoonK

The updated code is the same as the original.

How can I get a proper other-currency link then?

September 6, 2018 at 8:13 pm #2712211

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: America/Montevideo (GMT-03:00)

Hi,
Our colleague Itamar is off today.

I recommend you to visit this link where you will find our official hooks list: https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/

Best regards,
Carlos

September 7, 2018 at 10:06 am #2714055

saehoonK

Thanks but it couldn't help me.

If the direct link to the different currency should show the "?currency=xxx" at the end of the URL, the website should show the parameter at the end of the URL.
Am I right?
For example,
A USD currency page, for example, example.com/en/sample
If I clicked a link from EUR currency page, for example, the USD page would be example.com/en/sample?currency=USD

That's why the issue came out because I've been not using the currency parameter on my website.

So, how can I add the currency parameter to my website?

Thanks.

September 7, 2018 at 5:44 pm #2715638

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: America/Montevideo (GMT-03:00)

Hi there,

I have consulted our specialists and they suggest you to take a look at this ticket which has a similar issue: https://wpml.org/forums/topic/set-currency-with-url-parameter/#post-2688667

Also, instead of testing with ?currency, test with ?wcmlc

Please let me know if you need further assistance.
Best regards,
Carlos