Have you heard about Shopify Functions – a new era that helps to extend and customize Shopify backend logic freely?

Back in 2016, Shopify launched Shopify Scripts for the first time. Scripts assist brands in creating the micro-customizations they require to increase checkout conversions. Nevertheless, it has some limitations. Specifically, Scripts were exclusively accessible to large businesses that use the Shopify Plus plan. Additionally, to develop and alter customizations for discounts, shipping, or payment gateways in Scripts, users had to be proficient in Ruby coding.

Luckily, we now have a better alternative, Shopify Functions, without these difficulties in mind. It’s a ground-breaking new technique for extending and swapping backend Shopify logic with custom code to satisfy any business requirements.

Without any further, let’s dive into Shopify Functions now!

What is Shopify Functions App?

Shopify Functions allow developers to alter the backend logic that drives various platform aspects.

With the help of Shopify Functions, all Shopify companies may now extend and adjust existing Shopify functionalities to suit their business requirements. Developers may create robust customizations with Functions that operate in less than 5ms and scale for the world’s most significant sales events.

For example, the discounted logic found inside Checkout is the first location where Shopify will let you extend. You will eventually be able to control the Shopify backend for many components.

shopify-functions

Moreover, Shopify Functions can be configured directly in the admin without touching a line of code because they are installed with an app. Even though Functions initially just has the well-known backend changes for discounts, shipping, and payment methods, Shopify will soon add support for shipping rates, checkout and cart validations, return validations, and order routing.

You can have the flexibility of open-source platforms with Functions without dealing with the burden of managing hosting, security, and forked code.

How Shopify Functions work?

For developers

Using Shopify Functions, developers can add custom code to or replace significant portions of the backend logic of the platform. With no need for hosting, security, or management of forked code, this innovative Functions architecture offers open-source flexibility.

Additionally, because Shopify infrastructure hosts functions, they will always be up to date and capable of handling any crucial duties, even during record-breaking flash sales.

There are three steps to writing your function’s logic, including

  • Input: The GraphQL query for the function input is a subset of the Cart API. Metafields can also be queried by Shopify Functions, allowing you to store and get the data you need.
  • Function logic: Any language that generates WebAssembly with WASI for STDIN and STDOUT may be used to write the function logic. This strategy guarantees minimal latency for both customers and merchants.
  • Output: A payload that complies with a GraphQL schema pertinent to the given domain serves as the function’s output. You can get more information about specific schemas in the Functions API reference.

For developers, you can create a Function in any language that generates WebAssembly, and then use AppBridge and React to create a user interface. Developers can create a Function in their local environment and deploy it using the Shopify CLI. The Function is distributed in an app after it is finished. Thus, copying and pasting code from one store to another is no longer necessary.

For merchants

To configure the Shopify Function from the Shopify Admin dashboard, merchants only need to install an app. This implies that you can see discounts, shipping, and payment method Functions in addition to the default Shopify settings.

More specifically, an illustration of a function’s lifespan is shown below:

  • The data model of Shopify is connected to a function that app developers construct, configure, and deploy.
  • To enable the capability, retailers install the app on their websites.
  • Shopify responds to customer interactions by locating and carrying out the function.

shopify-functions

Source: Shopify

Benefits Of Leveraging Shopify Functions

Shopify is one of the best eCommerce platforms these days, yet every store can use the default features and setup. If you want to be seen among the crowd, you need customizations. Ideally, Shopify Functions makes these actions most effortless than ever. Proof that brands that use Shopify Functions enjoy a 20% increase in average order value.

Ease of Use

shopify-functions

Thanks to Shopify Functions, you may now update your promotions without worrying about changing the code. Instead, Functions are deployed similarly to other apps and are immediately configured alongside built-in Shopify features in the Admin dashboard.

Instead of generating discounts separately for a product, order, and shipping, you can combine all-in-one with customized discounts developed with Functions to produce effective promotions. For instance, you may combine the built-in free shipping discount in the discount settings with a custom spend $X receive $Y volume discount installed via an app.

It also provides sales reporting, including the Sales by the Discount report, which will display any discount created with Shopify Functions. In other words, you’ll be able to check all your deals using a single, accurate source of information.

This feature is essential to merchants since it simplifies reporting and makes it quicker and simpler to determine whether or not recent promotions were successful. Notably, this characteristic is exclusive to Functions and is not offered by discount apps created using draft orders.

More Accessible

First and foremost, all Shopify merchants, not just Shopify Plus, have access to Functions. You can buy it on the Shopify App Store and install it via an app. As a result, you can now begin developing discount apps with Functions and promote them to millions of retailers on Shopify, an utterly new market.

Second, Shopify Functions has the added benefit of being packaged into apps, which you can purchase from the Shopify App Store. Therefore, you may still obtain the unique Shopify customization your business needs, even if you don’t deal with a development team or agency.

Shopify has dramatically expanded the total addressable market for backend customizations and made them a lot simpler to use. Ecommerce managers and marketers never have to write (or even view) code again, thanks to Functions. Instead, you can set up it alongside standard Shopify capabilities in the Admin after installing it like any other app. Specifically, you can find shipping functions under shipping settings and discount functions under discount settings.

Exclusive Features for Shopify Plus

shopify-functions

Last but not least, only Shopify Plus brands have access to the option to create custom apps that deliver Shopify Functions to their stores. So, Shopify Plus businesses may quickly develop the functionality they require if a particular discount, shipping, or payment isn’t yet accessible in the Shopify App Store or if it’s too specialized or complex for the general public.

A Shopify Plus business could create its unique function. If you want to run campaigns: Spending $300 – get $50 off on one store, and $500 – get $100 off on another. The furniture store can manage the information available for product discounts by creating its Function; in this case, metatags will still contain the brand name information.

Moreover, Shopify announced that they would continue to update Shopify Functions with more appealing features. Thus, more of Shopify’s built-in logic will eventually be extendable via Functions.

What Do Shopify Functions Support?

Discount APIs (Order, Product)

As said above, Shopify Functions provides a discounts API, which enables you to set up directly in the Shopify admin without needing any code modification on the merchant’s part.

Specifically, you can modify the order discount and product discount APIs in more detail. Suppose to name a few well-liked examples, customers have always been interested in volume discounts depending on the number of things purchased, and gifts with purchase offers when a specific dollar barrier is achieved.

Shopify Functions support the following domains:

  • Using the Order Discount API, you can construct a brand-new kind of discount applied to all items in the cart.
  • On the other hand, using the Product Discount API, you can construct a brand-new kind of discount applied to a specific product or product variant in the cart.

WebAssembly API

We have discussed how developers can use WebAssembly to create a Function. Moreover, you can translate any language, including Rust, Zig, or TinyGo, into WebAssembly (Wasm) and use it to write your function.

Of course, some requirements here are:

  • Conform with the command module structure.
  • Write the output as a byte stream with JSON encoding to a default output file descriptor.
  • Read data from a common input file descriptor as a JSON-encoded byte stream.
  • You must write debug logs to a standard error file as a newline-delimited utf-8 file.

Below is an example of a Function that complies with WebAssembly API

WebAssembly-API

Source: Shopify

Shopify Shipping API

You can develop a brand-new kind of discount that is applied to one or more shipping rates at checkout using the shipping discount API. Covering up, changing your order, or adding new shipping options are all benefits of Shopify Functions.

For instance, bike shipping or local pickup may be highlighted as the top shipping choices for customers within a particular zip or postal code for an eco-friendly brand.

Furthermore, providing multiple shipping options can also decrease shopping cart abandonment. In a Metapack poll, 50% of respondents acknowledged removing items from their online shopping carts because the available shipping options did not satisfy their demands. You probably have an idea of what happened next. Up to 60% of these customers decided to purchase from a different merchant that provides shipping that met their requirements.

Thus, with this Shipping API, you can easily customize options that meet your strategy and customer requirements.

Shopify Functions Error Handling

When a function fails, it may throw an error, go over its allotted memory or time or return data that doesn’t follow the rules of the particular Function API.

In this situation, Shopify will auto detect and notify merchants. In the Shopify admin’s customization page, a banner appears when you use a function and an issue occurs. Information about the onset of mistakes is provided in the banner. It also has a URL that retailers can use to tell developers about unsuccessful function runs.

shopify-functions

Source: Shopify

After receiving error alerts, merchants can share with developer error reports. Next, app developers use their Partner Dashboard to monitor various features.

shopify-functions

Source: Shopify

Payment Methods API

Shopify Functions will quickly add the Payment Methods API to the feature list. You can also expect it to support the following:

  • Rearrange or cover up payment choices.
  • Setting a particular dollar threshold to determine when using the cash-on-hand payment option at the checkout. It is one of the most well-liked examples of payment method customization.

It would be better if you provided multi-payment options to ensure that as many potential clients can access your store as possible.

According to statistics, 6% of customers will abandon the cart if they can’t pay for their purchases in the method they like. If they cannot make a payment in their preferred manner, many customers will leave a purchase. Providing various payment options can ease the checkout process and motivate customers to finish their transactions.

As a result, keeping up with new and preferred payment methods is crucial if you want to lower cart abandonment and ensure your online store serves as many people as possible.

Take Your Shopify Backend Logic To The Next Level

You have several technical problems to solve even with the best eCommerce platform worldwide. Thus, BSS Shopify Commerce has Shopify Functions here to handle everything together. As you carve out your road to success, Shopify needs developers to help you think of fresh, creative ways to support merchants.

As developers, you will have the freedom and flexibility to create things with Shopify Functions, and this is just the beginning. Remember that Shopify’s goal has been to offer a new method for developing quick, scalable, and distinctive commerce experiences.