To do math operations you'd need to use Math filters.
{{ variant.price | minus:4500 | money }}
Hi,
This seems to be a very old thread so hopefully someone picks up on this.
I'm trying something similar and have used the Maths filters but still doesn't seem to be working. I'm trying to take 20% off for customers tagged "Trade".
I have put the following code on the product-template.liquid page. My edits are in bold.
@PadraigCahill All you've done by editing the template code is changing how the price is displayed to the user on that page. You've not affected the price change permanently.
Unfortunately I don't know of a way to make the change permanently except by using Shopify Wholesale Channel, which allows you to set custom price lists and assign them to customer tags, or by using Shopify's Script Editor app to affect lasting price change at the cart/checkout. Both of these features are available only to Shopify Plus stores.
What you've done, in combination with what I did using Script Editor (see below), would effectively provide you with a DIY method for discounting your prices based on customer tag. Yours is the visual change on the PDP, the script I wrote below applies a discount at the cart/checkout.
The way my script works is that a customer who is eligible for a discount must have two tags, one that identifies the customer as being eligible for a discount ("PRO"), and another that defines the discount amount (e.g. "PRO35" or "BETA").
TAG = "PRO" #customer tag DISCOUNTS_BY_TAG = { #array of discounts "PRO25" => 25, "PRO30" => 30, "PRO35" => 35, "PRO40" => 40, "PRO45" => 45, "PRO50" => 50, "BETA" => 90, } MESSAGE = "Pro discount" #this is the text that appears next to discount credit customer = Input.cart.customer if customer #checks to see if user is logged in if customer.tags.include?(TAG) #checks to see if user has appropriate discount tag DISCOUNTS_BY_TAG.each_pair do |tag, discount| #cycle through the above array of tags if customer.tags.include?(tag) #pairs the customer's discount level from the above array of tags discount = #{discount} Input.cart.line_items.each do |line_item| line_item.change_line_price( line_item.line_price * (Decimal.new(1) - discount / 100), message: MESSAGE, ) end end end end end Output.cart = Input.cart
This is a code snippet for a line item script in the Script Editor app. You should setup a customer how you want them to be tagged before trying to implement the script, and use the Script Editor to thoroughly test your script before publishing. Ideally, you're a programmer or advanced Shopify user if you're attempting to code your own discount in the Script Editor.
In my code snippet, you only need to edit the first 3 variables to suit your needs:
User | Count |
---|---|
17 | |
15 | |
13 | |
12 | |
11 |