I’ve set up multi currency on my site with Snipcart and Weweb and everything is working as it should, but have no idea how to display the price on the products according to the currency selected. Please help!
Hey @manifesto,
It really depends on how your website is built, when using our multi-currency feature, you must define the price for each currency on the buy button.
You can get the current currency with our JavaScript SDK using this:
const currency = Snipcart.store.getState().cart.currency;
You could probably use this value to show the correct price.
I’m not sure how WeWeb is flexible, but if you can add some custom JavaScript, that could be a way to do it.
Let me know if that helps!
That helps put me in the right direction, but unfortunately I’m not particularly skilled with javascript (I can get a rough idea what’s going on when reading it, but writing it myself is beyond me)
Can certainly add custom JavaScript in WeWeb.
Once I’ve used const currency = Snipcart.store.getState().cart.currency;
to get the currently selected currency, how do I pull the correct price from the price I’ve defined in the buy button?
Or would it be a matter of hiding and showing divs based on the currency selected?
You really obviously haven’t read my post.
I’ve already set up multicurrency. That video did certainly help me do that, but it doesn’t help with displaying the price on the product page in the correct currency.
Hey @manifesto,
We don’t have specific methods to display the price for the currency that is selected on your site.
But, I wrote this quick example available here. It shows how you an use our JavaScript SDK to implement a solution to display price depending on the selected currency on your site.
Hope this helps!
Hi @Charles,
Amazing! That did the trick quite nicely! Is there a way for it to work across multiple instances of the div classes on a page?
It will show and hide one div classed “price price-gbp” (for example), but it only seems to work on the one. So if I have a product list page with all my products it won’t display all their prices
Hey @manifesto,
Glad it helped! I updated my example to fix the issue you mentioned and I also optimized it a bit.
Let me know if that helps.
Thats perfect! Works a charm. Many thanks!