Development practices for Shopify Functions
This guide describes specific development practices and limitations you should be aware of when creating Shopify Functions.
Localization
Anchor 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. Function input queries provide monetary values in the customer's displayed currency. Likewise, monetary values output from functions must be in the customer's currency.
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 any merchant-configured amounts by the presentment_currency_rate
when comparing monetary values with the cart, or when outputting value discounts.
For example, if your app allows merchants to configure a fixed amount for a discount function, then you can use a numeric metafield and populate the metafield with the value in the store currency. When your function executes, it must multiply the configured value by the presentment_currency_rate
input to compare the configured subtotal to the customer's cart subtotal in the customer's display currency.
The following example shows how to apply the presentment_currency_rate
on a value discount:
Deleting functions
Anchor link to section titled "Deleting functions"To delete a Shopify Function, you need to remove the relevant files from your app's /extensions
directory, and then redeploy your app. Learn more about removing a Shopify Function.
When you delete a function, the following behavior occurs:
- The function, including all associated function owners, is permanently deleted.
- The function no longer runs, and becomes inaccessible to any Shopify stores that have your app installed.