Discussing Shopify Functions development, deployment, and usage in Shopify apps.
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?
Solved! Go to the solution
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
Hey @anhdd-kuro-159
This should be possible using the amountSpent field.
Scott | Developer Advocate @ Shopify
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
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
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.