Should not Add to Cart if Specific Product is Already in Cart

Topic summary

A user seeks help implementing a cart restriction feature for their Shopify store involving Gift Cards and other products.

Desired functionality:

  • When a Gift Card is already in the cart, attempting to add any other product should trigger a message preventing the addition
  • Conversely, when other products are in the cart, adding a Gift Card should display a similar blocking message
  • The restriction prevents customers from purchasing Gift Cards and regular products in the same transaction

Current status:

  • The user is requesting customization guidance to achieve this mutual exclusivity between product types
  • No solutions or responses have been provided yet
  • The implementation would require custom code to check cart contents before allowing new items to be added
Summarized with AI on November 18. AI used: claude-sonnet-4-5-20250929.

Hi guys, can you help me with the customization that I wanted. Here is what I want to achieve.

Product: Gift Card

Product: Other Product

If Gift Card product is In Cart already, and assuming that I want to add another product. In the Other Product page, clicking the Add to Cart button should show Message Box that says, “Cannot add this to cart because Gift Card is in Cart” something like that.

If Other Product is In Cart, and assuming that I want to add a Gift Card product. In the Gift Card product page, clicking the Add to Cart button should show message box that says, “Other Product is In cart, you can’t purchase them at once.” something like that.

Hope you help me guys, please give me your thoughts.

Thanks in advance.