Add a message to cart page when specific products are in the cart.

Topic summary

A merchant running a doorbuster sale wants to display a custom message on the cart page when five specific products are added via a pre-built cart link with a discount code.

Key Responses:

  • One user clarified that checkout page customization requires Shopify Plus; standard plans cannot modify checkout pages
  • The merchant confirmed they want the message on the cart page (not checkout), making customization possible

Proposed Solutions:

  1. Discount code detection: Add Liquid code to cart-template.liquid that checks if a specific discount code is applied and displays a message accordingly
  2. Product tag-based approach: Use conditional logic to detect products with specific tags in the cart and show custom messages
  3. Metafields method: Utilize product metafields to display data based on cart contents (video tutorial provided)

Current Status:
The merchant attempted the discount code solution but couldn’t get it to display. The issue remains unresolved, with suggestions to verify discount code setup and code placement within the Debut theme’s cart template file.

Summarized with AI on October 28. AI used: claude-sonnet-4-5-20250929.

Hi there, I have a doorbuster sale going on. I’ve created a link that looks like this: https://the-lynnette-bonner-bookstore.myshopify.com/cart/40611668361401:1,40593021010105:1,40593114759353:1,40593212113081:1,40593309991097:1?discount=WELCOME

What I’d like to do is add a message to the shopping cart checkout page only when those 5 products are in the cart with that discount code applied. Is this possible? Can I add a string to the above link to show a message? Or how would I go about this? If you can help, can you please tell me in Kindergarten lingo what to do? :slightly_smiling_face:

I’m using the Debut theme.

Lynnette

Hi @LynnetteBonner and welcome to Shopify Community.

Unfortunately Shopify checkout can be modified only on Shopify Plus plans.

There’s no way in other plans to show a custom message in checkout pages.

Okay, thanks.

First, you need to create a discount code for 5 products, refer https://help.shopify.com/en/manual/discounts/create-discount-codes
Ex: Discount code: Test
Then you just need to add this code to cart( file sections/cart-template.liquid :disappointed_face:

{%- assign cartDiscounts = 'template ’ | split: ’ ’ -%}
{%- if cart.cart_level_discount_applications.size > 0 -%}
{%- assign cartDiscounts = cart.cart_level_discount_applications -%}
{%- for discount_application in cartDiscounts -%}
{% if discount_application.title == ‘Test’ %}
// Show message
{% break %}
{% endif %}
{%- endfor -%}
{%- endif -%}

1 Like

Thank you. I tried, but I can’t get it to show up. Can you tell me where in the Debut theme in cart-template.liquid I need to put this code?

I changed the name to my discount which is WELCOME. And I put “test” where you have Show message. But nothing ever shows up on the cart page.

You can add it anywhere in the file.
Can you check the discount code again, after adding 5 products, it will automatically discount like this: https://i.imgur.com/3tYiI5m.png
This display is supported by debut theme, you don’t need to change any code, if it shows, my code will work fine too. If not, you need to check the discount code again or contact shopify.
Hope it helps!

I needed to add a custom message when 2 specific products were added to the cart. Add this in your cart.liquid where the {% for item in cart.items %} starts.

{% if item.product.tags contains ‘final’ %}

FINAL SALE. READ SIZE INFO.
{% endif %} *Check where exactly displays better for your needs (try and error)
1 Like

Hi @LynnetteBonner

Please refer the video below how you can use metafields to print data based on product in cart.

Hope this will help it needs a very small piece of code.