Custom increment qty in Dawn Theme and validation before adding to cart

Custom increment qty in Dawn Theme and validation before adding to cart

thethninaye23
Visitor
1 0 0

Hello,

 

We would like to implement custom increment quantity for certain products in Dawn Theme i.e., selling in  multiples of 5 or 10. We have already implemented it using setting metafields for those products and using them for min, step and value in the main-product.liquid. However, two issues we found are -

  • If the stock available for the product is less than the qty selected by the customer, it will add the stock available to the cart, without validating with the increment qty. For example, the stock available is 25 and the customer input 30 for product with an increment qty of 10, then it will add 25 to the cart. What we want to do is to add only in the multiples of 10. Where can we check and control the quantity that's being added to the cart?
  • Current default quantity selector allows the user to type in the number and it conflicts with our increment qty. Even though we set the increment qty to 10, if the user types in a number that's conflicting with our increment, how can we validate that? Or how can we make it not typeable? 
Reply 1 (1)

gr_trading
Shopify Partner
2053 149 212

Hi @thethninaye23 

 

Issue 1.

 

You should get the available quantity on page load and create a input field which will calculate how much quantity can be added in cart for current product.

 

Validate the value on click of add to cart.

 

Issues 2.

 

Convert your quantity input with select drop-down.

 

Hope this will help...

For any custom development WhatsApp or connect at Email ID: support@grtrading.in for quick consultation. | Shopify Free codes
To support Buy Me a Coffee