duncanmcclean / simple-commerce

A simple, yet powerful e-commerce addon for Statamic.
https://statamic.com/addons/duncanmcclean/simple-commerce
Other
143 stars 37 forks source link

Changing the tax config doesn't update on Information page #450

Closed francoismajor closed 3 years ago

francoismajor commented 3 years ago

Description

When changing the rate for taxes, the tax calculation is not updated on the Information page (checkout).

Expecting: tax amount to be updated on page load.

Steps to reproduce

  1. Basic starter kit
  2. Set tax rate to any amount
  3. Add a product to cart, and go to cart.
  4. Change the tax rate
  5. Reload page, or go back to site, go back to cart. Tax is not updated.

If you go to the next step (shipping) or add a product to the cart, the tax amount will be updated. So these two actions seem to trigger a cart update(). However, the basic checkout page never updates itself.

This is noticeable with the tax rate, but leads me to wonder if all of the values are also not updated on this page.

If I change a tax rate on a production site, and a client is shopping at the same time, it could be confusing. However, going to the next step updates the amount and at least (despite the person wondering WTF) the final amount will probably be the right one.

Environment

Statamic 3.1.31 Solo Laravel 8.52.0 PHP 8.0.3 doublethreedigital/simple-commerce 2.3.14

duncanmcclean commented 3 years ago

Ohh, you're changing the tax rate when you have an existing cart in progress?

I'm not really sure how we fix that, I don't really want to be recalculating the order's totals on every request for performance reasons.

francoismajor commented 3 years ago

Well I was just changing it period 😉 and trying to figure out why the total didn't seem to match my expected outcome. But this led me to notice that refreshing the page didn't update the totals displayed. I'm aware this is an edge case and probably shouldn't be an issue in production.

Now that the calculation is updated, it's less of an issue for me. I was just expecting the _cart to be updated on any changes. (like I mentionned, it is updated on adding a product or going to a further step) Feel free to close the issue if you think the behavior is correct.

duncanmcclean commented 3 years ago

Yeah, there's not much I can do if you change it with an active cart.

Whenever the customer updates their shipping info, adds items to the cart or just before payment, the order totals will always be recalculated so technically you could change it right before they checkout and they would pay the updated tax.

I'm going to close this as I think this is probably fine - I don't see people changing their tax rate in production mid-cart. Even if they do I think that's a fine trade-off.