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.
|11-16-2019 10:59 AM|
|11-11-2019 03:11 AM|
|11-11-2019 03:10 AM|
|11-11-2019 03:08 AM|