From ad29fbfafff8b8d901bd4ba84de13e012a4b75ef Mon Sep 17 00:00:00 2001 From: bc-zoharmuzafi Date: Fri, 29 Mar 2019 14:56:04 -0700 Subject: [PATCH] fixed update product qty by typing the new qty in the cart page --- CHANGELOG.md | 1 + assets/js/test-unit/theme/cart.spec.js | 3 +-- assets/js/theme/cart.js | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87efeec0b5..7eb9eb001a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Draft - Explicitly disable autocomplete in password entry input fields. [#1465](https://github.com/bigcommerce/cornerstone/pull/1465) +- Fixed update product qty by typing the new qty in the cart page (not with the arrows). [#1469](https://github.com/bigcommerce/cornerstone/pull/1469) ## 3.3.0 (2019-03-18) - Add option to hide breadcrumbs and page title. [#1444](https://github.com/bigcommerce/cornerstone/pull/1444) diff --git a/assets/js/test-unit/theme/cart.spec.js b/assets/js/test-unit/theme/cart.spec.js index 8f061b12a6..7ae39d7c5c 100644 --- a/assets/js/test-unit/theme/cart.spec.js +++ b/assets/js/test-unit/theme/cart.spec.js @@ -114,8 +114,7 @@ describe('cartUpdateQtyTextChange', () => { it('should CHANGE qty completly based on the cart-item-qty-input', () => { dataSpy dataSpy('manualQtyChange'); - spyOn(jQuery.fn, 'attr').and.returnValue(5); - spyOn(jQuery.fn, 'val').and.returnValue(2); + spyOn(jQuery.fn, 'val').and.returnValue(5, 2); c.cartUpdateQtyTextChange($dom); expect(UpdateSpy).toHaveBeenCalledWith('11111', 5, jasmine.any(Function)); diff --git a/assets/js/theme/cart.js b/assets/js/theme/cart.js index d7edcb090d..be62f1a9b3 100644 --- a/assets/js/theme/cart.js +++ b/assets/js/theme/cart.js @@ -67,11 +67,12 @@ export default class Cart extends PageManager { const oldQty = preVal !== null ? preVal : minQty; const minError = $el.data('quantityMinError'); const maxError = $el.data('quantityMaxError'); - const newQty = parseInt(Number($el.attr('value')), 10); + const newQty = parseInt(Number($el.val()), 10); let invalidEntry; + // Does not quality for min/max quantity if (!newQty) { - invalidEntry = $el.attr('value'); + invalidEntry = $el.val(); $el.val(oldQty); return swal({ text: `${invalidEntry} is not a valid entry`,