Hello,
I am attempting to create a discount script for multiple yet not all customers: a certain subset of customers in Texas and Oklahoma shall receive 50% off.
Currently, I am accomplishing this with a 50% discount code. However, I want to create a smoother user experience for the customer by having an automatic script discount.
Example:
- Customer 1, 2, 3 (who shop from Texas and Oklahoma) shall receive 50% when they check out
- Customers >3 (located anywhere) would pay full price
Could I accomplish this users a customer tag?
I am using the Debut theme.
Thanks,
Hi @NickBartelme , it’s great that you are trying to make a smoother experience for your customers. I think adding a tag to Customers 1, 2 and 3 would be a good way to go. Here is how I would propose setting your discount up:
- Create a customer tag called “tx_ok_discount”
- Add that tag to the set of customers you want to be eligible for the discount
- In your line item script, check that all of the following are true:
- the cart.customer.tags includes the “tx_ok_discount” tag
- that cart.shipping_address.province_code is either “TX” or “OK”
- If they are all true, apply the 50% off discount
- Otherwise, don’t apply any discount
If all goes well, then the following should all happen:
- If a customer’s state is TX or OK AND that customer has the tag “tx_ok_discount”, they get 50% off their order
- If a customer’s state is TX or OK but that customer DOES NOT have the tag “tx_ok_discount”, they pay full price
- If a customer’s state is NOT TX or OK AND that customer has the tag “tx_ok_discount”, they pay full price
- If a customer’s state is NOT TX or OK AND that customer DOES NOT have the tag “tx_ok_discount”, they pay full price
You can learn more about accessing the shipping information in a script here: https://help.shopify.com/en/manual/checkout-settings/script-editor/shopify-scripts#shippingaddress
Let me know if you are having trouble getting it to work. I can provide a script for you.