bigcommerce / stencil-cli

BigCommerce Stencil emulator for local theme development
https://developer.bigcommerce.com/stencil-docs
BSD 4-Clause "Original" or "Old" License
103 stars 140 forks source link

fix: STRF-11899 Update cart when multiple coupons are removed #1197

Closed huntario closed 3 months ago

huntario commented 3 months ago

What?

When removing multiple coupons, bust the cache because the cart has updated. If we don't the request signature just above this point - https://github.com/bigcommerce/stencil-cli/blob/879019066324c719b623eaf02eb76c26882bec3e/server/plugins/renderer/renderer.module.js#L194 - in the code will be the same as the last and we erroneously return 'cachedResponse2' which is stale.

The request to update the cart is different because it contains the coupon ID, but since it uses a redirect back to the cart, that request is undifferentiated from the previous request to the cart.php

Tickets / Documentation

Add links to any relevant tickets and documentation.

Screenshots (if appropriate)

Before: First coupon removal works as expected, but subsequent removals don't appear to take effect until refresh.

https://github.com/bigcommerce/stencil-cli/assets/5630999/0c0c1041-6b4f-4e5b-8a5f-91cc2bb9c7ab

After: additional coupons removed as expected

https://github.com/bigcommerce/stencil-cli/assets/5630999/f6af7f05-9354-4346-affa-59064e16ce42

cc @bigcommerce/storefront-team

huntario commented 3 months ago

...we just need to double check on historical reason of having this

Looks like it was added here - https://github.com/bigcommerce/stencil-cli/pull/124 - with the intention of speeding up development. Noticed this comment - https://github.com/bigcommerce/stencil-cli/pull/124#issuecomment-154156585 - which lead to clearing the cache if a post request is used. I've linked the ticket for that change to the current ticket.

...and keep eyes on amount of traffic we potentially can have because of this change

I've placed a link in the internal ticket that should allow us to track any change in usage.

github-actions[bot] commented 3 months ago

:tada: This PR is included in version 7.5.5 :tada:

The release is available on:

Your semantic-release bot :package::rocket: