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 5 replies, has 2 voices.

Last updated by Shekhar Bhandari 3 months, 1 week ago.

Assigned support staff: Shekhar Bhandari.

Author Posts
July 3, 2019 at 3:22 pm

katieW-3

I am trying to: Return the prices in the various language's currencies, but when the price field is blank or set to zero, it returns the default language price instead. We want it to return blank or zero.

Link to a page where the issue can be seen: hidden link

I expected to see: Australian prices (set to zero)

Instead, I got: Uk English prices

The code that handles is as follows, ideally we want to see if the price is greater than zero, if it's not we want to output POA. This works fine on simple products, but the above URL is of a grouped product.

            if((float)$product->get_price() >0):
                $product_price = apply_filters('woocommerce_get_price_suffix',wc_price($this_price));
	        else:
	            $product_price = get_woocommerce_currency_symbol().__(' POA','text-domain');
	        endif;
July 4, 2019 at 3:39 am #4140151

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

Welcome to WPML support. I'd be assisting you further on this issue.

As far as I know, prices are synchronized between languages so can you please let me know how you are adding prices for languages individually, are you using multi-currency?

Further, we recently released new versions of WPML plugins with fixes and improvements so could you please update the plugin to the latest version and let me know if this helps?

NOTE:

+ Make a backup (both files and database) for your site before updating/proceeding anything (Always a good practice!). You can use a plugin for this if you like. I often use the Duplicator plugin for this purpose. See: http://wordpress.org/plugins/duplicator/

Look forward to your reply.

Thanks

July 8, 2019 at 10:59 am #4161481

katieW-3

Hi Shekhar,

Thanks, we use WooCommerce multilingual which adds extra pricing options for the difference currencies when editing the root / default language version of the simple or grouped product.

The prices comes through fine when we have entered an actual value e.g say in the root language (which is GBP) we put in £100, in USD we put in $150 and that shows fine. However we need it so when the price is blank e.g. for Australian Dollars (AUD), if the value is empty or zero, we want to modify the price to say POA instead.

Attached is a screenshot with how we input the pricing and example of blank price fields that should become POA, and the full WP filter we are using:

        function in__show_poa($price){

        	return get_woocommerce_currency_symbol().__(' POA','text-domain');
        }
        add_filter('woocommerce_empty_price_html','in__show_poa');
        add_filter('woocommerce_grouped_empty_price_html', 'in__show_poa');

and then when we want to show the price using custom code:

            if((float)$product->get_price() >0):
                $product_price = apply_filters('woocommerce_get_price_suffix',wc_price($product->get_price()));
	        else:
	            $product_price = get_woocommerce_currency_symbol().__(' POA','text-domain');
	        endif;	

For an example this product here:
UK/Default Language - pricing is fine: hidden link - look in particular at Lantek IV 500MHz with PL Adapters, it's £7,395 - that's fine, that is what it is set to (see the screenshot)

However if you view the page in Canada for example:
hidden link - again look at Lantek IV 500MHz with PL Adapters - it is set to $7,395 CDN which is totally wrong as that's the UK/Default language price coming back from the WooCommerce function.

This had been previously working just fine it seems something has broken somewhere.

We have a test server to start trying upgrades on this afternoon with a bit of luck, but we urgently need to fix this issue.

Vicky

July 8, 2019 at 11:10 am #4161685

katieW-3

Hi Shekhar,

Just to add, it appears that some of the product models do indeed show POA, e.g. LanTEK IV 3000MHz with PL Adapters because the price has been entered as 0.00 - which seems to do the trick, but we didn't always have to do that.

However, is this the expected functionality?

If so, we will need to enter 0.00 for all the products.

Vicky

July 8, 2019 at 12:10 pm #4162225

katieW-3

Hello Shekhar,

Sorry I've had to create a bodge piece of code to only show POA in certain languages due to our customer registering an official complaint that we hadn't managed to resolve the issue quickly enough.

Can we co-ordinate a time to demo the problem, as I say we should have a development site soon.

Thanks,
Vicky

July 9, 2019 at 3:57 am #4167423

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

To help you here, I created a fresh new install, you can log in to the test site using the link: hidden link

I added your code to display POA and noticed a few things:

- the code works properly for the default currency

- However, the code doesn't work for secondary currency, if the 2nd currency is left empty or 0 it is using automatic currency rate defined in WooCommerce->WooCommerce Multilingual->Multi Currency and displaying the price accordingly.

- I also tested using 0.00 and it's working properly. I modified the code abit more to work with default theme

if((float)$product->get_price() > 0):
    ?>
<p class="<?php echo esc_attr( apply_filters( 'woocommerce_product_price_class', 'price' ) );?>"><?php echo $product->get_price_html(); ?></p>
<?php
else:
    $product_price = get_woocommerce_currency_symbol().__(' POA','text-domain');
	echo $product_price;
endif;  
?>

Being so, I can let you know that it's normal behavior to have the currency converted when it's zero, it makes sense to convert this automatically as settings a price to 0 on a specific currency is not a good option, being so I request you to set those prices to 0.00 which you are already using to fix the issue.

Let me know if this helps.

Thanks