The world of ecommerce presents an almost endless supply of technology challenges to solve. At Shopify, we know we'll never be able to tackle all of them on our own. We need the help of developers like you to come up with new and innovative ways to help merchants thrive—all while forging your own path to success. That’s why we built Shopify Functions, a revolutionary new way to extend and replace backend Shopify logic with custom code to meet the business needs of any brand on Shopify.
Introducing Shopify Functions
We thought long and hard about how we could offer more flexibility on Shopify while still providing a lightning-fast experience that can scale. Even though our frontend was already extensible with Liquid and Hydrogen, and the database layer was accessible through APIs and metafields, Shopify’s backend application logic has historically been locked down.
Not anymore.
With Shopify Functions we’ve created a radical new way to build unique commerce experiences by allowing developers to inject custom code into Shopify’s backend logic. Since Functions run inline on Shopify’s global infrastructure, they can meet the demands of the biggest sales events on the planet, while still executing in under 5ms. With Functions, you can have it all: the flexibility of open source platforms, without the hassle of managing hosting, security, and forked code.
Powerful Functions capabilities available to all Shopify merchants
After powering ecommerce businesses for over 16 years, we know how critical it is to differentiate from the competition with unique discounts, promotions, and buying experiences. In fact, we know that brands on Shopify Plus see a 20% increase to their average order value when they use Shopify Scripts discount, shipping, and payment method customizations. We also know that the more successful the brand is, the more likely they are to rely on Scripts for custom functionality.However, Scripts did have some challenges. Namely, Scripts are exclusive to Shopify Plus, meaning it was only available to our largest merchants. Additionally, Scripts required end users to be fluent in Ruby code to both create and modify discount, shipping, or payment gateway customizations. Looking to the future, we built Functions with these challenges in mind.
First and foremost, Functions are available to all merchants on Shopify, not just Plus. Secondly, Functions are installed with an app and can be sold in the Shopify App Store. This means that as of today, you can start building discount apps with Functions and sell them to millions of merchants on Shopify, a completely untapped market.
But that’s just the tip of the iceberg. In addition to dramatically increasing the total addressable market for backend customizations, we’ve also made them so much easier to use. With Functions, ecommerce managers and marketers never have to write (or even see) code. Instead, Functions are installed like any other app and then configured directly in the Admin alongside out-of-the-box Shopify features. Meaning, discount Functions will be visible under the discount settings, shipping Functions under shipping, and so on.
Taking this model a step further, let’s look at a discount example. With Discount Combinations, merchants can create unique promotions by combining a custom bulk discount—built with Functions—and Shopify’s out-of-the-box free shipping discount. The ability to mix and match custom discounts and native discounts is exclusive to Functions, giving it a huge advantage over current discount apps in the App Store.
The power of Functions doesn’t stop there; any discount built with Functions will be accessible in Shopify Analytics sales reporting. So merchants will finally have a single source of truth when reviewing their discount strategies. This capability is a big deal for merchants as it streamlines reporting and makes it faster and easier to see if their recent promotions were successful or not. It’s important to note that this attribute is also unique to Functions, and is not available to discount apps that are built with draft orders.
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
To ensure that Functions provide a lightning fast and reliable experience, we built a brand new WebAssembly platform for them to run on. Meaning, Functions is up to any critical task—stores going viral, internet-breaking flash sales—you name it, Functions can handle it.
Discount Functions available now and Payment and Shipping coming soon
We’ve already talked about discounts, which Functions allows you to configure directly in the Shopify admin, so merchants never need to touch a line of code.
Here are the other domains that Shopify Functions supports or will support in the near future:
- Discount APIs—product and order discount APIs available now
- More specifically, you can customize the order discount, product discount, and shipping discount APIs
- To give you a couple of popular 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 Customization API—coming soon
- Hide, reorder, or create new shipping options
- For example, in the case of an eco-friendly brand, bike shipping or local pickup could be displayed as the primary shipping options for any buyer within a specific zip or postal code radius.
- Payment Customization API—coming soon
- Hide or reorder payment options
- One of the most popular instances of a payment method customization is setting a specific dollar threshold to determine when a cash-on-hand payment option is available in the checkout
We’re starting out with familiar customization areas, but our plan is to offer significantly more Functions options in the future. For example, we’re already investigating how we could add support for order routing, checkout and cart validations, return validations, and shipping rates, just to name a few.
Start to explore everything you can do with Functions
As you can see, we’ve been laser focused on providing a radical new way to build fast, scalable, and unique commerce experiences. With Functions, you now have the power to extend Shopify and build capabilities that we’ve never dreamt about. Keep in mind that this is just the start of the journey, and be on the lookout as we make more of Shopify’s backend logic extensible with Functions.
If you’re eager to start building your first Shopify Function, you can learn more in our developer documentation, or jump right in and write your first product or order Discount Function by following along with our tutorial. We can’t wait to see what you’ll build.
Read more
- Building the World’s Best Commerce Apps with Built for Shopify
- How to Build a Shopify App: The Complete Guide
- Build with Hydrogen: Developer Preview Now Available
- Introducing Online Store 2.0: What it Means For Developers
- How the Routes and Page_Image Liquid Objects Can Help You Build More Robust Themes
- Everything You Need to Know About Development Stores
- Commerce+ 2021: A Recap of What’s Next in Commerce
- Announcing Unite: Shopify's Partner and Developer Conference