Skip to content

Commit

Permalink
fix(storefront): STRF-12475 Use fetch when updating variants in cart
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanarldt committed Dec 16, 2024
1 parent b25b270 commit 27897ae
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix GH build action & added package version and short commit hash to artifact names in GitHub Actions workflow for improved traceability and uniqueness. ([#2494](https://github.com/bigcommerce/cornerstone/pull/2494))
- Bump stencil-utils to 6.18.0 ([#2493](https://github.com/bigcommerce/cornerstone/pull/2493))
- Bump other GH actions to fix warnings related to old versions. ([#2495](https://github.com/bigcommerce/cornerstone/pull/2495))
- Use fetch when updating variants in cart ([#2521](https://github.com/bigcommerce/cornerstone/pull/2521))

## 6.15.0 (10-18-2024)
- Cornerstone changes to support inc/ex tax price lists on PDP [#2486](https://github.com/bigcommerce/cornerstone/pull/2486)
Expand Down
17 changes: 17 additions & 0 deletions assets/js/theme/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export default class Cart extends PageManager {
.hide(); // TODO: temporary until roper pulls in his cart components
this.$activeCartItemId = null;
this.$activeCartItemBtnAction = null;
this.$refreshBtn = $('#refresh-cart-test');

this.$refreshBtn.on('click', () => {
this.refreshContent();
});

this.setApplePaySupport();
this.bindEvents();
Expand Down Expand Up @@ -151,6 +156,18 @@ export default class Cart extends PageManager {
this.$modal.one(ModalEvents.opened, optionChangeHandler);
}

const modalForm = this.$modal.find('form');
const refreshContent = () => this.refreshContent();
async function onSubmit(event) {
event.preventDefault();
utils.api.cart.updateCartItemOptions(new FormData(this), () => {
modal.close();
refreshContent();
});
}

modalForm.on('submit', onSubmit);

this.productDetails = new CartItemDetails(this.$modal, context);

this.bindGiftWrappingForm();
Expand Down

0 comments on commit 27897ae

Please sign in to comment.