Development practices for Shopify Functions
This guide describes specific development practices and limitations you should be aware of when creating Shopify Fuctions.
LocalizationAnchor link to section titled "Localization"
Shopify provides the current locale in the input of the function as a string code. When the content is returned to be displayed to the buyer, your function should return content translated into the language indicated by the locale.
When selling to multiple markets, you need to be aware of the currency displayed to the customer at checkout. You can use the function input's
presentment_currency_rate property for the conversion rate between the store currency and the currency displayed to the customer. You must multiply the discounted amount by the
presentment_currency_rate when offering value discounts.
For example, to configure money values for a function, you must use a numeric metafield and populate the metafield with shop currency values. When your function executes, it must multiply the values by the
The following example shows how to apply the
presentment_currency_rate on a value discount:
LimitationsAnchor link to section titled "Limitations"
The following limitations apply to all functions:
- Shopify doesn't allow nondeterminism in functions, which means that you can't use any randomizing or clock functionality in your functions.
- The compiled function can't exceed 256 kB in size.
- You can't debug your function by printing out
STDOUT, which is reserved for function output. Use
- The logic of the function must execute within 5 milliseconds (ms).
- At runtime, a function can't exceed the following memory limits:
- Linear memory limit: 10 MB
- Stack memory limit: 512 kB