Shopify Functions has been introduced in Shopify’s 2022 edition for developer’s update. Before this update, it was quite hard for the developers to modify the already working methods as per the demanding requirements of the clients. But this update allows them to customize the backend logic that powers parts of Shopify. The place where Shopify will allow the developers to extend logic is the discounting logic that lives inside of Checkout. Over time developers will be able to manipulate the backend of many parts of Shopify. Since Functions run inline on Shopify’s global infrastructure, they can meet the demands of the biggest sales events.
How to build Functions
The three key building blocks for Shopify Functions include:
- Flexible UI—built with App Bridge and React
- Data storage and configuration—use Metafields
- Backend logic—Functions code
Shopify provided the WebAssembly platform to execute and to assure to working of the Shopify functions.
How Shopify Functions work
Like a typical function, you have to define an input, write some logic of your function, and then write out the output.
- Input: It is a subset of the Cart API and is written as a GraphQL query. Functions can also query metafields so you can store necessary data and retrieve it.
- Function logic: The function logic can be written in any language that compiles to WebAssembly using WASI for
- Output: The function output is a payload that conforms to a GraphQL schema relevant to the specific domain. You can learn more about specific schemas in the Functions API reference.
Functions that are available and can be available in future
- Discount APIs—available now
- To customize the order discount, product discount, and shipping discount APIs
- To give some ideas, brands have long been interested in volume discounts based on the number of items purchased, as well as free gift with purchase offers when a specific dollar threshold is reached
- Shipping API—coming soon
- Payment Methods API—coming soon