Skip Navigation

[Resolved] Which field to use in views for woocommerce currency_switcher shortcode?

This support ticket is created 7 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by timB 7 years, 11 months ago.

Assisted by: Luo Yang.

Author
Posts
#395818
BuySection.png

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.

#396184

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"]

#396245
Using _price.png

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

#396278

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

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.