PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]

Support Forum

You need to log-in to create request (topic) to the support

Pass current currency into link

The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page please
If you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.

Hello, is there a way to pass the currently selected currency as a variable into a wordpress link?

Hello

Yes, just add to your link ?currency=XXX

An example: https://demo.wp-currency.com/?currency=GBP

Hello, I think I did not explain my question very well.

I'm wanting to pass the currently selected currency into a link that is on my website. For example if GBP is selected, I want the button link on my website to be:  domain.com/currency=GBP

If USD is selected, I want to have USD in the button link: domain.com/currency=USD

Is there a way to pass the currently selected currency as a variable inside a link?

Hello

Sure, using PHP: https://wp-currency.com/function/wpcs-current_currency

Example: domain.com/currency=<?php global $WPCS; echo $WPCS->current_currency ?>

For more API see please: https://wp-currency.com/codex

Hello, how do I implement this into my WordPress site? I am wanting to change the URL of a button to include the PHP variable $WPCS, is this possible?

Hello

If you want to use dynamic content you can use PHP code. One moment, another idea: you can create custom shortcode and implement it into your content like: domain.com[my_wpcs]

Add please next code into file functions.php and use:

add_shortcode('my_wpcs', function () {
global $WPCS;
$tail = '';

if ($WPCS->default_currency !== $WPCS->current_currency) {
$tail = '?currency=' . $WPCS->current_currency;
}

return $tail;
});

The shortcode method worked perfectly, thank you!

Hello again, I am trying to do something similar to the above, but it doesn't seem to be working, any idea why?

add_shortcode('usa_wpcs', function () {
global $WPCS;
$USA = '';

if ($WPCS == 'USD') {
$USA = '&field_2[0]=10&options_2[0][0]';
}

if ($WPCS == 'CAD') {
$USA = '&field_62[0]=59&options_62[0][0]';
}

if ($WPCS == 'AUD') {
$USA = '&field_172[0]=113&options_172[0][0]';
}

if ($WPCS == 'EUR') {
$USA = '&field_99[0]=90&options_99[0][0]';
}

if ($WPCS == 'GBP') {
$USA = '&&field_134[0]=101&options_134[0][0]';
}

return $USA;
});

Hello

Please, for all comparisons use: $WPCS->current_currency

An example:

if ($WPCS->current_currency == 'USD') {