Author
Endertech Team Logo
Endertech Team
Published
7/11/2022
Categories
E-Commerce

Shopify Functions: A Better Way To Customize Shopify

Shopify Functions Explained.

Ecommerce is evolving rapidly, and Shopify is evolving with it. In 2021, Shopify launched Online Store 2.0 — a slew of updates to improve Shopify’s theme architecture, content customization, and developer tooling.

In 2022, in its first-ever Shopify Editions showcase, Shopify launched Functions — a new way to extend and customize Shopify’s core functionality with custom code.

In this guide, we’ll explore Shopify Functions to help you understand what it is, how it works, its benefits, and how it’s different from the existing ways to customize Shopify.

Ready to learn? Let’s get straight to it.

An Introduction to Shopify Functions

Shopify Functions is a feature that allows developers to extend Shopify’s server-side business logic using custom code. With Functions, developers can introduce micro-customizations without worrying about hosting, securing, and maintaining code.

Traditional ecommerce architectures generally consist of three parts: the frontend, backend, and database. The frontend defines the store’s appearance, the backend defines its functionality, and the database stores all the business data.

Until now, Shopify allowed you to customize the frontend of your store using Liquid and Hydrogen and access the database using APIs and Metafields. However, the backend was off-limits. This restriction made it difficult for developers to customize Shopify functionality.

Now, developers can extend and replace critical parts of Shopify’s backend code without needing to fork, host, or maintain the code. That means you enjoy the flexibility of using an open-source platform without any overheads.

More importantly, developers can write, configure, and deploy Functions using the Shopify CLI and distribute them as apps on the App Store.Merchants don’t need to interact with code to use the Functions inside of Shopify. They only need to install an app, and the Functions will be visible in the admin alongside Shopify’s default ecommerce features.

Although these Functions are available to all users, only Shopify Plus users can create and use custom apps with it. Non-Plus users can only access Functions through apps available on the App Store.

The Lifecycle of Shopify Functions Explained

Developers create Shopify Functions by defining the following three components:

  1. Input: A GraphQL query based on Shopify’s Cart API that can store and retrieve data by querying metafields.

  2. Function logic: Code written in languages such as C/C++ and Rust that compile to WebAssembly that extends Shopify’s default functionality.

  3. Output: GraphQL schema-based data that specifies the operations to be executed by Shopify.

After creating Functions, developers can use App Bridge and React to create a user interface that allows merchants to manage and customize them inside the Shopify admin. Finally, they deploy the function to an app that Shopify merchants can install from the App Store.

When merchants install the apps, the Functions deploy on the ShopifyVM platform and attach to a data model. When customers interact with the store on the frontend, Shopify finds and executes the function using the logic described in its code.

The Benefits of Shopify Functions

Here are three ways in which Shopify Functions benefit developers and merchants.

Easier Customizations

The biggest benefit is that you can extend and replace Shopify’s server-side logic using apps. If you’re a Shopify developer, you can build Functions-based apps and share them with millions of Shopify merchants via the App Store.

And if you’re a Shopify merchant, you can install apps to extend your store without needing a dedicated development team or Shopify agency. You can customize your Shopify store without touching code.

Seamless user experience

Another advantage of using Functions is that, unlike traditional Shopify apps, Functions work alongside native Shopify functionality.

For instance, when merchants install discount apps built with Functions, they’ll be able to create complex conditions and combine custom discounts with Shopify’s default ones.

And that’s not all. Any discounts created using Shopify Functions will also show up in their Analytics dashboard for a consistent user experience.

Hassle-free Experience

Functions are incredibly scalable as they’re built and deployed on Shopify’s global infrastructure. That allows Functions to execute in less than 5ms no matter the size of the sale event or traffic to a store.

Moreover, it also ensures that you don’t need to worry about optimizing or securing Functions. It’s maintained and upgraded by Shopify so you can focus on growing your online business.

Shopify Scripts vs Functions

Shopify introduced Scripts in 2016 to allow merchants to customize Shopify’s checkout. More recently, in 2021, Shopify launched a new version called Scripts V2 that improved its development, reliability, and execution using WebAssembly.

Despite the recent upgrade, Scripts had some challenges. The biggest one was that Scripts were only available to Shopify Plus users. That meant, only a tiny subset of Shopify users could access Scripts for customizations.

Moreover, Scripts were written with a Ruby API. Thus, end-users needed fluency with Ruby code to create and modify customizations built using Scripts.

Shopify Functions addresses these limitations and provides a better way to customize key parts of Shopify. Developers can write Functions using any language that compiles to WebAssembly and use metafields to allow merchants to customize the Function’s behavior.

But what makes them superior to Scripts is that Functions is over 100x faster than Scripts. Viral moments or Black Friday sales — these functions can handle everything.

Shopify Functions: A New Way To Extend Shopify Functionality

Shopify Functions helps you extend Shopify’s backend logic and build unique shopping experiences. It integrates seamlessly into the Shopify admin, so you don’t need to worry about dealing with complex code.

What we love about this is that it brings open source-like customization to Shopify. You can continue enjoying Shopify’s code-free UI without worrying about the technicalities of hosting, securing, or maintaining code.

They only allow you to extend discounts inside Checkout for now but support for shipping and payments is set to roll out soon. Shopify also plans to add support for other features such as shipping rates, cart validations, and programmable order routing in the future. Until then, you can continue using apps to custom functionality to your store.

Need help with building a custom app for your Shopify store? Contact us for a free consultation today.