From 92c021a7717d3ffcd539b8c72cbc400b7d62a6d9 Mon Sep 17 00:00:00 2001 From: jordanarldt Date: Tue, 17 Dec 2024 11:36:11 -0600 Subject: [PATCH] fix(storefront): STRF-12475 Use utils.api.cart.postFormData when updating variants in cart --- CHANGELOG.md | 1 + assets/js/theme/cart.js | 12 ++++++++++++ package-lock.json | 9 ++++----- package.json | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 610fa6a974..721e82b8e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/assets/js/theme/cart.js b/assets/js/theme/cart.js index b3cae98796..08a6415ce7 100644 --- a/assets/js/theme/cart.js +++ b/assets/js/theme/cart.js @@ -151,6 +151,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.postFormData(new FormData(this), () => { + modal.close(); + refreshContent(); + }); + } + + modalForm.on('submit', onSubmit); + this.productDetails = new CartItemDetails(this.$modal, context); this.bindGiftWrappingForm(); diff --git a/package-lock.json b/package-lock.json index 3717e2e87a..71253ee76c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "6.15.0", "license": "MIT", "dependencies": { - "@bigcommerce/stencil-utils": "6.18.0", + "@bigcommerce/stencil-utils": "6.19.0", "core-js": "^3.9.0", "creditcards": "^4.2.0", "easyzoom": "^2.5.3", @@ -1826,10 +1826,9 @@ } }, "node_modules/@bigcommerce/stencil-utils": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/@bigcommerce/stencil-utils/-/stencil-utils-6.18.0.tgz", - "integrity": "sha512-FVtwqocVB0c7wD7OSFvKLek5f3WCs8ERAo4lq+uK2GkqPW6y+IzmZHbEi74HdtlTMuWGOg4G2NIT9RGaAVN1ng==", - "license": "BSD-4-Clause", + "version": "6.19.0", + "resolved": "https://registry.npmjs.org/@bigcommerce/stencil-utils/-/stencil-utils-6.19.0.tgz", + "integrity": "sha512-Z9tWyHc76f8mi/Nnfae2NHSP8e6jC7KVU8cNrXSuWWfNhB2hoWd+GJqG9E3Uu+CKNwKCHeg7qpMuF8gsVn4xNw==", "dependencies": { "eventemitter3": "^4.0.4", "uuid": "^9.0.0", diff --git a/package.json b/package.json index 117d244f29..c6e9008473 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "author": "BigCommerce", "license": "MIT", "dependencies": { - "@bigcommerce/stencil-utils": "6.18.0", + "@bigcommerce/stencil-utils": "6.19.0", "core-js": "^3.9.0", "creditcards": "^4.2.0", "easyzoom": "^2.5.3",