Personalized checkout and custom promotions with Shopify Scripts
Currently, we have a hardcoded value in a script. For example, order total must be $50 or more for ____ to happen. The 5000 is hardcoded. We'd like the be able to have a setting somewhere in the Shopify admin dashboard - that the client can access - so the $50 can be changed to something else without having to modify the actual script.
Is this possible? I've looked for examples and can't find anything.
Are there any other ways in Shopify to define business rules and enforce them? And allow some shop owner flexibility?
If you are referring to Shopify Scripts https://help.shopify.com/en/manual/apps/apps-by-shopify/script-editor, then no.
Scripts have a limited input for good reasons. Security would be one
At Mircea - Thanks.
fwiw, this isn't really a sec issue. Certainly, the "receiving" script could and should do some validation. That is, if I'm expecting an INT between X and Y, I can test for that, yes; as all good functions/methods do 🙂
The alternative to that is to have to manually edit the script every time there needs to be a change. Which we'd all agree also involves risk 🙂
Scripts are helpful. But without the ability to pass in simple basic args, they feel overly-limited and thus compromise their usefulness.
You can pass data to Scripts as cart line items properties. You could pass a string in there...
As this happens on frontend, anyone can pass or alter that data. Not safe to use.
I also feel that there should be a broader I/O on Scripts. Some data from settings schema would be nice to have there.
Thanks again.
Yeah, we just need to pass in some simple settings.
p.s. If you have examples (read: links) on how to pass from the frontend, please share. tua
Yes, it is possible to have a setting in the Shopify admin dashboard that allows the client to change the minimum order total required for a particular action without modifying the script. One way to achieve this is by creating a custom settings page in the Shopify admin dashboard using the Shopify API. This custom settings page can be designed to allow the client to adjust the required minimum order total. Another way is to use the Shopify App Store and look for existing apps that provide this functionality.
As for other ways to define business rules and enforce them, Shopify offers a number of built-in features and APIs that can be leveraged. For example, Shopify's discount and coupon system can be used to create specific discounts or offers based on certain criteria such as order total or product type. Additionally, Shopify's web-hook API can be used to trigger events or execute custom scripts based on certain conditions, providing a lot of flexibility for enforcing business rules.
Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025Expand into selling wholesale with Shopify Academy’s learning path, B2B on Shopify: Lau...
By Shopify Jan 28, 2025