verbb / snipcart

A Craft CMS plugin to integrate with Snipcart.
Other
21 stars 9 forks source link

Currency changes don't get saved. #5

Closed ghost closed 5 years ago

ghost commented 5 years ago

Describe the bug

The currency dropdown does not get saved.

To Reproduce Steps to reproduce the behaviour:

  1. Go to admin/settings/plugins/snipcart
  2. Choose a different currency, like EUR
  3. Save the page
  4. Reload the page
  5. The old USD currency is back.

Expected behaviour When I switch from USD to EUR and save the page, I expect to see EUR the next time I visit the settings page.

Desktop (please complete the following information):

Improvement

Would it be possible to read the activated currencies from Snipcart and use them for the dropdown?

mattstein commented 5 years ago

Thanks for posting the issue, @mikewink! I believe I created the setting because there isn't an explicit way to get active currencies from the Snipcart API. The setting should obviously be saved though, so I'll get that fixed.

ghost commented 5 years ago

If there is no way to get it from Snipcart, could we maybe have a simple key/value field and add it ourselves? 🤔

mattstein commented 5 years ago

Multi-currency support is something that's on my plugin roadmap but unfortunately not part of v1.

Right now that plugin setting is there to clarify what currency symbol should be displayed in the control panel when one isn't explicitly provided with a Snipcart record. Plugin-generated buy buttons will use a currency-agnostic number for the price, which Snipcart will interpret according to whatever default currency is set for the store (in its dashboard).

You can, however, define multiple currencies per item in its frontend definition if you'd like. Instead of using a single numeric value for the item's price, like data-item-price="20", you would use a JSON array such as data-item-price='{"usd": 20, "eur": 17.79}'.

mattstein commented 5 years ago

@mikewink I've fixed the not-saving bug for 1.0.4 and included the ability to override the product prices at the template level, so something like this is possible:

{{ productInfo.getBuyNowButton({
    price: { 'usd': 20, 'eur': 17.79 },
}) | raw }}

Going to hop over to #5 and see if I can work that in before testing and publishing this release. You're welcome to check out the 1.0.4 branch if you'd like to poke at it. Again, thanks for the feedback! :)

mattstein commented 5 years ago

Fixed in 1.0.4.

ghost commented 5 years ago

Saving works just fine now.

And having the option to override is great and opens up some options to work with on-demand currency conversions.

Thank you, Matt.