Use Rust to create a Shopify Discount Function

Before you begin

For the first time ever Shopify is unlocking the ability to customize its business logic, opening the door to huge opportunities for app developers. This workshop will cover how to create a new Functions based discount using Rust. (No previous Rust experience is required as code is provided. Though this workshop will not be covering the basics of the language.) We will start by writing the Function locally, then create a corresponding UI, deploy the function to Shopify, and finally test the discount on a development store.

By the end of this workshop, attendees will have built a Shopify Function that applies a volume discount at checkout, which they can then use as a basis for their own app. The app we're building will have an accompanying UI that allows a merchant to create a volume discount (buy more of a product, get a bigger discount) and a Shopify Function, written in Rust, that applies the discount at checkout.

An image showing a discount type that was created by a Shopify function.

Learning objectives

After you've finished this tutorial, you'll have accomplished the following:

  • Used the discount React library to build a discount form page
  • Created a new page in your app where merchants can create a discount
  • Generated a new product discount extension with boilerplate code
  • Modified the Shopify Function code to generate the discounts at checkout
  • Configured your extension
  • Tested the new discount in your development store

What you'll need (Account Requirements)

What you'll need (Libraries and Tools)