Add a custom bundle
This guide shows you how to add a custom bundle using Shopify Functions.
What you'll learnAnchor link to section titled "What you'll learn"
In this tutorial, you'll learn how to do the following tasks:
- Use GraphQL to define the input of your function.
- Build a
RequirementsAnchor link to section titled "Requirements"
- You've created a Partner account.
- You've created a development store.
- You've created an app that uses Shopify CLI 3.0 or higher, or you've migrated your existing app so that it's compatible with Shopify CLI 3.0 or higher.
- You've installed your app on the development store.
Rust-specific requirementsAnchor link to section titled "Rust-specific requirements"
The following requirements are specific to Rust-based development with Shopify Functions.
You've installed Rust.
On Windows, Rust requires the Microsoft C++ Build Tools. Make sure to select the Desktop development with C++ workload when installing the tools.
You've installed cargo-wasi:
Step 1: Define the input of your functionAnchor link to section titled "Step 1: Define the input of your function"
The following example shows how to use the
cartTransform mutation to group specific line items from the cart together into a bundled line. The lines might be repriced to offer customers an incentive to purchase a complete bundle.
Step 2: Build a Anchor link to section titled "Step 2: Build a cart_transform function"
The process to build a
cart_transform function is similar to the process to create a discount function, with two key differences:
- You need to skip the discount React library and related discount React UI code.
You need to create a
cart_transformfunction instead of a
In the following example, a metafield reference is used to assign mappings between the bundle parent and components:
- Learn how to build a user interface for bundles in the Shopify admin.
- Learn how to use variables in your input query.