Have your say in Community Polls: What was/is your greatest motivation to start your own business?

Can you change hardcoded values in scripts through the Shopify admin dashboard?

Can you change hardcoded values in scripts through the Shopify admin dashboard?

mfs-mindsize
Excursionist
20 0 7

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? 

 

 

Replies 5 (5)

Mircea_Piturca
Shopify Partner
1548 44 347

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

Finally—Add variant descriptions to your products
mfs-mindsize
Excursionist
20 0 7

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. 

Mircea_Piturca
Shopify Partner
1548 44 347

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.

Finally—Add variant descriptions to your products
mfs-mindsize
Excursionist
20 0 7

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

comunicado_fuel
Tourist
4 0 2

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.