Shopify discount function dynamic products #546
Replies: 1 comment 4 replies
-
Love the idea! I'm assuming you have a privacy-suitable way to collect buyer information and send it to your backend to generate the recommendations, and treating that as entirely out of scope for this discussion. If I were building this, I'd use a theme extension and/or checkout UI extension to gather the buyer/product/whatever data, call my backend service with those data to get the recommendation, and store the recommended discount as cart attributes. I'd have a Product Discount Function that reads the cart attribute(s) and generates the corresponding discounts. In order to ensure that a malicious buyer can't abuse my Function, I'd have my server generate a signature (HMAC) that I can validate in the Function. Note that validating the signature in the Function code may consume a lot of the instruction count allowed by Shopify Functions, so I'd implement this in a language that is very energy efficient, like Rust, rather than javascript. |
Beta Was this translation helpful? Give feedback.
-
I'm writing an app that suggests users can buy a few more products and get a discount (bundle).
For example: When a user visits product A, I will have algorithms to recommend the trio of products B - C - D with a 10% discount. These 3 products B - C - D are not fixed and will follow the recomendation logic depending on each person, product,...
How can I implement discount function for this case?
Beta Was this translation helpful? Give feedback.
All reactions