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

How to display currency symbol before price and currency initials after price

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, how can I display currency symbol before price and currency initials after price?

For instance:

I want aud prices to show like:

$20 AUD

I cant find a way to display the initials after price. All I can do is all info before price, or all after, like $AUD 20 or 20 $AUD

Please help me to achieve this. (I own premium)

Thanks

 

Hello

Please paste your license key here - https://share.pluginus.net/image/i20210618130558.png -> https://share.pluginus.net/image/i20210618130614.png

Try  to  use  this  field - https://c2n.me/4ex0O6t.png

Thanks. Just added my license into the box.

It worked but I just want this field to work for AUD and USD.

Is there a snippet for this?

Hello

in this case you need to customize the code

this  hook

An example:

add_action('woocommerce_get_price_html', function($price_html, $product){

global $WOOCS;

if ('AUD' == $WOOCS->current_currency)  {

$price_html.='AUD';

} elseif ('USD' == $WOOCS->current_currency){

$price_html.='USD';

}

return $price_html;

}, 1, 2);

Thank you Pablo.

Tried to implement this snippet and it partially worked.

The issue is that the currency code returns in duplicate in the frontend.

What is expected from the snippet:

$ 20 AUD

What is happening:

$20 AUDAUD

The string is returning in duplicate, in other words, instead of only displaying AUD once, it is displaying twice.

The same happens for USD.

How can I solve this duplicate?

Thanks

ps: The custom price format field is empty, back to plugin default as I just want it to behave like this for AUD and USD.

Hello

Try  to add code  - https://c2n.me/4eysrcs.png

if ( stripos('AUD', $price_html) !== false  ||  stripos('USD', $price_html) !== false){

return $price_html;

}

 

Thanks Pablo. I added it, result is the same as previous. Nothing changed.

Have you tested it on your end?

Thanks

Hello

Please  drop  me  a screenshot  of the code

First one I tried:

add_action('woocommerce_get_price_html', function($price_html, $product){

global $WOOCS;

if ('AUD' == $WOOCS->current_currency)  {

$price_html.='AUD';

} elseif ('USD' == $WOOCS->current_currency){

$price_html.='USD';

}

return $price_html;

}, 1, 2);

Second one I tried:

add_action('woocommerce_get_price_html', function($price_html, $product){

if ( stripos('AUD', $price_html) !== false  ||  stripos('USD', $price_html) !== false){

return $price_html;

}

global $WOOCS;

if ('AUD' == $WOOCS->current_currency)  {

$price_html.='AUD';

} elseif ('USD' == $WOOCS->current_currency){

$price_html.='USD';

}

return $price_html;

}, 1, 2);

 

Both results are the same, AUDAUD or USDUSD instead of only once.

 

Hello

Ok!  just for test try this code

add_action('woocommerce_get_price_html', function($price_html, $product){

if ( stripos('+', $price_html) !== false  ||  stripos('-', $price_html) !== false){

return $price_html;

}

global $WOOCS;

if ('AUD' == $WOOCS->current_currency)  {

$price_html.='+';

} elseif ('USD' == $WOOCS->current_currency){

$price_html.='-';

}

return $price_html;

}, 1, 2);

Have you tested those snippets?

I ve just tested it and the result of this one is: $20++

Ok!  try  it  please

add_action('woocommerce_get_price_html', function($price_html, $product){

$price_html = str_replace(['USD', 'AUD'], ['',''],  $price_html);

global $WOOCS;

if ('AUD' == $WOOCS->current_currency)  {

$price_html.='AUD';

} elseif ('USD' == $WOOCS->current_currency){

$price_html.='USD';

}

return $price_html;

}, 1, 2);

Just tested it...

same result...

Hello

Try  it:

add_action('woocommerce_get_price_html', function($price_html, $product){

global $WOOCS;

if ('AUD' == $WOOCS->current_currency) {

$price_html = str_replace('</bdi>', '</bdi>AUD', $price_html);

} elseif ('USD' == $WOOCS->current_currency){

$price_html = str_replace('</bdi>', '</bdi>USD', $price_html);

}

return $price_html;

}, 1, 2);

It worked!

The only thing now is that"AUD" and"USD" are not passed along in mini cart or cart pages.

It displays correctly on the homepage and product pages.

Why is so?

Thanks

Hello

Please  drop  me a  link to your site