Hi, my store sells pre-made meals. We have Fresh meal packs and Frozen meal packs. The Fresh meal packs are made to order and have a 7 day lead time. The Frozen meal Packs are already made and ready to ship out overnight. The Fresh meal and Frozen meals can’t sent together as one is sent via frozen courier and the other via chilled courier.
Is there a way to exclude customers from adding products from both the Fresh meals collection and the Frozen meals collection into the same order either natively through Shopify or through an external app?
Hi @HelloMeals , Regarding the app, i am not sure but it’s possible, we can do it vie custom code. The basic principle works here, first, we will check the item is exist on cart from 1 collection, if yes, we won’t allow the customer to add the product from the 2nd collection, if No, he/she can able to add the product.
@HelloMeals you can do this by checking the cart contents and then conditionally loading an add to cart button or a message.
Here’s how I would approach it:
-
Get the cart’s contents with liquid: https://shopify.dev/api/liquid/objects/cart#cart-items
-
Get the current product type with liquid, and compare against the cart item’s product type
-
If the condition you want to match exists, show a message about only allowing 1 thing per order. If not, then show the normal add to cart button
If you need to do it dynamically (for example if people can add other products to cart from a product page), then you would use the Shopify ajax API instead to get the cart contents and take action on the add to cart button: https://shopify.dev/api/ajax/reference/cart
Hi @HelloMeals ,
Really great question!
I completely understand what you’re looking for and why, thanks for breaking that down. It does seem quite customised and I had a look to see if any apps in the Shopify App store could do what you’re looking for abd the MinCart - Min Max Order limits app might be an option. The line in the app description which stood out for me was:
allows you to specify minimum order limits & maximum limits on your store in 7 different ways: on the entire cart, specific products, variants, collections, vendors, product type or tags
There is a 7-day free trial so it could be worth taking a look to see if this works for you!
Alternativley as @Ajay-app-dev mentioned, the next way to go about this would be to have something custom made by a Shopify Expert. You can see the Shopify Expert directory from the link here.
Do you think the MinCart app could work for you? Let me know!