How can I apply specific discount percentages to customers?

Hi there!

A colleague of mine helped build our Shopify webshop with some adjustments in the code.

1 adjustment was that we give customers a tag and they receive a discount without having to enter a code themselves during the check out.
This looks like this:

{% if customer.tags contains ‘5%’ %}

{% else if customer.tags contains ‘10%’ %}

{% endif %}

Now we also want to apply a discount percentage of 3, 7 and 8%, but unfortunately this colleague is no longer working for us. That’s why I’m trying to learn it myself now. I have already created the discounts within the Shopify webshop and given names such as ‘Customer condition-3%’ and copied and adjusted the code like so:

{% if customer.tags contains “3%” %}

{% else if customer.tags contains “5%” %}

{% else if customer.tags contains “7%” %}

{% else if customer.tags contains “8%” %}

{% else if customer.tags contains “10%” %}

{% endif %}

But I don’t think it works yet. I have about 2% knowledge of Liquid language, so it’s a bit of a copy-paste gambling for me at the moment. So I have no idea if an ‘if’ ‘else’ code works like that.

Is there anyone who can point me to an error? Thanks in advance!

I think in Liquid it should be “elsif” not “else if”. See here: https://shopify.github.io/liquid/tags/control-flow/

Can you share the URL of your store? I can take a look.

It does look like calling {{ routes.cart_url }} from somewhere. Although it is hard to tell without actually looking into the theme files but I think you also need to make changes to this routes files which is getting imported.

I think this did the trick, thanks!

has anyone been able to pass multiple discount codes within the input type ?

e.g.

Discount 5% for collection A

Discount 10% for collection B

if you separate them with a comma then only the first one is passed to checkout