I am trying to: Have the listed currency change according to the one selected in the WooCommerce [currency_switcher] shortcode
I visited this URL: https://wpml.org/documentation/related-projects/woocommerce-multilingual/multi-currency-support-woocommerce/
I expected to see: The currency number update to EUR or USD when changed on front end
Instead, I got: no change.
I am using the
[types field="views_woo_price"][/types]
field to display the price. But I have also entered fixed custom prices for EUR and USD in WooCommerce.
I wonder whether I should be using a different field so the price is updated, or if there is a setting I need to change to make it work.
I have already placed a ticket on the WPML board for this, but I'm doing it here in case its to do with Views and WooCommerce Integration.
Please see the attached screenshot for the price selector on the page. When the drop-down is changed, the price doesn't change.
Dear tim,
Woocommerce is using a hidden field "_price" to store the product price, I suggest you try with Views shortcode [wpv-post-field], for example:
[wpv-post-field name="_price"]
Many thanks for that Luo.
I did as you suggested, using "_price" - so the code for the price section is as follows:
<!-- wpv-loop-start -->
<center>Show price in: [currency_switcher]</center>
<wpv-loop>
[wpv-post-body view_template="BaseProduct1"]
</wpv-loop>
<!-- wpv-loop-end -->
And the BaseProduct1 Views Template now uses "_price" thus:
<h3>Buy Now</h3><table width = "100%">
<tr><td>
<a href="[wpv-post-url]" class="BuyProductTitle">[types field="modification-short-description"][/types]</a>
</td><td class="detailtxt"><div><a href="[wpv-post-url]">[wpv-post-featured-image size='original' class='icon-display']</a></div>[types field="amount-mg"][/types]mg<br>[wpv-post-field name="_price"]</td><td width="100%" style="text-align:right;">[wpv-woo-buy-or-select add_to_cart_text="Add to Cart" link_to_product_text="" group_add_to_cart_text="" external_add_to_cart_text="" show_quantity_in_button="no" show_variation_options="no"]</td>
</tr>
</table>
The price displays when the currency selector is set to UKP£ (the default setting) but when it is changed an error is thrown, once for each product listing on the page:
"Warning: Invalid argument supplied for foreach() in /home/absoluteantibodi/public_html/wp-content/plugins/wp-views/embedded/inc/wpv-shortcodes.php on line 2866"
See attached screenshot for how it looks on screen.
Can you suggest what might be causing the error, and how I can fix it?
Many thanks
Tim
Hi again Luo
I have been doing more experimentation with shortcodes and found one which works:
[wpv-woo-product-price]
Thank you for pointing me in the right direction. This issue is fixed now, and that shortcode works beautifully. It even implants a currency symbol according to the currency selected in the drop-down.
Hurray!
T