Streaming live at 10am (PST)

Shopping Cart - Seeking help for enforcing quantity limit before checkout

I’m currently setting up an e-commerce site with 1 single item for sale. We are only allowing 1 item per order due to limited quantities available.

I’m trying to add some custom code that will either prevent someone from checking out (error message) and/or force the quantity before checkout.

I know you can hide the quantity selector, which will prevent someone from modifying the quantity, but that’s not going to prevent someone from closing the cart and adding another item before checking out.

Ideally, I’d like some logic on the page to check the current cart quantity. If the quantity is 0, add the item. If it’s greater than 0, set it to 1. Something along those lines should work but I’m not sure how to target the elements on the page or intercept when these calls are made or where to inject the code.

Thoughts?

2 Likes

I need the same .

I would also need fix number like 50, 100, 150, 200

Hi all.
Josh from Foxy here. What you’re after is possible with Foxy + Webflow. Not only can you limit quantity added to cart, but you can tell Foxy the quantity max (and minimum) so that customers can’t exceed the max quantity if they make changes in the cart or checkout.

More info about our seamless Webflow integration can be found here: https://www.foxy.io/webflow We offer an unlimited free trial and free one-on-one onboarding. Please don’t hesitate to reach out if we can help you get started.

Thanks,
Josh

If you want to do this with code, you need to add a mutation observer to the shopping cart (https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver). It checks for changes in the DOM tree, and therefore is able to detect live changes in the shopping cart.
Therefore you could look at the updates of the cart and update a var with the qty each time something changes and use this var to do whatever…

But your use case doesn’t seem to require such a thing.
(And If you only sell one item in one qty… you’d probably be better off implementing shopify buy button or directly stripe integration with your webflow site. Might be cheaper than webflow e-commerce plan)