How can I limit product quantity in cart using ruby and rail?

Hi,

We are using the shopify script editor app to “Limit the product quantity add to cart” and script is working great but unfortunately shopify announced to deprecate this app in 2024 august.

Found many app with similar functionality but all of them using the javascript to making the quantity limit check on front-end and ignore the backend although Script editor app apply the backend check via ruby and rail.

Anybody here to help me how I can apply the quality limit check and refer any app that using the ruby and rail.

Thanks!

Zain

Hello Zain,

Possible but need customization you can check the idea.

You need to apply the logic on PDP page.
First step, you need to check the quantity selection on click of the atc button. If it’s greater than 3 you have to restrict the default functionality of the atc button and show a message that you can’t add more than 3.
Second step, if customer quantity selection is just 1 and they use same process to add more than 3 items then in this case you have read the cart on every click of the atc button through ajax and If same product counts is greater than 3 show the message and restrict the customer to add product to cart.

Third step, in the cart page make a check on the quantity selector so the customer cannot increase quantity more then 3.

btw if you need custom solution you can drop me an email for further discussions.

Thanks

HI Guleria,

Your suggested solution work but with lot of files changes in theme but still depend on front-end.

Any solution for backend-side (Server Side) ?