Hi. I plan a strange setup for selling virtual goods. With my current setup I am not able to split different product types in my order processing. I plan to do a MVP and do not want to spent to much resources in it.
Is there a way to only allow one item (but in higher quantities) in the basket. So I add 5 times item A. When I add item B I get an error message "Please finish the order for every item separate".
Solved! Go to the solution
This is an accepted solution.
1) Set an event listener on your add to cart button so that when someone clicks on it, before adding to cart it checks to see how many line items are in the cart.
2) If there are > 0 line items in the cart, check to see if the line item in the cart is the same as the product you're adding (so they can add more quantity any time).
3) If > 0 line items and the line item in cart does not match the one on the product page, then show an error message instead of adding the product to cart.
Here's the documentation: https://shopify.dev/docs/themes/ajax-api. You'll want to use GET cart.js specifically for this project: https://shopify.dev/docs/themes/ajax-api/reference/cart#get-cart-js
If you need help from a developer feel free to reach out to my team at speedboostr.com/contact. We do customizations like this all the time.