Skip to content

Commit

Permalink
Merge pull request #1661 from bookernath/fix-cart-404-quantity
Browse files Browse the repository at this point in the history
Reset cart quantity to 0 if we get a 404 for the cart
  • Loading branch information
bookernath authored Apr 22, 2020
2 parents 5933797 + caa1b30 commit 4c165ad
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion assets/js/theme/global/cart-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ export default function (secureBaseUrl, cartId) {
const cartQtyPromise = new Promise((resolve, reject) => {
utils.api.cart.getCartQuantity({ baseUrl: secureBaseUrl, cartId }, (err, qty) => {
if (err) {
reject(err);
// If this appears to be a 404 for the cart ID, set cart quantity to 0
if (err === 'Not Found') {
resolve(0);
} else {
reject(err);
}
}
resolve(qty);
});
Expand Down

0 comments on commit 4c165ad

Please sign in to comment.