From 46e2259359e166222ba414e8326b3a8a0aec4f34 Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Wed, 31 Oct 2018 21:31:44 +0100 Subject: [PATCH 1/2] increase quantity limit in cart --- frontend/src/constants/cartConstants.js | 2 +- frontend/src/constants/coMarketConstants.js | 2 +- frontend/src/containers/cart/components/CartItem.jsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/constants/cartConstants.js b/frontend/src/constants/cartConstants.js index 2a3acb8..b4b6801 100644 --- a/frontend/src/constants/cartConstants.js +++ b/frontend/src/constants/cartConstants.js @@ -65,7 +65,7 @@ export const cartMessages = { QUANTITY_UPDATED: "Quantity has been updated for the package!", INVALID_PACKAGE_FOR_REMOVE: "This package is not available in your cart! In case this error persists contact Co-Market!", PACKAGE_REMOVED_FROM_CART: "The package has been removed from the cart!", - INVALID_QUANTITY: "The quantity can be a number between 1 and 100!", + INVALID_QUANTITY: "The quantity can be a number between 1 and 65000!", CART_EMPTY: "You must have at least one package in the cart!", NO_DELIVERY_ADDRESS: "No delivery address was added! Please fill the necessary info", INCOMPLETE_DELIVERY_ADDRESS: "Incomplete delivery address. Please review!", diff --git a/frontend/src/constants/coMarketConstants.js b/frontend/src/constants/coMarketConstants.js index cb7fccc..55bdf3f 100644 --- a/frontend/src/constants/coMarketConstants.js +++ b/frontend/src/constants/coMarketConstants.js @@ -32,7 +32,7 @@ export const coMarketMessages = { QUANTITY_UPDATED: "Quantity has been updated for the package!", INVALID_PACKAGE_FOR_REMOVE: "This package is not available in your cart! In case this error persists contact the Co-Market!", PACKAGE_REMOVED_FROM_CART: "The package has been removed from the cart!", - INVALID_QUANTITY: "The quantity can be a number between 1 and 100!", + INVALID_QUANTITY: "The quantity can be a number between 1 and 65000!", CART_EMPTY: "You must have at least one package in the cart!", NO_DELIVERY_ADDRESS: "No delivery address was added! Please fill the necessary info", INCOMPLETE_DELIVERY_ADDRESS: "Incomplete delivery address. Please review!", diff --git a/frontend/src/containers/cart/components/CartItem.jsx b/frontend/src/containers/cart/components/CartItem.jsx index 9618061..6eca641 100644 --- a/frontend/src/containers/cart/components/CartItem.jsx +++ b/frontend/src/containers/cart/components/CartItem.jsx @@ -35,7 +35,7 @@ class CartItem extends Component { } isQuantityValid(quantity) { - return quantity > 0 && quantity <= 100; + return quantity > 0 && quantity <= 65000; } updateQuantity(cartItem, quantity) { From 1a33593cbe2ce6efa8df4e03a3320900458d276a Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Thu, 1 Nov 2018 00:28:33 +0100 Subject: [PATCH 2/2] add more validation --- backend/app/plugins/wiaas/includes/class-wiaas-cart.php | 4 ++++ frontend/src/containers/cart/components/CartItem.jsx | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-cart.php b/backend/app/plugins/wiaas/includes/class-wiaas-cart.php index 98c75f4..f2f3098 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-cart.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-cart.php @@ -248,6 +248,10 @@ class Wiaas_Cart { * @return bool */ public static function update_package_quantity($package_cart_item_key, $new_quantity) { + if ($new_quantity > 65000){ + return false; + } + $cart_item = WC()->cart->get_cart_item($package_cart_item_key); if (!$cart_item) { diff --git a/frontend/src/containers/cart/components/CartItem.jsx b/frontend/src/containers/cart/components/CartItem.jsx index 6eca641..b0736b7 100644 --- a/frontend/src/containers/cart/components/CartItem.jsx +++ b/frontend/src/containers/cart/components/CartItem.jsx @@ -40,8 +40,8 @@ class CartItem extends Component { updateQuantity(cartItem, quantity) { if(quantity) { - this.setState({itemQuantity: quantity}); if(this.isQuantityValid(quantity)) { + this.setState({itemQuantity: quantity}); this.sumPrices(cartItem, quantity); this.props.dispatch(updateQuantity(cartItem, quantity)); } else {