So here are the way to apply manual discount automatically on checkout page.. if particular products are in cart items.
You can also use automatic discount for same purpose but if 1 automatic is already active then you can choose this 2nd way to apply auto discount.
As currently shopify plus support only one automatic discount at a time.
So here is the script you have to apply on cart liquid file of your theme. Mine is ( cart-template.liquid ) in Debut theme.
NOTE : Please create a normal discount in admin first then you can apply that code there in script.
Here is the way to add discount code in shopify….
Like in the above screenshot.. click on create discount button. New window will be like this..
Choose first one and next window will be..
Add your discount code there like helo or something you like or as per your purpose..
So we have now discount code name “helo” ..
add this script to near after form start.. on your theme cart liquid file.
<form action=”/cart” method=”post”>
if you want to match single product in cart item then..
{% assign prod = false %}
{% for item in cart.items %}
{% if item.product.title == 'Your product name or title' %}
{% assign prod = true %}
{% endif %}
{% endfor %}
{% if prod %}
<input type="hidden" name="discount" value="helo"/>
{% endif %}
Please change “Your product name or title” to with your product name.
If you want to match two products then follow this script..
{% assign prod = false %}
{% assign prod1 = false %}
{% for item in cart.items %}
{% if item.product.title == 'Your product name or title' %}
{% assign prod = true %}
{% endif %}
{% if item.product.title == 'Your product name or title 2' %}
{% assign prod1 = true %}
{% endif %}
{% endfor %}
{% if prod and prod1 %}
<input type="hidden" name="discount" value="helo"/>
{% endif %}
So above scripts will only add discount on cart page if they matched to your mentioned products name and discount code will reflect on checkout page automatically.
You can also show message to cart page like this.. showing in red color on right side of screenshot.
add this one script to where you want to show message on cart page.
{% if prod and prod1 %}
<strong class="cod-check1">*Your discount will apply in checkout.</strong>
{% endif %}
I hope this will help you .. If you need more help then contact with me using chat box.
Thanks 🙏