Re: Shopify function discount base on customer order history

Solved

Shopify function discount base on customer order history

anhdd-kuro-159
Shopify Partner
14 0 6

Is it possible to create an automatic discount based on a customer's order history using shopify function ?

For example, can we create a 10% discount for customers who have spent a certain amount of money on successful paid orders?

Accepted Solution (1)
SBD_
Shopify Staff
1829 271 415

This is an accepted solution.

Ah, got you! Functions can't read previous customer orders, but they can read customer tags. A potential workaround would be to tag customers who meet your criteria (with a script, manually or maybe Flow could help?), and then the function could look for that tag to apply the discount.

Scott | Developer Advocate @ Shopify 

View solution in original post

Replies 4 (4)

SBD_
Shopify Staff
1829 271 415

Hey @anhdd-kuro-159 

 

This should be possible using the amountSpent field.

Scott | Developer Advocate @ Shopify 

anhdd-kuro-159
Shopify Partner
14 0 6

Thank you for reply !

I apologize for not providing enough information.

It seems that the "amountSpent" field will return the result of the entire order history. Can I retrieve total amount of orders from approximately 6 months ago or something similar?

I want to have additional perks for customers who frequently place orders

 

SBD_
Shopify Staff
1829 271 415

This is an accepted solution.

Ah, got you! Functions can't read previous customer orders, but they can read customer tags. A potential workaround would be to tag customers who meet your criteria (with a script, manually or maybe Flow could help?), and then the function could look for that tag to apply the discount.

Scott | Developer Advocate @ Shopify 

anhdd-kuro-159
Shopify Partner
14 0 6

Thank you! It seems that we are unable to archive it simply at the moment.

As a workaround, I will attempt to combine a web hook (for creating orders) and tagging, despite the possibility of some human mistake when using tags.