Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(checkout): CHECKOUT-7213 refresh cart page if no item in the cart #2360

Merged
merged 2 commits into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
- Added css classes for ApplePay Button [[#2344]](https://github.com/bigcommerce/cornerstone/pull/2344)
- Added styling config for the Bolt smart payment button [[#2356]](https://github.com/bigcommerce/cornerstone/pull/2356)
- Remove default whitespace from multiline input [#2355](https://github.com/bigcommerce/cornerstone/pull/2355)
- Refresh page if no more item in the cart [#2360](https://github.com/bigcommerce/cornerstone/pull/2360)

## 6.10.0 (03-23-2023)
- A bug with the display of the product quantity on the PDP [#2340](https://github.com/bigcommerce/cornerstone/pull/2340)
Expand Down
9 changes: 7 additions & 2 deletions assets/js/theme/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,16 @@ export default class Cart extends PageManager {
this.$cartAdditionalCheckoutBtns.html(response.additionalCheckoutButtons);

$cartPageTitle.replaceWith(response.pageTitle);
this.bindEvents();
this.$overlay.hide();

const quantity = $('[data-cart-quantity]', this.$cartContent).data('cartQuantity') || 0;

if (!quantity) {
return window.location.reload();
}

this.bindEvents();
this.$overlay.hide();

$('body').trigger('cart-quantity-update', quantity);

$(`[data-cart-itemid='${this.$activeCartItemId}']`, this.$cartContent)
Expand Down