Giving specific customers a discount

Solved
Anne-Marieke
Tourist
7 0 1

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%' %}
<input type="hidden" id="discount" name="discount" value="Customer Condition-5%">
{% else if customer.tags contains '10%' %}
<input type="hidden" id="discount" name="discount" value="Customer Condition-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%" %}
<input type="hidden" id="discount" name="discount" value="Customer Condition-3%">
{% else if customer.tags contains "5%" %}
<input type="hidden" id="discount" name="discount" value="Customer Condition-5%">
{% else if customer.tags contains "7%" %}
<input type="hidden" id="discount" name="discount" value="Customer Condition-7%">
{% else if customer.tags contains "8%" %}
<input type="hidden" id="discount" name="discount" value="Customer Condition-8%">
{% else if customer.tags contains "10%" %}
<input type="hidden" id="discount" name="discount" value="Customer Condition-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!

 

Discounts are madeDiscounts are madeThis worksThis worksThis doesn't workThis doesn't work

0 Likes
mysticmac
Tourist
7 2 0

This is an accepted solution.

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

0 Likes
twinkleppc
Excursionist
29 3 4

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. 

Ravi Thakor
Digital Marketing Specialist | twinkleppc.co
email: ravi@twinkleppc.co
0 Likes
Anne-Marieke
Tourist
7 0 1

I think this did the trick, thanks!

0 Likes