At Shopify, we know how important the checkout is when it comes to converting customers. It needs to be lightning fast and secure, while still providing the flexibility to build unique promotions that convert customers.
That’s where Shopify Functions come into play. With Functions, you can customize Shopify’s backend logic to build everything from checkout validation rules to product bundles that display right in the checkout. Best of all, Functions are deployed via apps and can be distributed through the Shopify App Store. In this article, we dive into some of the recent enhancements that we’ve made to Shopify Functions, announced at the Shopify Winter ’23 Edition.
Catch up on the latest developer announcements from the Shopify Winter ’23 Edition
The Shopify Winter ’23 Edition was full of big announcements for developers who work with Shopify. Visit our roundup on the Shopify Partner Blog to get caught up on all the news.Read article
What are Shopify Functions?
The Function itself is a WebAssembly module that contains custom business logic, such as a product bundle (see below). Functions can be written in any language that supports WebAssembly.
To make it even easier to build Functions in Rust, we recently published a new Rust library that drastically reduces the amount of boilerplate code that you need to write, allowing you to focus on writing Functions business logic instead of worrying about API implementation.
Beyond product bundles, you can also use Functions to create specific discounting logic, like volume or tiered discounts, as well as build your own custom delivery and payment rules to hide, reorder, or present new options within the checkout. We’ve even created a collection in the Shopify App Store to highlight discount apps that are powered by Functions.
New Shopify Functions APIs
At the Shopify Winter ’23 Edition, we announced developer previews for three new Functions APIs: Product Bundles, Cart and Checkout Validations, and Order Routing. These new APIs enable developers to solve many more unique commerce use cases. Let’s dive into each new Function API to understand what it does and what merchant use case it can help solve.
1. Cart Transform API (Developer preview)
With the Cart Transform Function API, developers can give merchants the ability to create unique bundle offerings. There are two key parts to this. First, the Cart Transform Function allows brands to configure which specific products can be merged into a bundle. These items are then displayed as a new bundle price within the checkout when the correct individual products are combined.
In addition, the Cart Transform Function can also expand a bundle product into its individual components, making it easier to complete tasks on the backend—like calculating taxes, shipping weights, decrement inventory, and more—as well as ensuring each individual item is fulfilled appropriately after a purchase.
To learn more about the Cart Transform API, visit our developer documentation.
2. Cart and Checkout Validation API (Developer preview)
The Cart and Checkout Validation API ensures customers can only complete a purchase and checkout if their orders comply with a specific set of rules, determined by the merchant. Some of the most common use cases for cart and checkout validation include:
- Ensuring the customer meets the minimum or maximum quantity requirements to check out. For example, during a hyped sneaker drop, a brand could set a rule that only allowed customers to buy one pair of shoes to minimize reselling.
- Checking that the shipping address can be shipped to and is not a PO box.
- Making sure the cart doesn’t contain items that can’t be purchased together, such as a lighter and lithium batteries.
The Cart and Checkout Validation API also work together with our recently announced Gates API to power tokengated commerce experiences. Practically speaking, this means that buyers would need to present the correct token to unlock exclusive collections, to receive special discounts, or to check out.
Learn more about the Cart and Checkout Validation API in the docs.
3. Order Routing API (Developer preview)
There are many variables to consider when determining how to best fulfill and ship orders. For example, does a brand have a warehouse that needs to prepare certain items, or is it better to ship items from the closest location no matter the circumstance? With the Order Routing API, developers can help brands create the order routing logic that best aligns with their businesses.
For example, brands could set a topline rule to avoid split-fulfillments, along with a secondary rule to send items from the closest location to the shipping address. This logic means that before completing a shipment, Shopify would determine what fulfillment location had everything in stock and then pick the closest warehouse to the customer.
This example is just the tip of the iceberg—developers can create a number of new rules depending on the complexity of the merchant. For example, keeping orders within the country, balancing inventory levels to prioritize locations with more items in stock, or shipping directly from stores, just to name a few.
Please note that the Order Routing API is currently in developer preview and does not contain a merchant configuration UI. As a result, developers can only test their order routing options within their code.
Learn more about the Order Routing API in our docs.
4. Delivery and Payment Customization APIs
With so many unique businesses, markets, and buyer norms, it’s nearly impossible to create delivery and payment options that meet the needs of all the merchants on Shopify. That’s why we’ve released the delivery customization and payment customization Functions. With these Functions APIs, you can hide, reorder, or offer custom delivery and payment options that display right in the checkout.
For example, one of the most popular delivery customizations include the ability to surface unique shipping options to specific buyers. We’ve seen brands offer special shipping options, like bike shipping, that only display to customers that live within a certain local area based on ZIP or postal codes. Merchants can also use these new Functions to offer shipping rates that are only available to customers within their country.
With regards to payment customizations, one of the most popular use cases is to hide certain payment options based on a dollar threshold. Practically speaking, a merchant may want to offer cash-on-delivery as a payment option, but only up to a specific dollar amount.
Dig deeper into the developer products announced at Shopify Editions
Join our upcoming Shopify Editions-focused AMA sessions on our Discord channel. Learn from industry experts, including Shopify CEO Tobi Lütke, ask questions, and connect with other like-minded individuals.
You can RSVP to whichever AMA sessions interest you on our Discord channel in the ‘Events’ category at the top left of the channel list. Join our Discord channel at the link below.Join now
Start building with Shopify Functions
We’re committed to making Shopify more extensible. With Shopify Functions, you can now build custom discounts, delivery and payment options, order routing logic, checkout validation rules, and product bundles. And this is just the beginning. We plan on rapidly adding new surface areas that can be customized with Functions over the coming year to give you the building blocks you need to create incredible apps.
If you’re eager to start testing out the new Shopify Functions APIs, be sure to head over to our developer documentation to learn more.