Please make sure to update to WPML 4.3.5 and check our list of Known Issues before reporting

Hi, Amit here, I am the WPML Support Manager, our current ticket queue is high, update your WPML plugins and make sure you meet the minimal requirements for running WPML before reporting an issue please - many tickets are resolved doing that

Please look at our updated list of Known Issues and you can also use our support search to find helpful information and of course review our documentation before opening a ticket.

If you do need to open a ticket please make sure to provide us with all the needed information as described in this page

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 6 replies, has 3 voices.

Last updated by Carlos Rojas 1 year, 3 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: Europe/Madrid (GMT+01: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: Europe/Madrid (GMT+01: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