Skip to main content

Fulfillment Constraints Function API

Fulfillment constraints refer to limitations or conditions that you apply when fulfilling orders. You can either specify a list of locations where cart items can be fulfilled from, or specify that cart items must be fulfilled from the same location. If the cart items with fulfillment constraints applied aren't available at the same location or any of the listed locations, then buyers won't see any shipping options at checkout. Instead, a message will show which items are out of stock, preventing the buyer from completing the purchase. To configure constraints for fulfilling orders, you can only use the Fulfillment Constraints Function API.

Shopify Functions enable you to customize Shopify's backend logic. The Fulfillment Constraints API integrates this logic into the checkout flow.

Use the API to customize fulfillment and delivery strategies for specific cart items, with associated data such as buyer identity, metafields, and location addresses.

Note

You can activate a maximum of 25 fulfillment constraint functions on each store.

  • Fulfill specific items in a cart from the same location.
  • Fulfill specific items in a cart from any of the locations in a list.

Function target

Simple targetRun targetcart.fulfillment-constraints.generate.runInputrun functionCartFulfillmentConstraintsGenerateRunResultShopify injects

Checkout

Function Target
Compatibility with Shopify surfaces
Supported (9)
Partially supported (3)
Unsupported (2)

Scaffolding the function using Shopify CLI will automatically configure your TOML file. You can alter the default configuration to customize the way your function operates.

Terminal

shopify app generate extension --template fulfillment_constraints

A target is an identifier in shopify.extension.toml that specifies where you're injecting code into Shopify Function APIs, or other parts of the Shopify platform. Each target is composed of three to four namespaces. The name begins with a broad Shopify context and ends with the behavior of the extensible element.


cart.fulfillment-constraints.generate.run

The run target indicates which locations are used to fulfill specific items in a cart, either using Shopify data or hardcoded values. The target returns a list of operations that apply fulfillment constraints.

For example, you might use this to fulfill specific items in a cart from any of the locations in a list.

OBJECT

The Input object is the complete GraphQL schema that your function can query as input to customize fulfillment constraints. Your function receives only the fields that you request in the input query. To optimize performance, we highly recommend that you request only the fields that your function requires.

non-null

The cart where the Function is running. A cart contains the merchandise that a customer intends to purchase and information about the customer, such as the customer's email address and phone number.

The custom attributes associated with a cart to store additional information. Cart attributes allow you to collect specific information from customers on the Cart page, such as order notes, gift wrapping requests, or custom product details. Attributes are stored as key-value pairs.

Arguments

The key of the cart attribute to retrieve. For example, "gift_wrapping".


Fields

non-null

The key or name of the attribute. For example, "customer_first_order".

The value of the attribute. For example, "true".

The billing address associated with the cart.

The first line of the address. Typically the street address or PO Box number.

The second line of the address. Typically the number of the apartment, suite, or unit.

The name of the city, district, village, or town.

The name of the customer's company or organization.

The two-letter code for the country of the address. For example, US.

AC, AD, AE, AF, AG, AI, AL, AM, AN, AO, AR, AT, AU, AW, AX, AZ, BA, BB, BD, BE, BF, BG, BH, BI, BJ, BL, BM, BN, BO, BQ, BR, BS, BT, BV, BW, BY, BZ, CA, CC, CD, CF, CG, CH, CI, CK, CL, CM, CN, CO, CR, CU, CV, CW, CX, CY, CZ, DE, DJ, DK, DM, DO, DZ, EC, EE, EG, EH, ER, ES, ET, FI, FJ, FK, FO, FR, GA, GB, GD, GE, GF, GG, GH, GI, GL, GM, GN, GP, GQ, GR, GS, GT, GW, GY, HK, HM, HN, HR, HT, HU, ID, IE, IL, IM, IN, IO, IQ, IR, IS, IT, JE, JM, JO, JP, KE, KG, KH, KI, KM, KN, KP, KR, KW, KY, KZ, LA, LB, LC, LI, LK, LR, LS, LT, LU, LV, LY, MA, MC, MD, ME, MF, MG, MK, ML, MM, MN, MO, MQ, MR, MS, MT, MU, MV, MW, MX, MY, MZ, NA, NC, NE, NF, NG, NI, NL, NO, NP, NR, NU, NZ, OM, PA, PE, PF, PG, PH, PK, PL, PM, PN, PS, PT, PY, QA, RE, RO, RS, RU, RW, SA, SB, SC, SD, SE, SG, SH, SI, SJ, SK, SL, SM, SN, SO, SR, SS, ST, SV, SX, SY, SZ, TA, TC, TD, TF, TG, TH, TJ, TK, TL, TM, TN, TO, TR, TT, TV, TW, TZ, UA, UG, UM, US, UY, UZ, VA, VC, VE, VG, VN, VU, WF, WS, XK, YE, YT, ZA, ZM, ZW, ZZ

The first name of the customer.

The last name of the customer.

The approximate latitude of the address.

The approximate longitude of the address.

The full name of the customer, based on firstName and lastName.

A unique phone number for the customer. Formatted using E.164 standard. For example, +16135551111.

The alphanumeric code for the region. For example, ON.

The zip or postal code of the address.

Deprecated
non-null

A human-readable unique string for the market automatically generated from its title.

non-null

A globally-unique identifier.

A custom field that stores additional information about a Shopify resource, such as products, orders, and many more. Using metafields with Shopify Functions enables you to customize the checkout experience.

Arguments

A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts between different apps or different parts of the same app. If omitted, then the app-reserved namespace is used.

required

The unique identifier for the metafield within its namespace. A metafield is composed of a namespace and a key, in the format namespace.key.


Fields

non-null

The data that's stored in the metafield, using JSON format.

non-null

The type of data that the metafield stores in the value field.

non-null

The data that's stored in the metafield. The data is always stored as a string, regardless of the metafield's type.

non-null

A geographic region which comprises a market.

The name of the region in the language of the current localization.

Information about the customer that's interacting with the cart. It includes details such as the customer's email and phone number, and the total amount of money the customer has spent in the store. This information helps personalize the checkout experience and ensures that accurate pricing and delivery options are displayed to customers.

The customer that's interacting with the cart.

non-null

The total amount that the customer has spent on orders. The amount is converted from the shop's currency to the currency of the cart using a market rate.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
non-null

The full name of the customer, based on the values for firstName and lastName. If firstName and lastName aren't specified, then the value is the customer's email address. If the email address isn't specified, then the value is the customer's phone number.

The customer's email address.

The customer's first name.

non-null

Whether the customer is associated with any of the specified tags. The customer must have at least one tag from the list to return true.

Arguments

requiredDefault:[]

A comma-separated list of searchable keywords that are associated with the customer. For example, "VIP, Gold" returns customers with either the VIP or Gold tag.


non-null

Whether the customer is associated with the specified tags.

Arguments

requiredDefault:[]

A comma-separated list of searchable keywords that are associated with the customer. For example, "VIP, Gold" returns customers with both the VIP and Gold tags.


Fields

non-null

Whether the Shopify resource has the tag.

non-null

A searchable keyword that's associated with a Shopify resource, such as a product or customer. For example, a merchant might apply the sports and summer tags to products that are associated with sportswear for summer.

non-null

A globally-unique ID for the customer.

The customer's last name.

A custom field that stores additional information about a Shopify resource, such as products, orders, and many more. Using metafields with Shopify Functions enables you to customize the checkout experience.

Arguments

A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts between different apps or different parts of the same app. If omitted, then the app-reserved namespace is used.

required

The unique identifier for the metafield within its namespace. A metafield is composed of a namespace and a key, in the format namespace.key.


Fields

non-null

The data that's stored in the metafield, using JSON format.

non-null

The type of data that the metafield stores in the value field.

non-null

The data that's stored in the metafield. The data is always stored as a string, regardless of the metafield's type.

non-null

The total number of orders that the customer has made at the store.

The email address of the customer that's interacting with the cart.

non-null

Whether the customer is authenticated through their customer account.

The phone number of the customer that's interacting with the cart.

The company of a B2B customer that's interacting with the cart. Used to manage and track purchases made by businesses rather than individual customers.

non-null

The company associated to the order or draft order.

non-null

The date and time (ISO 8601 format) at which the company was created in Shopify.

A unique externally-supplied ID for the company.

non-null

The ID of the company.

A custom field that stores additional information about a Shopify resource, such as products, orders, and many more. Using metafields with Shopify Functions enables you to customize the checkout experience.

Arguments

A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts between different apps or different parts of the same app. If omitted, then the app-reserved namespace is used.

required

The unique identifier for the metafield within its namespace. A metafield is composed of a namespace and a key, in the format namespace.key.


Fields

non-null

The data that's stored in the metafield, using JSON format.

non-null

The type of data that the metafield stores in the value field.

non-null

The data that's stored in the metafield. The data is always stored as a string, regardless of the metafield's type.

non-null

The name of the company.

non-null

The date and time (ISO 8601 format) at which the company was last modified.

The company contact associated to the order or draft order.

non-null

The date and time (ISO 8601 format) at which the company contact was created in Shopify.

non-null

The ID of the company.

The company contact's locale (language).

The company contact's job title.

non-null

The date and time (ISO 8601 format) at which the company contact was last modified.

non-null

The company location associated to the order or draft order.

non-null

The date and time (ISO 8601 format) at which the company location was created in Shopify.

A unique externally-supplied ID for the company.

non-null

The ID of the company.

The preferred locale of the company location.

A custom field that stores additional information about a Shopify resource, such as products, orders, and many more. Using metafields with Shopify Functions enables you to customize the checkout experience.

Arguments

A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts between different apps or different parts of the same app. If omitted, then the app-reserved namespace is used.

required

The unique identifier for the metafield within its namespace. A metafield is composed of a namespace and a key, in the format namespace.key.


Fields

non-null

The data that's stored in the metafield, using JSON format.

non-null

The type of data that the metafield stores in the value field.

non-null

The data that's stored in the metafield. The data is always stored as a string, regardless of the metafield's type.

non-null

The name of the company location.

non-null

The number of orders placed at this company location.

non-null

The total amount spent at this company location.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
non-null

The date and time (ISO 8601 format) at which the company location was last modified.

non-null

A breakdown of the costs that the customer will pay at checkout. It includes the total amount, the subtotal before taxes and duties, the tax amount, and duty charges.

non-null

The amount, before taxes and cart-level discounts, for the customer to pay.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
non-null

The total amount for the customer to pay at checkout.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF

The duty charges for a customer to pay at checkout.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF

The total tax amount for the customer to pay at checkout.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
non-null

The items in a cart that are eligible for fulfillment and can be delivered to the customer.

The custom attributes associated with a cart to store additional information. Cart attributes allow you to collect specific information from customers on the Cart page, such as order notes, gift wrapping requests, or custom product details. Attributes are stored as key-value pairs.

Cart line attributes are equivalent to the line_item object in Liquid.

Arguments

The key of the cart attribute to retrieve. For example, "gift_wrapping".


Fields

non-null

The key or name of the attribute. For example, "customer_first_order".

The value of the attribute. For example, "true".

non-null

The ID of the cart line.

non-null

The item that the customer intends to purchase.

OBJECT

A custom product represents a product that doesn't map to Shopify's standard product categories. For example, you can use a custom product to manage gift cards, shipping requirements, localized product information, or weight measurements and conversions.

non-null

Whether the merchandise is a gift card.

non-null

Whether the item needs to be shipped to the customer. For example, a digital gift card doesn't need to be shipped, but a t-shirt does need to be shipped.

non-null

The localized name for the product that displays to customers. The title is used to construct the product's handle, which is a unique, human-readable string of the product's title. For example, if a product is titled "Black Sunglasses", then the handle is black-sunglasses.

The product variant's weight, in the system of measurement set in the weightUnit field.

non-null

The unit of measurement for weight.

GRAMS, KILOGRAMS, OUNCES, POUNDS
OBJECT

A specific version of a product that comes in more than one option, such as size or color. For example, if a merchant sells t-shirts with options for size and color, then a small, blue t-shirt would be one product variant and a large, blue t-shirt would be another.

non-null

A globally-unique ID for the product variant.

A custom field that stores additional information about a Shopify resource, such as products, orders, and many more. Using metafields with Shopify Functions enables you to customize the checkout experience.

Arguments

A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts between different apps or different parts of the same app. If omitted, then the app-reserved namespace is used.

required

The unique identifier for the metafield within its namespace. A metafield is composed of a namespace and a key, in the format namespace.key.


Fields

non-null

The data that's stored in the metafield, using JSON format.

non-null

The type of data that the metafield stores in the value field.

non-null

The data that's stored in the metafield. The data is always stored as a string, regardless of the metafield's type.

non-null

The product associated with the product variant. For example, if a merchant sells t-shirts with options for size and color, then a small, blue t-shirt would be one product variant and a large, blue t-shirt would be another. The product associated with the product variant would be the t-shirt itself.

non-null

A unique, human-readable string of the product's title. A handle can contain letters, hyphens (-), and numbers, but not spaces. The handle is used in the online store URL for the product. For example, if a product is titled "Black Sunglasses", then the handle is black-sunglasses.

non-null

Whether the product is associated with any of the specified tags. The product must have at least one tag from the list to return true.

Arguments

requiredDefault:[]

A comma-separated list of searchable keywords that are associated with the product. For example, "sports, summer" returns products with either the sports or summer tag.


non-null

Whether the product is associated with the specified tags.

Arguments

requiredDefault:[]

A comma-separated list of searchable keywords that are associated with the product. For example, "sports, summer" returns products with both the sports and summer tags.


Fields

non-null

Whether the Shopify resource has the tag.

non-null

A searchable keyword that's associated with a Shopify resource, such as a product or customer. For example, a merchant might apply the sports and summer tags to products that are associated with sportswear for summer.

non-null

A globally-unique ID for the product.

non-null

Whether the product is in any of the specified collections. The product must be in at least one collection from the list to return true.

A collection is a group of products that can be displayed in online stores and other sales channels in categories, which makes it easy for customers to find them. For example, an athletics store might create different collections for running attire and accessories.

Arguments

requiredDefault:[]

A comma-separated list of globally-unique collection IDs that are associated with the product. For example, gid://shopify/Collection/123, gid://shopify/Collection/456.


non-null

Whether the product is in the specified collections. The product must be in all of the collections in the list to return true.

A collection is a group of products that can be displayed in online stores and other sales channels in categories, which makes it easy for customers to find them. For example, an athletics store might create different collections for running attire and accessories.

Arguments

requiredDefault:[]

A comma-separated list of globally-unique collection IDs that are associated with the product. For example, gid://shopify/Collection/123, gid://shopify/Collection/456.


Fields

non-null

A globally-unique ID for the collection.

non-null

Whether the product is in the specified collection.

non-null

Whether the product is a gift card.

A custom field that stores additional information about a Shopify resource, such as products, orders, and many more. Using metafields with Shopify Functions enables you to customize the checkout experience.

Arguments

A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts between different apps or different parts of the same app. If omitted, then the app-reserved namespace is used.

required

The unique identifier for the metafield within its namespace. A metafield is composed of a namespace and a key, in the format namespace.key.


Fields

non-null

The data that's stored in the metafield, using JSON format.

non-null

The type of data that the metafield stores in the value field.

non-null

The data that's stored in the metafield. The data is always stored as a string, regardless of the metafield's type.

A custom category for a product. Product types allow merchants to define categories other than the ones available in Shopify's standard product categories.

non-null

The localized name for the product that displays to customers. The title is used to construct the product's handle, which is a unique, human-readable string of the product's title. For example, if a product is titled "Black Sunglasses", then the handle is black-sunglasses.

The name of the product's vendor.

non-null

Whether the item needs to be shipped to the customer. For example, a digital gift card doesn't need to be shipped, but a t-shirt does need to be shipped.

A case-sensitive identifier for the product variant in the merchant's store. For example, "BBC-1". A product variant must have a SKU to be connected to a fulfillment service.

The localized name for the product variant that displays to customers.

The product variant's weight, in the system of measurement set in the weightUnit field.

non-null

The unit of measurement for weight.

GRAMS, KILOGRAMS, OUNCES, POUNDS
non-null

The quantity of the item that the customer intends to purchase.

non-null

A collection of items that are grouped by shared delivery characteristics. Delivery groups streamline fulfillment by organizing items that can be shipped together, based on the customer's shipping address. For example, if a customer orders a t-shirt and a pair of shoes that can be shipped together, then the items are included in the same delivery group.

In the Order Discount and Product Discount legacy APIs, the cart.deliveryGroups input is always an empty array. This means you can't access delivery groups when creating Order Discount or Product Discount Functions. If you need to apply discounts to shipping costs, then use the Discount Function API instead.

non-null

Information about items in a cart that a customer intends to purchase. A cart line is an entry in the customer's cart that represents a single unit of a product variant. For example, if a customer adds two different sizes of the same t-shirt to their cart, then each size is represented as a separate cart line.

The custom attributes associated with a cart to store additional information. Cart attributes allow you to collect specific information from customers on the Cart page, such as order notes, gift wrapping requests, or custom product details. Attributes are stored as key-value pairs.

Cart line attributes are equivalent to the line_item object in Liquid.

Arguments

The key of the cart attribute to retrieve. For example, "gift_wrapping".


Fields

non-null

The key or name of the attribute. For example, "customer_first_order".

The value of the attribute. For example, "true".

non-null

The cost of an item in a cart that the customer intends to purchase. Cart lines are entries in the customer's cart that represent a single unit of a product variant. For example, if a customer adds two different sizes of the same t-shirt to their cart, then each size is represented as a separate cart line.

non-null

The cost of a single unit. For example, if a customer purchases three units of a product that are priced at $10 each, then the amountPerQuantity is $10.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
Anchor to compareAtAmountPerQuantitycompareAtAmountPerQuantity

The compareAt price of a single unit before any discounts are applied. This field is used to calculate and display savings for customers. For example, if a product's compareAtAmountPerQuantity is $25 and its current price is $20, then the customer sees a $5 discount. This value can change based on the buyer's identity and is null when the value is hidden from buyers.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
non-null

The cost of items in the cart before applying any discounts to certain items. This amount serves as the starting point for calculating any potential savings customers might receive through promotions or discounts.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
non-null

The total cost of items in a cart.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
non-null

The discounts that have been applied to the cart line.

non-null

The discount that was applied.

non-null

The method by which the discount's value is allocated to its entitled items.

ACROSS, EACH

A custom field that stores additional information about a Shopify resource, such as products, orders, and many more. Using metafields with Shopify Functions enables you to customize the checkout experience.

Arguments

A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts between different apps or different parts of the same app. If omitted, then the app-reserved namespace is used.

required

The unique identifier for the metafield within its namespace. A metafield is composed of a namespace and a key, in the format namespace.key.


Fields

non-null

The data that's stored in the metafield, using JSON format.

non-null

The type of data that the metafield stores in the value field.

non-null

The data that's stored in the metafield. The data is always stored as a string, regardless of the metafield's type.

non-null

The lines on the cart targeted by the discount.

ALL, ENTITLED, EXPLICIT
non-null

The type of line (i.e. line item or shipping line) on a cart that the discount is applicable towards.

LINE_ITEM, SHIPPING_LINE
Anchor to totalAllocatedAmounttotalAllocatedAmount
non-null

The total allocated amount of the discount across all items.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
non-null

The value of the discount.

OBJECT

A precise monetary value and its associated currency. Combines a decimal amount with a three-letter currency code to express prices, costs, and other financial values throughout the API. For example, 12.99 USD.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
Anchor to PricingPercentageValue
OBJECT

The percentage value of a discount.

non-null

The percentage value of the discount.

non-null

The amount that was discounted.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
non-null

The ID of the cart line.

non-null

The item that the customer intends to purchase.

OBJECT

A custom product represents a product that doesn't map to Shopify's standard product categories. For example, you can use a custom product to manage gift cards, shipping requirements, localized product information, or weight measurements and conversions.

non-null

Whether the merchandise is a gift card.

non-null

Whether the item needs to be shipped to the customer. For example, a digital gift card doesn't need to be shipped, but a t-shirt does need to be shipped.

non-null

The localized name for the product that displays to customers. The title is used to construct the product's handle, which is a unique, human-readable string of the product's title. For example, if a product is titled "Black Sunglasses", then the handle is black-sunglasses.

The product variant's weight, in the system of measurement set in the weightUnit field.

non-null

The unit of measurement for weight.

GRAMS, KILOGRAMS, OUNCES, POUNDS
OBJECT

A specific version of a product that comes in more than one option, such as size or color. For example, if a merchant sells t-shirts with options for size and color, then a small, blue t-shirt would be one product variant and a large, blue t-shirt would be another.

non-null

A globally-unique ID for the product variant.

A custom field that stores additional information about a Shopify resource, such as products, orders, and many more. Using metafields with Shopify Functions enables you to customize the checkout experience.

Arguments

A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts between different apps or different parts of the same app. If omitted, then the app-reserved namespace is used.

required

The unique identifier for the metafield within its namespace. A metafield is composed of a namespace and a key, in the format namespace.key.


Fields

non-null

The data that's stored in the metafield, using JSON format.

non-null

The type of data that the metafield stores in the value field.

non-null

The data that's stored in the metafield. The data is always stored as a string, regardless of the metafield's type.

non-null

The product associated with the product variant. For example, if a merchant sells t-shirts with options for size and color, then a small, blue t-shirt would be one product variant and a large, blue t-shirt would be another. The product associated with the product variant would be the t-shirt itself.

non-null

A unique, human-readable string of the product's title. A handle can contain letters, hyphens (-), and numbers, but not spaces. The handle is used in the online store URL for the product. For example, if a product is titled "Black Sunglasses", then the handle is black-sunglasses.

non-null

Whether the product is associated with any of the specified tags. The product must have at least one tag from the list to return true.

Arguments

requiredDefault:[]

A comma-separated list of searchable keywords that are associated with the product. For example, "sports, summer" returns products with either the sports or summer tag.


non-null

Whether the product is associated with the specified tags.

Arguments

requiredDefault:[]

A comma-separated list of searchable keywords that are associated with the product. For example, "sports, summer" returns products with both the sports and summer tags.


Fields

non-null

Whether the Shopify resource has the tag.

non-null

A searchable keyword that's associated with a Shopify resource, such as a product or customer. For example, a merchant might apply the sports and summer tags to products that are associated with sportswear for summer.

non-null

A globally-unique ID for the product.

non-null

Whether the product is in any of the specified collections. The product must be in at least one collection from the list to return true.

A collection is a group of products that can be displayed in online stores and other sales channels in categories, which makes it easy for customers to find them. For example, an athletics store might create different collections for running attire and accessories.

Arguments

requiredDefault:[]

A comma-separated list of globally-unique collection IDs that are associated with the product. For example, gid://shopify/Collection/123, gid://shopify/Collection/456.


non-null

Whether the product is in the specified collections. The product must be in all of the collections in the list to return true.

A collection is a group of products that can be displayed in online stores and other sales channels in categories, which makes it easy for customers to find them. For example, an athletics store might create different collections for running attire and accessories.

Arguments

requiredDefault:[]

A comma-separated list of globally-unique collection IDs that are associated with the product. For example, gid://shopify/Collection/123, gid://shopify/Collection/456.


Fields

non-null

A globally-unique ID for the collection.

non-null

Whether the product is in the specified collection.

non-null

Whether the product is a gift card.

A custom field that stores additional information about a Shopify resource, such as products, orders, and many more. Using metafields with Shopify Functions enables you to customize the checkout experience.

Arguments

A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts between different apps or different parts of the same app. If omitted, then the app-reserved namespace is used.

required

The unique identifier for the metafield within its namespace. A metafield is composed of a namespace and a key, in the format namespace.key.


Fields

non-null

The data that's stored in the metafield, using JSON format.

non-null

The type of data that the metafield stores in the value field.

non-null

The data that's stored in the metafield. The data is always stored as a string, regardless of the metafield's type.

A custom category for a product. Product types allow merchants to define categories other than the ones available in Shopify's standard product categories.

non-null

The localized name for the product that displays to customers. The title is used to construct the product's handle, which is a unique, human-readable string of the product's title. For example, if a product is titled "Black Sunglasses", then the handle is black-sunglasses.

The name of the product's vendor.

non-null

Whether the item needs to be shipped to the customer. For example, a digital gift card doesn't need to be shipped, but a t-shirt does need to be shipped.

A case-sensitive identifier for the product variant in the merchant's store. For example, "BBC-1". A product variant must have a SKU to be connected to a fulfillment service.

The localized name for the product variant that displays to customers.

The product variant's weight, in the system of measurement set in the weightUnit field.

non-null

The unit of measurement for weight.

GRAMS, KILOGRAMS, OUNCES, POUNDS

The nested relationship between this line and its parent line, if any.

non-null

The parent line in the relationship.

non-null

The quantity of the item that the customer intends to purchase.

Anchor to sellingPlanAllocationsellingPlanAllocation

The selling plan associated with the cart line, including information about how a product variant can be sold and purchased.

non-null

A list of price adjustments, with a maximum of two. When there are two, the first price adjustment goes into effect at the time of purchase, while the second one starts after a certain number of orders. A price adjustment represents how a selling plan affects pricing when a variant is purchased with a selling plan. Prices display in the customer's currency if the shop is configured for it.

non-null

The effective price for a single delivery. For example, for a prepaid subscription plan that includes 6 deliveries at the price of $48.00, the per delivery price is $8.00.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
non-null

The price of the variant when it's purchased with a selling plan For example, for a prepaid subscription plan that includes 6 deliveries of $10.00 granola, where the customer gets 20% off, the price is 6 x $10.00 x 0.80 = $48.00.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
non-null

A representation of how products and variants can be sold and purchased. For example, an individual selling plan could be '6 weeks of prepaid granola, delivered weekly'.

The description of the selling plan.

non-null

A globally-unique identifier.

A custom field that stores additional information about a Shopify resource, such as products, orders, and many more. Using metafields with Shopify Functions enables you to customize the checkout experience.

Arguments

A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts between different apps or different parts of the same app. If omitted, then the app-reserved namespace is used.

required

The unique identifier for the metafield within its namespace. A metafield is composed of a namespace and a key, in the format namespace.key.


Fields

non-null

The data that's stored in the metafield, using JSON format.

non-null

The type of data that the metafield stores in the value field.

non-null

The data that's stored in the metafield. The data is always stored as a string, regardless of the metafield's type.

non-null

The name of the selling plan. For example, '6 weeks of prepaid granola, delivered weekly'.

non-null

Whether purchasing the selling plan will result in multiple deliveries.

The shipping or destination address associated with the delivery group.

The first line of the address. Typically the street address or PO Box number.

The second line of the address. Typically the number of the apartment, suite, or unit.

The name of the city, district, village, or town.

The name of the customer's company or organization.

The two-letter code for the country of the address. For example, US.

AC, AD, AE, AF, AG, AI, AL, AM, AN, AO, AR, AT, AU, AW, AX, AZ, BA, BB, BD, BE, BF, BG, BH, BI, BJ, BL, BM, BN, BO, BQ, BR, BS, BT, BV, BW, BY, BZ, CA, CC, CD, CF, CG, CH, CI, CK, CL, CM, CN, CO, CR, CU, CV, CW, CX, CY, CZ, DE, DJ, DK, DM, DO, DZ, EC, EE, EG, EH, ER, ES, ET, FI, FJ, FK, FO, FR, GA, GB, GD, GE, GF, GG, GH, GI, GL, GM, GN, GP, GQ, GR, GS, GT, GW, GY, HK, HM, HN, HR, HT, HU, ID, IE, IL, IM, IN, IO, IQ, IR, IS, IT, JE, JM, JO, JP, KE, KG, KH, KI, KM, KN, KP, KR, KW, KY, KZ, LA, LB, LC, LI, LK, LR, LS, LT, LU, LV, LY, MA, MC, MD, ME, MF, MG, MK, ML, MM, MN, MO, MQ, MR, MS, MT, MU, MV, MW, MX, MY, MZ, NA, NC, NE, NF, NG, NI, NL, NO, NP, NR, NU, NZ, OM, PA, PE, PF, PG, PH, PK, PL, PM, PN, PS, PT, PY, QA, RE, RO, RS, RU, RW, SA, SB, SC, SD, SE, SG, SH, SI, SJ, SK, SL, SM, SN, SO, SR, SS, ST, SV, SX, SY, SZ, TA, TC, TD, TF, TG, TH, TJ, TK, TL, TM, TN, TO, TR, TT, TV, TW, TZ, UA, UG, UM, US, UY, UZ, VA, VC, VE, VG, VN, VU, WF, WS, XK, YE, YT, ZA, ZM, ZW, ZZ

The first name of the customer.

The last name of the customer.

The approximate latitude of the address.

The approximate longitude of the address.

The full name of the customer, based on firstName and lastName.

A unique phone number for the customer. Formatted using E.164 standard. For example, +16135551111.

The alphanumeric code for the region. For example, ON.

The zip or postal code of the address.

Deprecated
non-null

A human-readable unique string for the market automatically generated from its title.

non-null

A globally-unique identifier.

A custom field that stores additional information about a Shopify resource, such as products, orders, and many more. Using metafields with Shopify Functions enables you to customize the checkout experience.

Arguments

A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts between different apps or different parts of the same app. If omitted, then the app-reserved namespace is used.

required

The unique identifier for the metafield within its namespace. A metafield is composed of a namespace and a key, in the format namespace.key.


Fields

non-null

The data that's stored in the metafield, using JSON format.

non-null

The type of data that the metafield stores in the value field.

non-null

The data that's stored in the metafield. The data is always stored as a string, regardless of the metafield's type.

non-null

A geographic region which comprises a market.

The name of the region in the language of the current localization.

non-null

The delivery options available for the delivery group. Delivery options are the different ways that customers can choose to have their orders shipped. Examples include express shipping or standard shipping.

A unique identifier that represents the delivery option offered to customers. For example, Canada Post Expedited.

non-null

The amount that the customer pays if they select the delivery option.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
non-null

The delivery method associated with the delivery option. A delivery method is a way that merchants can fulfill orders from their online stores. Delivery methods include shipping to an address, local pickup, and shipping to a pickup point, all of which are natively supported by Shopify checkout.

LOCAL, NONE, PICK_UP, PICKUP_POINT, RETAIL, SHIPPING

A single-line description of the delivery option, with HTML tags removed.

non-null

A unique, human-readable identifier of the delivery option's title. A handle can contain letters, hyphens (-), and numbers, but not spaces. For example, standard-shipping.

The name of the delivery option that displays to customers. The title is used to construct the delivery option's handle. For example, if a delivery option is titled "Standard Shipping", then the handle is standard-shipping.

non-null

The discounts that have been applied to the delivery group.

non-null

The discount that was applied.

non-null

The method by which the discount's value is allocated to its entitled items.

ACROSS, EACH

A custom field that stores additional information about a Shopify resource, such as products, orders, and many more. Using metafields with Shopify Functions enables you to customize the checkout experience.

Arguments

A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts between different apps or different parts of the same app. If omitted, then the app-reserved namespace is used.

required

The unique identifier for the metafield within its namespace. A metafield is composed of a namespace and a key, in the format namespace.key.


Fields

non-null

The data that's stored in the metafield, using JSON format.

non-null

The type of data that the metafield stores in the value field.

non-null

The data that's stored in the metafield. The data is always stored as a string, regardless of the metafield's type.

non-null

The lines on the cart targeted by the discount.

ALL, ENTITLED, EXPLICIT
non-null

The type of line (i.e. line item or shipping line) on a cart that the discount is applicable towards.

LINE_ITEM, SHIPPING_LINE
Anchor to totalAllocatedAmounttotalAllocatedAmount
non-null

The total allocated amount of the discount across all items.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
non-null

The value of the discount.

OBJECT

A precise monetary value and its associated currency. Combines a decimal amount with a three-letter currency code to express prices, costs, and other financial values throughout the API. For example, 12.99 USD.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
Anchor to PricingPercentageValue
OBJECT

The percentage value of a discount.

non-null

The percentage value of the discount.

non-null

The amount that was discounted.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
non-null

The type of merchandise in the delivery group.

ONE_TIME_PURCHASE, SUBSCRIPTION
non-null

A globally-unique ID for the delivery group.

Anchor to selectedDeliveryOptionselectedDeliveryOption

Information about the delivery option that the customer has selected.

A unique identifier that represents the delivery option offered to customers. For example, Canada Post Expedited.

non-null

The amount that the customer pays if they select the delivery option.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
non-null

The delivery method associated with the delivery option. A delivery method is a way that merchants can fulfill orders from their online stores. Delivery methods include shipping to an address, local pickup, and shipping to a pickup point, all of which are natively supported by Shopify checkout.

LOCAL, NONE, PICK_UP, PICKUP_POINT, RETAIL, SHIPPING

A single-line description of the delivery option, with HTML tags removed.

non-null

A unique, human-readable identifier of the delivery option's title. A handle can contain letters, hyphens (-), and numbers, but not spaces. For example, standard-shipping.

The name of the delivery option that displays to customers. The title is used to construct the delivery option's handle. For example, if a delivery option is titled "Standard Shipping", then the handle is standard-shipping.

Anchor to discountApplicationsdiscountApplications
non-null

The discounts that have been applied to the cart.

non-null

The method by which the discount's value is allocated to its entitled items.

ACROSS, EACH

A custom field that stores additional information about a Shopify resource, such as products, orders, and many more. Using metafields with Shopify Functions enables you to customize the checkout experience.

Arguments

A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts between different apps or different parts of the same app. If omitted, then the app-reserved namespace is used.

required

The unique identifier for the metafield within its namespace. A metafield is composed of a namespace and a key, in the format namespace.key.


Fields

non-null

The data that's stored in the metafield, using JSON format.

non-null

The type of data that the metafield stores in the value field.

non-null

The data that's stored in the metafield. The data is always stored as a string, regardless of the metafield's type.

non-null

The lines on the cart targeted by the discount.

ALL, ENTITLED, EXPLICIT
non-null

The type of line (i.e. line item or shipping line) on a cart that the discount is applicable towards.

LINE_ITEM, SHIPPING_LINE
Anchor to totalAllocatedAmounttotalAllocatedAmount
non-null

The total allocated amount of the discount across all items.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
non-null

The value of the discount.

OBJECT

A precise monetary value and its associated currency. Combines a decimal amount with a three-letter currency code to express prices, costs, and other financial values throughout the API. For example, 12.99 USD.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
Anchor to PricingPercentageValue
OBJECT

The percentage value of a discount.

non-null

The percentage value of the discount.

non-null

The items in a cart that the customer intends to purchase. A cart line is an entry in the customer's cart that represents a single unit of a product variant. For example, if a customer adds two different sizes of the same t-shirt to their cart, then each size is represented as a separate cart line.

The custom attributes associated with a cart to store additional information. Cart attributes allow you to collect specific information from customers on the Cart page, such as order notes, gift wrapping requests, or custom product details. Attributes are stored as key-value pairs.

Cart line attributes are equivalent to the line_item object in Liquid.

Arguments

The key of the cart attribute to retrieve. For example, "gift_wrapping".


Fields

non-null

The key or name of the attribute. For example, "customer_first_order".

The value of the attribute. For example, "true".

non-null

The cost of an item in a cart that the customer intends to purchase. Cart lines are entries in the customer's cart that represent a single unit of a product variant. For example, if a customer adds two different sizes of the same t-shirt to their cart, then each size is represented as a separate cart line.

non-null

The cost of a single unit. For example, if a customer purchases three units of a product that are priced at $10 each, then the amountPerQuantity is $10.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
Anchor to compareAtAmountPerQuantitycompareAtAmountPerQuantity

The compareAt price of a single unit before any discounts are applied. This field is used to calculate and display savings for customers. For example, if a product's compareAtAmountPerQuantity is $25 and its current price is $20, then the customer sees a $5 discount. This value can change based on the buyer's identity and is null when the value is hidden from buyers.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
non-null

The cost of items in the cart before applying any discounts to certain items. This amount serves as the starting point for calculating any potential savings customers might receive through promotions or discounts.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
non-null

The total cost of items in a cart.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
non-null

The discounts that have been applied to the cart line.

non-null

The discount that was applied.

non-null

The method by which the discount's value is allocated to its entitled items.

ACROSS, EACH

A custom field that stores additional information about a Shopify resource, such as products, orders, and many more. Using metafields with Shopify Functions enables you to customize the checkout experience.

Arguments

A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts between different apps or different parts of the same app. If omitted, then the app-reserved namespace is used.

required

The unique identifier for the metafield within its namespace. A metafield is composed of a namespace and a key, in the format namespace.key.


Fields

non-null

The data that's stored in the metafield, using JSON format.

non-null

The type of data that the metafield stores in the value field.

non-null

The data that's stored in the metafield. The data is always stored as a string, regardless of the metafield's type.

non-null

The lines on the cart targeted by the discount.

ALL, ENTITLED, EXPLICIT
non-null

The type of line (i.e. line item or shipping line) on a cart that the discount is applicable towards.

LINE_ITEM, SHIPPING_LINE
Anchor to totalAllocatedAmounttotalAllocatedAmount
non-null

The total allocated amount of the discount across all items.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
non-null

The value of the discount.

OBJECT

A precise monetary value and its associated currency. Combines a decimal amount with a three-letter currency code to express prices, costs, and other financial values throughout the API. For example, 12.99 USD.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
Anchor to PricingPercentageValue
OBJECT

The percentage value of a discount.

non-null

The percentage value of the discount.

non-null

The amount that was discounted.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
non-null

The ID of the cart line.

non-null

The item that the customer intends to purchase.

OBJECT

A custom product represents a product that doesn't map to Shopify's standard product categories. For example, you can use a custom product to manage gift cards, shipping requirements, localized product information, or weight measurements and conversions.

non-null

Whether the merchandise is a gift card.

non-null

Whether the item needs to be shipped to the customer. For example, a digital gift card doesn't need to be shipped, but a t-shirt does need to be shipped.

non-null

The localized name for the product that displays to customers. The title is used to construct the product's handle, which is a unique, human-readable string of the product's title. For example, if a product is titled "Black Sunglasses", then the handle is black-sunglasses.

The product variant's weight, in the system of measurement set in the weightUnit field.

non-null

The unit of measurement for weight.

GRAMS, KILOGRAMS, OUNCES, POUNDS
OBJECT

A specific version of a product that comes in more than one option, such as size or color. For example, if a merchant sells t-shirts with options for size and color, then a small, blue t-shirt would be one product variant and a large, blue t-shirt would be another.

non-null

A globally-unique ID for the product variant.

A custom field that stores additional information about a Shopify resource, such as products, orders, and many more. Using metafields with Shopify Functions enables you to customize the checkout experience.

Arguments

A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts between different apps or different parts of the same app. If omitted, then the app-reserved namespace is used.

required

The unique identifier for the metafield within its namespace. A metafield is composed of a namespace and a key, in the format namespace.key.


Fields

non-null

The data that's stored in the metafield, using JSON format.

non-null

The type of data that the metafield stores in the value field.

non-null

The data that's stored in the metafield. The data is always stored as a string, regardless of the metafield's type.

non-null

The product associated with the product variant. For example, if a merchant sells t-shirts with options for size and color, then a small, blue t-shirt would be one product variant and a large, blue t-shirt would be another. The product associated with the product variant would be the t-shirt itself.

non-null

A unique, human-readable string of the product's title. A handle can contain letters, hyphens (-), and numbers, but not spaces. The handle is used in the online store URL for the product. For example, if a product is titled "Black Sunglasses", then the handle is black-sunglasses.

non-null

Whether the product is associated with any of the specified tags. The product must have at least one tag from the list to return true.

Arguments

requiredDefault:[]

A comma-separated list of searchable keywords that are associated with the product. For example, "sports, summer" returns products with either the sports or summer tag.


non-null

Whether the product is associated with the specified tags.

Arguments

requiredDefault:[]

A comma-separated list of searchable keywords that are associated with the product. For example, "sports, summer" returns products with both the sports and summer tags.


Fields

non-null

Whether the Shopify resource has the tag.

non-null

A searchable keyword that's associated with a Shopify resource, such as a product or customer. For example, a merchant might apply the sports and summer tags to products that are associated with sportswear for summer.

non-null

A globally-unique ID for the product.

non-null

Whether the product is in any of the specified collections. The product must be in at least one collection from the list to return true.

A collection is a group of products that can be displayed in online stores and other sales channels in categories, which makes it easy for customers to find them. For example, an athletics store might create different collections for running attire and accessories.

Arguments

requiredDefault:[]

A comma-separated list of globally-unique collection IDs that are associated with the product. For example, gid://shopify/Collection/123, gid://shopify/Collection/456.


non-null

Whether the product is in the specified collections. The product must be in all of the collections in the list to return true.

A collection is a group of products that can be displayed in online stores and other sales channels in categories, which makes it easy for customers to find them. For example, an athletics store might create different collections for running attire and accessories.

Arguments

requiredDefault:[]

A comma-separated list of globally-unique collection IDs that are associated with the product. For example, gid://shopify/Collection/123, gid://shopify/Collection/456.


Fields

non-null

A globally-unique ID for the collection.

non-null

Whether the product is in the specified collection.

non-null

Whether the product is a gift card.

A custom field that stores additional information about a Shopify resource, such as products, orders, and many more. Using metafields with Shopify Functions enables you to customize the checkout experience.

Arguments

A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts between different apps or different parts of the same app. If omitted, then the app-reserved namespace is used.

required

The unique identifier for the metafield within its namespace. A metafield is composed of a namespace and a key, in the format namespace.key.


Fields

non-null

The data that's stored in the metafield, using JSON format.

non-null

The type of data that the metafield stores in the value field.

non-null

The data that's stored in the metafield. The data is always stored as a string, regardless of the metafield's type.

A custom category for a product. Product types allow merchants to define categories other than the ones available in Shopify's standard product categories.

non-null

The localized name for the product that displays to customers. The title is used to construct the product's handle, which is a unique, human-readable string of the product's title. For example, if a product is titled "Black Sunglasses", then the handle is black-sunglasses.

The name of the product's vendor.

non-null

Whether the item needs to be shipped to the customer. For example, a digital gift card doesn't need to be shipped, but a t-shirt does need to be shipped.

A case-sensitive identifier for the product variant in the merchant's store. For example, "BBC-1". A product variant must have a SKU to be connected to a fulfillment service.

The localized name for the product variant that displays to customers.

The product variant's weight, in the system of measurement set in the weightUnit field.

non-null

The unit of measurement for weight.

GRAMS, KILOGRAMS, OUNCES, POUNDS

The nested relationship between this line and its parent line, if any.

non-null

The parent line in the relationship.

non-null

The quantity of the item that the customer intends to purchase.

Anchor to sellingPlanAllocationsellingPlanAllocation

The selling plan associated with the cart line, including information about how a product variant can be sold and purchased.

non-null

A list of price adjustments, with a maximum of two. When there are two, the first price adjustment goes into effect at the time of purchase, while the second one starts after a certain number of orders. A price adjustment represents how a selling plan affects pricing when a variant is purchased with a selling plan. Prices display in the customer's currency if the shop is configured for it.

non-null

The effective price for a single delivery. For example, for a prepaid subscription plan that includes 6 deliveries at the price of $48.00, the per delivery price is $8.00.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
non-null

The price of the variant when it's purchased with a selling plan For example, for a prepaid subscription plan that includes 6 deliveries of $10.00 granola, where the customer gets 20% off, the price is 6 x $10.00 x 0.80 = $48.00.

non-null

A monetary value in decimal format, allowing for precise representation of cents or fractional currency. For example, 12.99.

non-null

The three-letter currency code that represents a world currency used in a store. Currency codes include standard standard ISO 4217 codes, legacy codes, and non-standard codes. For example, USD.

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, USDC, UYU, UZS, VED, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, XXX, YER, ZAR, ZMW, BYR, STD, VEF
non-null

A representation of how products and variants can be sold and purchased. For example, an individual selling plan could be '6 weeks of prepaid granola, delivered weekly'.

The description of the selling plan.

non-null

A globally-unique identifier.

A custom field that stores additional information about a Shopify resource, such as products, orders, and many more. Using metafields with Shopify Functions enables you to customize the checkout experience.

Arguments

A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts between different apps or different parts of the same app. If omitted, then the app-reserved namespace is used.

required

The unique identifier for the metafield within its namespace. A metafield is composed of a namespace and a key, in the format namespace.key.


Fields

non-null

The data that's stored in the metafield, using JSON format.

non-null

The type of data that the metafield stores in the value field.

non-null

The data that's stored in the metafield. The data is always stored as a string, regardless of the metafield's type.

non-null

The name of the selling plan. For example, '6 weeks of prepaid granola, delivered weekly'.

non-null

Whether purchasing the selling plan will result in multiple deliveries.

non-null

The additional fields on the Cart page that are required for international orders in specific countries, such as customs information or tax identification numbers.

Arguments

requiredDefault:[]

The keys of the localized fields to retrieve.

SHIPPING_CREDENTIAL_BR, SHIPPING_CREDENTIAL_CL, SHIPPING_CREDENTIAL_CN, SHIPPING_CREDENTIAL_CO, SHIPPING_CREDENTIAL_CR, SHIPPING_CREDENTIAL_EC, SHIPPING_CREDENTIAL_ES, SHIPPING_CREDENTIAL_GT, SHIPPING_CREDENTIAL_ID, SHIPPING_CREDENTIAL_KR, SHIPPING_CREDENTIAL_MX, SHIPPING_CREDENTIAL_MY, SHIPPING_CREDENTIAL_PE, SHIPPING_CREDENTIAL_PT, SHIPPING_CREDENTIAL_PY, SHIPPING_CREDENTIAL_TR, SHIPPING_CREDENTIAL_TW, SHIPPING_CREDENTIAL_TYPE_CO, TAX_CREDENTIAL_BR, TAX_CREDENTIAL_CL, TAX_CREDENTIAL_CO, TAX_CREDENTIAL_CR, TAX_CREDENTIAL_EC, TAX_CREDENTIAL_ES, TAX_CREDENTIAL_GT, TAX_CREDENTIAL_ID, TAX_CREDENTIAL_IT, TAX_CREDENTIAL_MX, TAX_CREDENTIAL_MY, TAX_CREDENTIAL_PE, TAX_CREDENTIAL_PT, TAX_CREDENTIAL_PY, TAX_CREDENTIAL_TR, TAX_CREDENTIAL_TYPE_CO, TAX_CREDENTIAL_TYPE_MX, TAX_CREDENTIAL_USE_MX, TAX_EMAIL_IT

Fields

non-null

The key of the localized field.

SHIPPING_CREDENTIAL_BR, SHIPPING_CREDENTIAL_CL, SHIPPING_CREDENTIAL_CN, SHIPPING_CREDENTIAL_CO, SHIPPING_CREDENTIAL_CR, SHIPPING_CREDENTIAL_EC, SHIPPING_CREDENTIAL_ES, SHIPPING_CREDENTIAL_GT, SHIPPING_CREDENTIAL_ID, SHIPPING_CREDENTIAL_KR, SHIPPING_CREDENTIAL_MX, SHIPPING_CREDENTIAL_MY, SHIPPING_CREDENTIAL_PE, SHIPPING_CREDENTIAL_PT, SHIPPING_CREDENTIAL_PY, SHIPPING_CREDENTIAL_TR, SHIPPING_CREDENTIAL_TW, SHIPPING_CREDENTIAL_TYPE_CO, TAX_CREDENTIAL_BR, TAX_CREDENTIAL_CL, TAX_CREDENTIAL_CO, TAX_CREDENTIAL_CR, TAX_CREDENTIAL_EC, TAX_CREDENTIAL_ES, TAX_CREDENTIAL_GT, TAX_CREDENTIAL_ID, TAX_CREDENTIAL_IT, TAX_CREDENTIAL_MX, TAX_CREDENTIAL_MY, TAX_CREDENTIAL_PE, TAX_CREDENTIAL_PT, TAX_CREDENTIAL_PY, TAX_CREDENTIAL_TR, TAX_CREDENTIAL_TYPE_CO, TAX_CREDENTIAL_TYPE_MX, TAX_CREDENTIAL_USE_MX, TAX_EMAIL_IT
non-null

The title of the localized field.

The value of the localized field.

A custom field that stores additional information about a Shopify resource, such as products, orders, and many more. Using metafields with Shopify Functions enables you to customize the checkout experience.

Arguments

A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts between different apps or different parts of the same app. If omitted, then the app-reserved namespace is used.

required

The unique identifier for the metafield within its namespace. A metafield is composed of a namespace and a key, in the format namespace.key.


Fields

non-null

The data that's stored in the metafield, using JSON format.

non-null

The type of data that the metafield stores in the value field.

non-null

The data that's stored in the metafield. The data is always stored as a string, regardless of the metafield's type.

A purchase order number associated with the cart, often used for B2B transactions to reference the buyer's internal purchase order.

The physical location where a retail order is created or completed.

non-null

The address of this location.

The first line of the address for the location.

The second line of the address for the location.

The city of the location.

The country of the location.

The country code of the location.

non-null

A formatted version of the address for the location.

The approximate latitude coordinates of the location.

The approximate longitude coordinates of the location.

The phone number of the location.

The province of the location.

The code for the province, state, or district of the address of the location.

The ZIP code of the location.

non-null

The location handle.

non-null

The location id.

A custom field that stores additional information about a Shopify resource, such as products, orders, and many more. Using metafields with Shopify Functions enables you to customize the checkout experience.

Arguments

A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts between different apps or different parts of the same app. If omitted, then the app-reserved namespace is used.

required

The unique identifier for the metafield within its namespace. A metafield is composed of a namespace and a key, in the format namespace.key.


Fields

non-null

The data that's stored in the metafield, using JSON format.

non-null

The type of data that the metafield stores in the value field.

non-null

The data that's stored in the metafield. The data is always stored as a string, regardless of the metafield's type.

non-null

The name of the location.

Anchor to fulfillmentConstraintRulefulfillmentConstraintRule
non-null

The backend logic that the Function uses to determine how to fulfill orders. It includes the metafields that are associated with the customization.

A custom field that stores additional information about a Shopify resource, such as products, orders, and many more. Using metafields with Shopify Functions enables you to customize the checkout experience.

Arguments

A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts between different apps or different parts of the same app. If omitted, then the app-reserved namespace is used.

required

The unique identifier for the metafield within its namespace. A metafield is composed of a namespace and a key, in the format namespace.key.


Fields

non-null

The data that's stored in the metafield, using JSON format.

non-null

The type of data that the metafield stores in the value field.

non-null

The data that's stored in the metafield. The data is always stored as a string, regardless of the metafield's type.

non-null

The regional and language settings that determine how the Function handles currency, numbers, dates, and other locale-specific values during discount calculations. These settings are based on the store's configured localization practices.

non-null

The country for which the store is customized, reflecting local preferences and regulations. Localization might influence the language, currency, and product offerings available in a store to enhance the shopping experience for customers in that region.

non-null

The ISO code of the country.

AC, AD, AE, AF, AG, AI, AL, AM, AN, AO, AR, AT, AU, AW, AX, AZ, BA, BB, BD, BE, BF, BG, BH, BI, BJ, BL, BM, BN, BO, BQ, BR, BS, BT, BV, BW, BY, BZ, CA, CC, CD, CF, CG, CH, CI, CK, CL, CM, CN, CO, CR, CU, CV, CW, CX, CY, CZ, DE, DJ, DK, DM, DO, DZ, EC, EE, EG, EH, ER, ES, ET, FI, FJ, FK, FO, FR, GA, GB, GD, GE, GF, GG, GH, GI, GL, GM, GN, GP, GQ, GR, GS, GT, GW, GY, HK, HM, HN, HR, HT, HU, ID, IE, IL, IM, IN, IO, IQ, IR, IS, IT, JE, JM, JO, JP, KE, KG, KH, KI, KM, KN, KP, KR, KW, KY, KZ, LA, LB, LC, LI, LK, LR, LS, LT, LU, LV, LY, MA, MC, MD, ME, MF, MG, MK, ML, MM, MN, MO, MQ, MR, MS, MT, MU, MV, MW, MX, MY, MZ, NA, NC, NE, NF, NG, NI, NL, NO, NP, NR, NU, NZ, OM, PA, PE, PF, PG, PH, PK, PL, PM, PN, PS, PT, PY, QA, RE, RO, RS, RU, RW, SA, SB, SC, SD, SE, SG, SH, SI, SJ, SK, SL, SM, SN, SO, SR, SS, ST, SV, SX, SY, SZ, TA, TC, TD, TF, TG, TH, TJ, TK, TL, TM, TN, TO, TR, TT, TV, TW, TZ, UA, UG, UM, US, UY, UZ, VA, VC, VE, VG, VN, VU, WF, WS, XK, YE, YT, ZA, ZM, ZW, ZZ
non-null

The language for which the store is customized, ensuring content is tailored to local customers. This includes product descriptions and customer communications that resonate with the target audience.

non-null

The ISO code.

AF, AK, AM, AR, AS, AZ, BE, BG, BM, BN, BO, BR, BS, CA, CE, CKB, CS, CU, CY, DA, DE, DZ, EE, EL, EN, EO, ES, ET, EU, FA, FF, FI, FIL, FO, FR, FY, GA, GD, GL, GU, GV, HA, HE, HI, HR, HU, HY, IA, ID, IG, II, IS, IT, JA, JV, KA, KI, KK, KL, KM, KN, KO, KS, KU, KW, KY, LB, LG, LN, LO, LT, LU, LV, MG, MI, MK, ML, MN, MR, MS, MT, MY, NB, ND, NE, NL, NN, NO, OM, OR, OS, PA, PL, PS, PT, PT_BR, PT_PT, QU, RM, RN, RO, RU, RW, SA, SC, SD, SE, SG, SI, SK, SL, SN, SO, SQ, SR, SU, SV, SW, TA, TE, TG, TH, TI, TK, TO, TR, TT, UG, UK, UR, UZ, VI, VO, WO, XH, YI, YO, ZH, ZH_CN, ZH_TW, ZU
non-nullDeprecated
non-null

A human-readable unique string for the market automatically generated from its title.

non-null

A globally-unique identifier.

A custom field that stores additional information about a Shopify resource, such as products, orders, and many more. Using metafields with Shopify Functions enables you to customize the checkout experience.

Arguments

A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts between different apps or different parts of the same app. If omitted, then the app-reserved namespace is used.

required

The unique identifier for the metafield within its namespace. A metafield is composed of a namespace and a key, in the format namespace.key.


Fields

non-null

The data that's stored in the metafield, using JSON format.

non-null

The type of data that the metafield stores in the value field.

non-null

The data that's stored in the metafield. The data is always stored as a string, regardless of the metafield's type.

non-null

A geographic region which comprises a market.

The name of the region in the language of the current localization.

non-null

A list of all geographical locations where the inventory is stored, including warehouses, retail locations, and distribution centers.

Arguments

A list of globally-unique identifiers for the locations where inventory resides.

A list of location names where the inventory resides.


Fields

non-null

The address of this location.

The first line of the address for the location.

The second line of the address for the location.

The city of the location.

The country of the location.

The country code of the location.

non-null

A formatted version of the address for the location.

The approximate latitude coordinates of the location.

The approximate longitude coordinates of the location.

The phone number of the location.

The province of the location.

The code for the province, state, or district of the address of the location.

The ZIP code of the location.

non-null

The location handle.

non-null

The location id.

A custom field that stores additional information about a Shopify resource, such as products, orders, and many more. Using metafields with Shopify Functions enables you to customize the checkout experience.

Arguments

A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts between different apps or different parts of the same app. If omitted, then the app-reserved namespace is used.

required

The unique identifier for the metafield within its namespace. A metafield is composed of a namespace and a key, in the format namespace.key.


Fields

non-null

The data that's stored in the metafield, using JSON format.

non-null

The type of data that the metafield stores in the value field.

non-null

The data that's stored in the metafield. The data is always stored as a string, regardless of the metafield's type.

non-null

The name of the location.

Anchor to presentmentCurrencyRatepresentmentCurrencyRate
non-null

The exchange rate used to convert discounts between the shop's default currency and the currency that displays to the customer during checkout. For example, if a store operates in USD but a customer is viewing discounts in EUR, then the presentment currency rate handles this conversion for accurate pricing.

non-null

Information about the shop where the Function is running, including the shop's timezone setting and associated metafields.

non-null

The current time based on the store's timezone setting.

non-null

The current date relative to the parent object.

non-null

Returns true if the current date and time is at or past the given date and time, and false otherwise.

Arguments

required

The date and time to compare against, assumed to be in the timezone of the parent object.


non-null

Returns true if the current date and time is before the given date and time, and false otherwise.

Arguments

required

The date and time to compare against, assumed to be in the timezone of the parent timezone.


non-null

Returns true if the current date and time is between the two given date and times, and false otherwise.

Arguments

required

The lower bound time to compare against, assumed to be in the timezone of the parent timezone.

required

The upper bound time to compare against, assumed to be in the timezone of the parent timezone.


non-null

Returns true if the current time is at or past the given time, and false otherwise.

Arguments

required

The time to compare against, assumed to be in the timezone of the parent timezone.


non-null

Returns true if the current time is at or past the given time, and false otherwise.

Arguments

required

The time to compare against, assumed to be in the timezone of the parent timezone.


non-null

Returns true if the current time is between the two given times, and false otherwise.

Arguments

required

The lower bound time to compare against, assumed to be in the timezone of the parent timezone.

required

The upper bound time to compare against, assumed to be in the timezone of the parent timezone.


A custom field that stores additional information about a Shopify resource, such as products, orders, and many more. Using metafields with Shopify Functions enables you to customize the checkout experience.

Arguments

A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts between different apps or different parts of the same app. If omitted, then the app-reserved namespace is used.

required

The unique identifier for the metafield within its namespace. A metafield is composed of a namespace and a key, in the format namespace.key.


Fields

non-null

The data that's stored in the metafield, using JSON format.

non-null

The type of data that the metafield stores in the value field.

non-null

The data that's stored in the metafield. The data is always stored as a string, regardless of the metafield's type.

Fetch a specific Metaobject by one of its unique identifiers. Only app-owned metaobjects with the $app reserved prefix are accessible to functions.

Arguments

The handle and type of the metaobject.

non-null

The handle of the metaobject to retrieve.

non-null

The type of the metaobject. Must match an existing metaobject definition type.

The ID of the metaobject.


Fields

The field for an object key, or null if the key has no field definition.

Arguments

required

The metaobject key to access.


Fields

The assigned field value in JSON format.

non-null

The object key of this field.

non-null

The type of the field.

The assigned field value, always stored as a string regardless of the field type.

non-null

The unique handle of the metaobject, useful as a custom ID.

non-null

The type of the metaobject.

The logic that processes the input data to generate a standardized list of operations that apply fulfillment constraints.

Each operation specifies whether to fulfill items from the same location or from a specified location on a list. Shopify processes your response to determine how to best fulfill orders.

This return must follow the schema defined in the CartFulfillmentConstraintsGenerateRunResult object.

Caution

If the CartFulfillmentConstraintsGenerateRunResult object returns fulfillment constraints that are mutually exclusive, then checkout won't return any shipping rates. For example, you might not be able to fulfill an item from two locations, or you might not be able to fulfill two items together because they must be fulfilled from different locations.

Anchor to CartFulfillmentConstraintsGenerateRunResultCartFulfillmentConstraintsGenerateRunResult
OBJECT

The CartFulfillmentConstraintsGenerateRunResult object is the output of the function run target. The object contains the operations to apply constraints for fulfilling orders.

non-null

The ordered list of operations to apply when fulfilling orders. You can either specify a list of locations where cart items can be fulfilled from, or specify that cart items must be fulfilled from the same location.

Anchor to deliverableLinesMustFulfillFromAdddeliverableLinesMustFulfillFromAdd

Force a set of items to be fulfilled from a specified location. If the cart item isn't stocked at the specified location, then checkout won't return any shipping rates and completing checkout will be blocked.

The IDs of the deliverable lines for which the constraint is applied.

non-null

The IDs of the locations for which the cart lines must fulfill from.

Anchor to deliverableLinesMustFulfillFromSameLocationAdddeliverableLinesMustFulfillFromSameLocationAdd

Force a set of items to be fulfilled from the same location. If the cart items with constraints aren't stocked at the same location, then checkout won't return any shipping rates and completing checkout will be blocked.

The IDs of the deliverable lines for which the constraint is applied.

Examples
  • Prevent splitting low-subtotal carts into multiple shipments

    This function checks if the cart is below a certain configurable subtotal and if so it returns a fulfillment constraint that prevents the cart from being split into multiple shipments

    cart.fulfillment-constraints.generate.run

    Input Query (Rust)
    query Input {
      cart {
        cost {
          subtotalAmount {
            amount
            currencyCode
          }
        }
        deliverableLines {
          id
        }
      }
      fulfillmentConstraintRule {
        metafield(namespace: "$app:fulfillment-constraints", key: "configuration") {
          jsonValue
        }
      }
    }
    Input Query (JavaScript)
    query RunInput {
      cart {
        cost {
          subtotalAmount {
            amount
            currencyCode
          }
        }
        deliverableLines {
          id
        }
      }
      fulfillmentConstraintRule {
        metafield(namespace: "$app:fulfillment-constraints", key: "configuration") {
          jsonValue
        }
      }
    }
    Input Object (Rust)
    {
      "cart": {
        "cost": {
          "subtotalAmount": {
            "amount": "49.99",
            "currencyCode": "USD"
          }
        },
        "deliverableLines": [
          {
            "id": "gid://shopify/CartLine/1"
          },
          {
            "id": "gid://shopify/CartLine/2"
          }
        ]
      },
      "fulfillmentConstraintRule": {
        "metafield": {
          "jsonValue": {
            "threshold": 50.0
          }
        }
      }
    }
    Input Object (JavaScript)
    {
      "cart": {
        "cost": {
          "subtotalAmount": {
            "amount": "49.99",
            "currencyCode": "USD"
          }
        },
        "deliverableLines": [
          {
            "id": "gid://shopify/CartLine/1"
          },
          {
            "id": "gid://shopify/CartLine/2"
          }
        ]
      },
      "fulfillmentConstraintRule": {
        "metafield": {
          "jsonValue": {
            "threshold": 50.0
          }
        }
      }
    }
    Function Code (Rust)
    use crate::schema;
    use shopify_function::prelude::*;
    use shopify_function::Result;
    
    #[derive(Deserialize, Default, PartialEq)]
    pub struct Configuration {
        threshold: f64,
    }
    
    #[shopify_function]
    fn cart_fulfillment_constraints_generate_run(
        input: schema::cart_fulfillment_constraints_generate_run::Input,
    ) -> Result<schema::CartFulfillmentConstraintsGenerateRunResult> {
        // Parse configuration from metafield
        let config = match input.fulfillment_constraint_rule().metafield() {
            Some(metafield) => metafield.json_value(),
            None => &Configuration::default(),
        };
    
        // Get the cart subtotal and convert threshold to Decimal
        let subtotal = input.cart().cost().subtotal_amount().amount();
        let threshold = Decimal::from(config.threshold);
    
        // If the subtotal is below the threshold, prevent splitting
        if subtotal.lt(&threshold) {
            let deliverable_line_ids: Vec<String> = input
                .cart()
                .deliverable_lines()
                .iter()
                .map(|line| line.id().clone())
                .collect();
    
            let operations = vec![
                schema::Operation::DeliverableLinesMustFulfillFromSameLocationAdd(
                    schema::DeliverableLinesMustFulfillFromSameLocationAddOperation {
                        deliverable_line_ids: Some(deliverable_line_ids),
                    },
                ),
            ];
    
            return Ok(schema::CartFulfillmentConstraintsGenerateRunResult { operations });
        }
    
        // No constraints if the subtotal is above the threshold
        Ok(schema::CartFulfillmentConstraintsGenerateRunResult { operations: vec![] })
    }
    
    
    Performance Cost (Rust)

    33239 instructions

    Function Code (JavaScript)
    // @ts-check
    
    /**
     * @typedef {import("../generated/api").RunInput} RunInput
     * @typedef {import("../generated/api").CartFulfillmentConstraintsGenerateRunResult} CartFulfillmentConstraintsGenerateRunResult
     */
    
    /**
     * @type {CartFulfillmentConstraintsGenerateRunResult}
     */
    const NO_CHANGES = {
      operations: [],
    };
    
    /**
     * @param {RunInput} input
     * @returns {CartFulfillmentConstraintsGenerateRunResult}
     */
    export function cartFulfillmentConstraintsGenerateRun(input) {
      // Parse configuration from metafield
      const configuration = input.fulfillmentConstraintRule.metafield?.jsonValue ?? "{}"
    
      // If no configuration is provided, return no changes
      if (!configuration.threshold) {
        return NO_CHANGES;
      }
    
      // Get the cart subtotal
      const subtotal = parseFloat(input.cart.cost.subtotalAmount.amount);
    
      // If the subtotal is below the threshold, prevent splitting
      if (subtotal < configuration.threshold) {
        return {
          operations: [
            {
              deliverableLinesMustFulfillFromSameLocationAdd: {
                deliverableLineIds: input.cart.deliverableLines.map(line => line.id)
              }
            }
          ]
        };
      }
    
      // No constraints if the subtotal is above the threshold
      return NO_CHANGES;
    }
    Performance Cost (JavaScript)

    192667 instructions

    Output JSON (Rust)
    {
      "operations": [
        {
          "deliverableLinesMustFulfillFromSameLocationAdd": {
            "deliverableLineIds": [
              "gid://shopify/CartLine/1",
              "gid://shopify/CartLine/2"
            ]
          }
        }
      ]
    }
    Output JSON (JavaScript)
    {
      "operations": [
        {
          "deliverableLinesMustFulfillFromSameLocationAdd": {
            "deliverableLineIds": [
              "gid://shopify/CartLine/1",
              "gid://shopify/CartLine/2"
            ]
          }
        }
      ]
    }
  • Ensure that items in a bundle are fulfilled from the same location

    This function groups items with the same bundle attribute value and returns a fulfillment constraint that requires all items in the same bundle group to be fulfilled from the same location.

    cart.fulfillment-constraints.generate.run

    Input Query (Rust)
    query Input {
      cart {
        deliverableLines {
          id
          attribute(key: "bundle") {
            key
            value
          }
        }
      }
    }
    Input Query (JavaScript)
    query RunInput {
      cart {
        deliverableLines {
          id
          attribute(key: "bundle") {
            key
            value
          }
        }
      }
    }
    Input Object (Rust)
    {
      "cart": {
        "deliverableLines": [
          {
            "id": "gid://shopify/CartLine/1",
            "attribute": {
              "key": "bundle",
              "value": "bundle-123"
            }
          },
          {
            "id": "gid://shopify/CartLine/2",
            "attribute": {
              "key": "bundle",
              "value": "bundle-123"
            }
          },
          {
            "id": "gid://shopify/CartLine/3",
            "attribute": null
          }
        ]
      }
    }
    Input Object (JavaScript)
    {
      "cart": {
        "deliverableLines": [
          {
            "id": "gid://shopify/CartLine/1",
            "attribute": {
              "key": "bundle",
              "value": "bundle-123"
            }
          },
          {
            "id": "gid://shopify/CartLine/2",
            "attribute": {
              "key": "bundle",
              "value": "bundle-123"
            }
          },
          {
            "id": "gid://shopify/CartLine/3",
            "attribute": null
          }
        ]
      }
    }
    Function Code (Rust)
    use crate::schema;
    use shopify_function::prelude::*;
    use shopify_function::Result;
    
    #[shopify_function]
    fn cart_fulfillment_constraints_generate_run(
        input: schema::cart_fulfillment_constraints_generate_run::Input,
    ) -> Result<schema::CartFulfillmentConstraintsGenerateRunResult> {
        let mut bundle_groups: std::collections::HashMap<String, Vec<String>> =
            std::collections::HashMap::new();
    
        // Group deliverable lines by their bundle attribute value
        for line in input.cart().deliverable_lines().iter() {
            if let Some(attribute) = &line.attribute() {
                if attribute.key() == "bundle" {
                    if let Some(value) = &attribute.value() {
                        bundle_groups
                            .entry(value.to_string())
                            .or_insert_with(Vec::new)
                            .push(line.id().clone());
                    }
                }
            }
        }
    
        // Create constraints for each bundle group
        let operations: Vec<schema::Operation> = bundle_groups
            .values()
            .filter(|group| group.len() > 1) // Only create constraints for groups with more than one item
            .map(|group| {
                schema::Operation::DeliverableLinesMustFulfillFromSameLocationAdd(
                    schema::DeliverableLinesMustFulfillFromSameLocationAddOperation {
                        deliverable_line_ids: Some(group.clone()),
                    },
                )
            })
            .collect();
    
        Ok(schema::CartFulfillmentConstraintsGenerateRunResult { operations })
    }
    
    
    Performance Cost (Rust)

    40411 instructions

    Function Code (JavaScript)
    // @ts-check
    
    /**
     * @typedef {import("../generated/api").RunInput} RunInput
     * @typedef {import("../generated/api").CartFulfillmentConstraintsGenerateRunResult} CartFulfillmentConstraintsGenerateRunResult
     * @typedef {import("../generated/api").Operation} Operation
     */
    
    /**
     * @param {RunInput} input
     * @returns {CartFulfillmentConstraintsGenerateRunResult}
     */
    export function cartFulfillmentConstraintsGenerateRun(input) {
      // Initialize bundle groups map
      const bundleGroups = new Map();
    
      // Group deliverable lines by their bundle attribute value
      for (const line of input.cart.deliverableLines) {
        if (line.attribute?.key === "bundle" && line.attribute?.value) {
          const bundleValue = line.attribute.value;
          if (!bundleGroups.has(bundleValue)) {
            bundleGroups.set(bundleValue, []);
          }
          bundleGroups.get(bundleValue).push(line.id);
        }
      }
    
      // Create constraints for each bundle group that has more than one item
      const operations = Array.from(bundleGroups.values())
        .filter(group => group.length > 1)
        .map(group => ({
          deliverableLinesMustFulfillFromSameLocationAdd: {
            deliverableLineIds: group
          }
        }));
    
      return { operations };
    }
    Performance Cost (JavaScript)

    234106 instructions

    Output JSON (Rust)
    {
      "operations": [
        {
          "deliverableLinesMustFulfillFromSameLocationAdd": {
            "deliverableLineIds": [
              "gid://shopify/CartLine/1",
              "gid://shopify/CartLine/2"
            ]
          }
        }
      ]
    }
    Output JSON (JavaScript)
    {
      "operations": [
        {
          "deliverableLinesMustFulfillFromSameLocationAdd": {
            "deliverableLineIds": [
              "gid://shopify/CartLine/1",
              "gid://shopify/CartLine/2"
            ]
          }
        }
      ]
    }
  • Require orders of a set size to be fulfilled from warehouses

    This function builds a fulfillment constraint that requires all items to be fulfilled from a warehouse once the cart exceeds a configurable limit of items.

    cart.fulfillment-constraints.generate.run

    Input Query (Rust)
    query Input {
      cart {
        deliverableLines {
          id
        }
      }
      fulfillmentConstraintRule {
        metafield(namespace: "$app:limit", key: "config") {
          value
        }
      }
      locations {
        id
        metafield(namespace: "custom", key: "type") {
          value
        }
      }
    }
    Input Query (JavaScript)
    query RunInput {
      cart {
        deliverableLines {
          id
        }
      }
      fulfillmentConstraintRule {
        metafield(namespace: "$app:limit", key: "config") {
          value
        }
      }
      locations {
        id
        metafield(namespace: "custom", key: "type") {
          value
        }
      }
    }
    Input Object (Rust)
    {
      "cart": {
        "deliverableLines": [
          {
            "id": "gid://shopify/CartLine/1"
          },
          {
            "id": "gid://shopify/CartLine/2"
          },
          {
            "id": "gid://shopify/CartLine/3"
          }
        ]
      },
      "fulfillmentConstraintRule": {
        "metafield": {
          "value": "2"
        }
      },
      "locations": [
        {
          "id": "gid://shopify/Location/1",
          "metafield": {
            "value": "warehouse"
          }
        },
        {
          "id": "gid://shopify/Location/2",
          "metafield": {
            "value": "store"
          }
        }
      ]
    }
    Input Object (JavaScript)
    {
      "cart": {
        "deliverableLines": [
          {
            "id": "gid://shopify/CartLine/1"
          },
          {
            "id": "gid://shopify/CartLine/2"
          },
          {
            "id": "gid://shopify/CartLine/3"
          }
        ]
      },
      "fulfillmentConstraintRule": {
        "metafield": {
          "value": "2"
        }
      },
      "locations": [
        {
          "id": "gid://shopify/Location/1",
          "metafield": {
            "value": "warehouse"
          }
        },
        {
          "id": "gid://shopify/Location/2",
          "metafield": {
            "value": "store"
          }
        }
      ]
    }
    Function Code (Rust)
    use crate::schema;
    use shopify_function::prelude::*;
    use shopify_function::Result;
    
    #[derive(Deserialize, Default, PartialEq)]
    struct Configuration {
        item_limit: i32,
    }
    
    #[shopify_function]
    fn cart_fulfillment_constraints_generate_run(
        input: schema::cart_fulfillment_constraints_generate_run::Input,
    ) -> Result<schema::CartFulfillmentConstraintsGenerateRunResult> {
        // Parse item limit from metafield
        let item_limit: i32 = input
            .fulfillment_constraint_rule()
            .metafield()
            .as_ref()
            .and_then(|metafield| metafield.value().parse().ok())
            .unwrap_or(i32::MAX);
    
        // Check if the cart exceeds the item limit
        let cart_item_count = input.cart().deliverable_lines().len() as i32;
        if cart_item_count <= item_limit {
            return Ok(schema::CartFulfillmentConstraintsGenerateRunResult { operations: vec![] });
        }
    
        // Filter locations that are marked as warehouses
        let warehouse_locations: Vec<String> = input
            .locations()
            .iter()
            .filter(|location| {
                location
                    .metafield()
                    .as_ref()
                    .map_or(false, |m| m.value() == "warehouse")
            })
            .map(|location| location.id().clone())
            .collect();
    
        if warehouse_locations.is_empty() {
            return Ok(schema::CartFulfillmentConstraintsGenerateRunResult { operations: vec![] });
        }
    
        // Create fulfillment constraint
        let operations = vec![schema::Operation::DeliverableLinesMustFulfillFromAdd(
            schema::DeliverableLinesMustFulfillFromAddOperation {
                deliverable_line_ids: Some(
                    input
                        .cart()
                        .deliverable_lines()
                        .iter()
                        .map(|line| line.id().clone())
                        .collect(),
                ),
                location_ids: warehouse_locations,
            },
        )];
    
        Ok(schema::CartFulfillmentConstraintsGenerateRunResult { operations })
    }
    
    
    Performance Cost (Rust)

    44382 instructions

    Function Code (JavaScript)
    // @ts-check
    
    /**
     * @typedef {import("../generated/api").RunInput} RunInput
     * @typedef {import("../generated/api").CartFulfillmentConstraintsGenerateRunResult} CartFulfillmentConstraintsGenerateRunResult
     */
    
    /**
     * @type {CartFulfillmentConstraintsGenerateRunResult}
     */
    const NO_CHANGES = {
      operations: [],
    };
    
    /**
     * @param {RunInput} input
     * @returns {CartFulfillmentConstraintsGenerateRunResult}
     */
    export function cartFulfillmentConstraintsGenerateRun(input) {
      // Parse item limit from metafield
      const itemLimit = parseInt(input.fulfillmentConstraintRule.metafield?.value ?? "Infinity", 10);
    
      // Check if the cart exceeds the item limit
      const cartItemCount = input.cart.deliverableLines.length;
      if (cartItemCount <= itemLimit) {
        return NO_CHANGES;
      }
    
      // Filter locations that are marked as warehouses
      const warehouseLocations = input.locations
        .filter(location => location.metafield?.value === "warehouse")
        .map(location => location.id);
    
      if (warehouseLocations.length === 0) {
        return NO_CHANGES;
      }
    
      // Create fulfillment constraint
      return {
        operations: [
          {
            deliverableLinesMustFulfillFromAdd: {
              deliverableLineIds: input.cart.deliverableLines.map(line => line.id),
              locationIds: warehouseLocations
            }
          }
        ]
      };
    }
    Performance Cost (JavaScript)

    241495 instructions

    Output JSON (Rust)
    {
      "operations": [
        {
          "deliverableLinesMustFulfillFromAdd": {
            "deliverableLineIds": [
              "gid://shopify/CartLine/1",
              "gid://shopify/CartLine/2",
              "gid://shopify/CartLine/3"
            ],
            "locationIds": [
              "gid://shopify/Location/1"
            ]
          }
        }
      ]
    }
    Output JSON (JavaScript)
    {
      "operations": [
        {
          "deliverableLinesMustFulfillFromAdd": {
            "deliverableLineIds": [
              "gid://shopify/CartLine/1",
              "gid://shopify/CartLine/2",
              "gid://shopify/CartLine/3"
            ],
            "locationIds": [
              "gid://shopify/Location/1"
            ]
          }
        }
      ]
    }
  • Prevent orders from being fulfilled at locations that are at capacity

    This function builds a fulfillment constraint that requires all items to be fulfilled from other locations when a location has a metafield that says it's reached capacity.

    cart.fulfillment-constraints.generate.run

    Input Query (Rust)
    query Input {
      cart {
        deliverableLines {
          id
        }
      }
      locations {
        id
        metafield(namespace: "capacity", key: "is_at_capacity") {
          value
        }
      }
    }
    Input Query (JavaScript)
    query RunInput {
      cart {
        deliverableLines {
          id
        }
      }
      locations {
        id
        metafield(namespace: "capacity", key: "is_at_capacity") {
          value
        }
      }
    }
    Input Object (Rust)
    {
      "cart": {
        "deliverableLines": [
          {
            "id": "gid://shopify/CartLine/1"
          },
          {
            "id": "gid://shopify/CartLine/2"
          }
        ]
      },
      "locations": [
        {
          "id": "gid://shopify/Location/1",
          "metafield": {
            "value": "true"
          }
        },
        {
          "id": "gid://shopify/Location/2",
          "metafield": {
            "value": "false"
          }
        }
      ]
    }
    Input Object (JavaScript)
    {
      "cart": {
        "deliverableLines": [
          {
            "id": "gid://shopify/CartLine/1"
          },
          {
            "id": "gid://shopify/CartLine/2"
          }
        ]
      },
      "locations": [
        {
          "id": "gid://shopify/Location/1",
          "metafield": {
            "value": "true"
          }
        },
        {
          "id": "gid://shopify/Location/2",
          "metafield": {
            "value": "false"
          }
        }
      ]
    }
    Function Code (Rust)
    use crate::schema;
    use shopify_function::prelude::*;
    use shopify_function::Result;
    
    #[shopify_function]
    fn cart_fulfillment_constraints_generate_run(
        input: schema::cart_fulfillment_constraints_generate_run::Input,
    ) -> Result<schema::CartFulfillmentConstraintsGenerateRunResult> {
        // Collect all deliverable line IDs
        let deliverable_line_ids: Vec<String> = input
            .cart()
            .deliverable_lines()
            .iter()
            .map(|line| line.id().to_string())
            .collect();
    
        // Find locations that are not at capacity
        let valid_locations: Vec<String> = input
            .locations()
            .iter()
            .filter(|location| {
                location
                    .metafield()
                    .as_ref()
                    .map_or(true, |metafield| metafield.value() != "true")
            })
            .map(|location| location.id().to_string())
            .collect();
    
        // If no valid locations are available, return no constraints
        if valid_locations.is_empty() {
            return Ok(schema::CartFulfillmentConstraintsGenerateRunResult { operations: vec![] });
        }
    
        // Create the fulfillment constraint
        let operations = vec![schema::Operation::DeliverableLinesMustFulfillFromAdd(
            schema::DeliverableLinesMustFulfillFromAddOperation {
                deliverable_line_ids: Some(deliverable_line_ids),
                location_ids: valid_locations,
            },
        )];
    
        Ok(schema::CartFulfillmentConstraintsGenerateRunResult { operations })
    }
    
    
    Performance Cost (Rust)

    36030 instructions

    Function Code (JavaScript)
    // @ts-check
    
    /**
     * @typedef {import("../generated/api").RunInput} RunInput
     * @typedef {import("../generated/api").CartFulfillmentConstraintsGenerateRunResult} CartFulfillmentConstraintsGenerateRunResult
     */
    
    /**
     * @type {CartFulfillmentConstraintsGenerateRunResult}
     */
    const NO_CHANGES = {
      operations: [],
    };
    
    /**
     * @param {RunInput} input
     * @returns {CartFulfillmentConstraintsGenerateRunResult}
     */
    export function cartFulfillmentConstraintsGenerateRun(input) {
      // Collect all deliverable line IDs
      const deliverableLineIds = input.cart.deliverableLines.map(line => line.id);
    
      // Find locations that are not at capacity
      const validLocations = input.locations
        .filter(location => !location.metafield || location.metafield.value !== "true")
        .map(location => location.id);
    
      // If no valid locations are available, return no constraints
      if (validLocations.length === 0) {
        return NO_CHANGES;
      }
    
      // Create the fulfillment constraint
      return {
        operations: [
          {
            deliverableLinesMustFulfillFromAdd: {
              deliverableLineIds,
              locationIds: validLocations
            }
          }
        ]
      };
    }
    Performance Cost (JavaScript)

    210384 instructions

    Output JSON (Rust)
    {
      "operations": [
        {
          "deliverableLinesMustFulfillFromAdd": {
            "deliverableLineIds": [
              "gid://shopify/CartLine/1",
              "gid://shopify/CartLine/2"
            ],
            "locationIds": [
              "gid://shopify/Location/2"
            ]
          }
        }
      ]
    }
    Output JSON (JavaScript)
    {
      "operations": [
        {
          "deliverableLinesMustFulfillFromAdd": {
            "deliverableLineIds": [
              "gid://shopify/CartLine/1",
              "gid://shopify/CartLine/2"
            ],
            "locationIds": [
              "gid://shopify/Location/2"
            ]
          }
        }
      ]
    }
  • Prevent discounted items from being fulfilled at retail locations.

    This function removes retail locations from the fulfillment options if the cart has discounted items. Retail locations are identified by the location_type metafield having the value retail.

    cart.fulfillment-constraints.generate.run

    Input Query (Rust)
    query Input {
      cart {
        deliverableLines {
          id
        }
        lines {
          id
          cost {
            amountPerQuantity {
              amount
            }
            compareAtAmountPerQuantity {
              amount
            }
          }
        }
      }
      locations {
        id
        metafield(namespace: "custom", key: "location_type") {
          value
        }
      }
    }
    Input Query (JavaScript)
    query RunInput {
      cart {
        deliverableLines {
          id
        }
        lines {
          id
          cost {
            amountPerQuantity {
              amount
            }
            compareAtAmountPerQuantity {
              amount
            }
          }
        }
      }
      locations {
        id
        metafield(namespace: "custom", key: "location_type") {
          value
        }
      }
    }
    Input Object (Rust)
    {
      "cart": {
        "deliverableLines": [
          {
            "id": "gid://shopify/DeliverableCartLine/1"
          },
          {
            "id": "gid://shopify/DeliverableCartLine/2"
          }
        ],
        "lines": [
          {
            "id": "gid://shopify/CartLine/1",
            "cost": {
              "amountPerQuantity": {
                "amount": "20.00"
              },
              "compareAtAmountPerQuantity": {
                "amount": "25.00"
              }
            }
          },
          {
            "id": "gid://shopify/CartLine/2",
            "cost": {
              "amountPerQuantity": {
                "amount": "30.00"
              },
              "compareAtAmountPerQuantity": {
                "amount": "30.00"
              }
            }
          }
        ]
      },
      "locations": [
        {
          "id": "gid://shopify/Location/1",
          "metafield": {
            "value": "retail"
          }
        },
        {
          "id": "gid://shopify/Location/2",
          "metafield": {
            "value": "warehouse"
          }
        }
      ]
    }
    Input Object (JavaScript)
    {
      "cart": {
        "deliverableLines": [
          {
            "id": "gid://shopify/DeliverableCartLine/1"
          },
          {
            "id": "gid://shopify/DeliverableCartLine/2"
          }
        ],
        "lines": [
          {
            "id": "gid://shopify/CartLine/1",
            "cost": {
              "amountPerQuantity": {
                "amount": "20.00"
              },
              "compareAtAmountPerQuantity": {
                "amount": "25.00"
              }
            }
          },
          {
            "id": "gid://shopify/CartLine/2",
            "cost": {
              "amountPerQuantity": {
                "amount": "30.00"
              },
              "compareAtAmountPerQuantity": {
                "amount": "30.00"
              }
            }
          }
        ]
      },
      "locations": [
        {
          "id": "gid://shopify/Location/1",
          "metafield": {
            "value": "retail"
          }
        },
        {
          "id": "gid://shopify/Location/2",
          "metafield": {
            "value": "warehouse"
          }
        }
      ]
    }
    Function Code (Rust)
    use crate::schema;
    use shopify_function::prelude::*;
    use shopify_function::Result;
    
    #[shopify_function]
    fn cart_fulfillment_constraints_generate_run(
        input: schema::cart_fulfillment_constraints_generate_run::Input,
    ) -> Result<schema::CartFulfillmentConstraintsGenerateRunResult> {
        // Create a map of line IDs to their cost details
        let line_cost_map: std::collections::HashMap<
            String,
            &schema::cart_fulfillment_constraints_generate_run::input::cart::Lines,
        > = input
            .cart()
            .lines()
            .iter()
            .map(|line| {
                let id = line.id().split('/').last().unwrap_or("").to_string();
                (id, line)
            })
            .collect();
    
        // Check if any deliverable line has a discount
        let has_discounted_items = input
            .cart()
            .deliverable_lines()
            .iter()
            .any(|deliverable_line| {
                let id = deliverable_line
                    .id()
                    .split('/')
                    .last()
                    .unwrap_or("")
                    .to_string();
                if let Some(line) = line_cost_map.get(&id) {
                    line.cost()
                        .compare_at_amount_per_quantity()
                        .map_or(false, |compare_at| {
                            compare_at
                                .amount()
                                .gt(&line.cost().amount_per_quantity().amount())
                        })
                } else {
                    false
                }
            });
    
        if !has_discounted_items {
            return Ok(schema::CartFulfillmentConstraintsGenerateRunResult { operations: vec![] });
        }
    
        // Filter out retail locations
        let non_retail_locations: Vec<String> = input
            .locations()
            .iter()
            .filter(|location| {
                location
                    .metafield()
                    .map_or(true, |metafield| metafield.value() != "retail")
            })
            .map(|location| location.id().to_string())
            .collect();
    
        if non_retail_locations.is_empty() {
            return Ok(schema::CartFulfillmentConstraintsGenerateRunResult { operations: vec![] });
        }
    
        // Create fulfillment constraint
        let operations = vec![schema::Operation::DeliverableLinesMustFulfillFromAdd(
            schema::DeliverableLinesMustFulfillFromAddOperation {
                deliverable_line_ids: Some(
                    input
                        .cart()
                        .deliverable_lines()
                        .iter()
                        .map(|line| line.id().to_string())
                        .collect(),
                ),
                location_ids: non_retail_locations,
            },
        )];
    
        Ok(schema::CartFulfillmentConstraintsGenerateRunResult { operations })
    }
    
    
    Performance Cost (Rust)

    63503 instructions

    Function Code (JavaScript)
    // @ts-check
    
    /**
     * @typedef {import("../generated/api").RunInput} RunInput
     * @typedef {import("../generated/api").CartFulfillmentConstraintsGenerateRunResult} CartFulfillmentConstraintsGenerateRunResult
     */
    
    /**
     * @type {CartFulfillmentConstraintsGenerateRunResult}
     */
    const NO_CHANGES = {
      operations: [],
    };
    
    /**
     * @param {RunInput} input
     * @returns {CartFulfillmentConstraintsGenerateRunResult}
     */
    export function cartFulfillmentConstraintsGenerateRun(input) {
      // Create a map of line IDs to their cost details
      const lineCostMap = new Map(
        input.cart.lines.map(line => [
          line.id.split('/').pop() || '',
          line
        ])
      );
    
      // Check if any deliverable line has a discount
      const hasDiscountedItems = input.cart.deliverableLines.some(deliverableLine => {
        const id = deliverableLine.id.split('/').pop() || '';
        const line = lineCostMap.get(id);
        if (!line) return false;
    
        const compareAtAmount = line.cost.compareAtAmountPerQuantity?.amount;
        const currentAmount = line.cost.amountPerQuantity.amount;
        return compareAtAmount && parseFloat(compareAtAmount) > parseFloat(currentAmount);
      });
    
      if (!hasDiscountedItems) {
        return NO_CHANGES;
      }
    
      // Filter out retail locations
      const nonRetailLocations = input.locations
        .filter(location => !location.metafield?.value || location.metafield.value !== 'retail')
        .map(location => location.id);
    
      if (nonRetailLocations.length === 0) {
        return NO_CHANGES;
      }
    
      // Create fulfillment constraint
      return {
        operations: [{
          deliverableLinesMustFulfillFromAdd: {
            deliverableLineIds: input.cart.deliverableLines.map(line => line.id),
            locationIds: nonRetailLocations
          }
        }]
      };
    }
    Performance Cost (JavaScript)

    363041 instructions

    Output JSON (Rust)
    {
      "operations": [
        {
          "deliverableLinesMustFulfillFromAdd": {
            "deliverableLineIds": [
              "gid://shopify/DeliverableCartLine/1",
              "gid://shopify/DeliverableCartLine/2"
            ],
            "locationIds": [
              "gid://shopify/Location/2"
            ]
          }
        }
      ]
    }
    Output JSON (JavaScript)
    {
      "operations": [
        {
          "deliverableLinesMustFulfillFromAdd": {
            "deliverableLineIds": [
              "gid://shopify/DeliverableCartLine/1",
              "gid://shopify/DeliverableCartLine/2"
            ],
            "locationIds": [
              "gid://shopify/Location/2"
            ]
          }
        }
      ]
    }
  • Restrict fulfillment to equipped locations

    This function checks if an item has a line item attribute that is customized and if so, it checks if the item is being shipped from a location that has the required equipment based on a location metafield

    cart.fulfillment-constraints.generate.run

    Input Query (Rust)
    query Input {
      cart {
        deliverableLines {
          id
          merchandise {
            __typename
            ... on ProductVariant {
              id
              __typename
            }
          }
          attribute(key: "customized") {
            key
            value
          }
        }
      }
      locations {
        id
        metafield(namespace: "custom_equipment", key: "has_required_equipment") {
          value
        }
      }
    }
    Input Query (JavaScript)
    query RunInput {
      cart {
        deliverableLines {
          id
          merchandise {
            __typename
            ... on ProductVariant {
              id
              __typename
            }
          }
          attribute(key: "customized") {
            key
            value
          }
        }
      }
      locations {
        id
        metafield(namespace: "custom_equipment", key: "has_required_equipment") {
          value
        }
      }
    }
    Input Object (Rust)
    {
      "cart": {
        "deliverableLines": [
          {
            "id": "gid://shopify/CartLine/1",
            "merchandise": {
              "__typename": "ProductVariant",
              "id": "gid://shopify/ProductVariant/123"
            },
            "attribute": {
              "key": "customized",
              "value": "true"
            }
          },
          {
            "id": "gid://shopify/CartLine/2",
            "merchandise": {
              "__typename": "ProductVariant",
              "id": "gid://shopify/ProductVariant/456"
            },
            "attribute": null
          }
        ]
      },
      "locations": [
        {
          "id": "gid://shopify/Location/1",
          "metafield": {
            "value": "true"
          }
        }
      ]
    }
    Input Object (JavaScript)
    {
      "cart": {
        "deliverableLines": [
          {
            "id": "gid://shopify/CartLine/1",
            "merchandise": {
              "__typename": "ProductVariant",
              "id": "gid://shopify/ProductVariant/123"
            },
            "attribute": {
              "key": "customized",
              "value": "true"
            }
          },
          {
            "id": "gid://shopify/CartLine/2",
            "merchandise": {
              "__typename": "ProductVariant",
              "id": "gid://shopify/ProductVariant/456"
            },
            "attribute": null
          }
        ]
      },
      "locations": [
        {
          "id": "gid://shopify/Location/1",
          "metafield": {
            "value": "true"
          }
        }
      ]
    }
    Function Code (Rust)
    use crate::schema;
    use shopify_function::prelude::*;
    use shopify_function::Result;
    
    #[shopify_function]
    fn cart_fulfillment_constraints_generate_run(
        input: schema::cart_fulfillment_constraints_generate_run::Input,
    ) -> Result<schema::CartFulfillmentConstraintsGenerateRunResult> {
        let mut customized_line_ids = Vec::new();
    
        // Find cart lines that are marked as customized
        for line in input.cart().deliverable_lines().iter() {
            let is_customized = line.attribute().as_ref().map_or(false, |attr| {
                attr.key() == "customized" && attr.value().as_ref().map_or(false, |v| *v == "true")
            });
    
            if is_customized {
                customized_line_ids.push(line.id().clone());
            }
        }
    
        // Return early if no customized items
        if customized_line_ids.is_empty() {
            return Ok(no_fulfillment_constraints_result());
        }
    
        // Find locations with required equipment
        let valid_locations: Vec<_> = input
            .locations()
            .iter()
            .filter(|location| {
                location
                    .metafield()
                    .as_ref()
                    .map_or(false, |m| m.value() == "true")
            })
            .collect();
    
        // Return early if no valid locations
        if valid_locations.is_empty() {
            return Ok(no_fulfillment_constraints_result());
        }
    
        // Create the fulfillment constraint
        let operations = vec![must_fulfill_from_operation(
            customized_line_ids,
            valid_locations.iter().map(|l| l.id().clone()).collect(),
        )];
    
        Ok(schema::CartFulfillmentConstraintsGenerateRunResult { operations })
    }
    
    fn must_fulfill_from_operation(
        deliverable_line_ids: Vec<String>,
        location_ids: Vec<String>,
    ) -> schema::Operation {
        schema::Operation::DeliverableLinesMustFulfillFromAdd(
            schema::DeliverableLinesMustFulfillFromAddOperation {
                deliverable_line_ids: Some(deliverable_line_ids),
                location_ids,
            },
        )
    }
    
    fn no_fulfillment_constraints_result() -> schema::CartFulfillmentConstraintsGenerateRunResult {
        schema::CartFulfillmentConstraintsGenerateRunResult { operations: vec![] }
    }
    
    
    Performance Cost (Rust)

    42384 instructions

    Function Code (JavaScript)
    // @ts-check
    
    /**
     * @typedef {import("../generated/api").RunInput} RunInput
     * @typedef {import("../generated/api").CartFulfillmentConstraintsGenerateRunResult} CartFulfillmentConstraintsGenerateRunResult
     */
    
    /**
     * @type {CartFulfillmentConstraintsGenerateRunResult}
     */
    const NO_CHANGES = {
      operations: [],
    };
    
    /**
     * @param {RunInput} input
     * @returns {CartFulfillmentConstraintsGenerateRunResult}
     */
    export function cartFulfillmentConstraintsGenerateRun(input) {
      // Find cart lines that are marked as customized
      const customizedLineIds = input.cart.deliverableLines
        .filter(line => line.attribute?.key === "customized" && line.attribute?.value === "true")
        .map(line => line.id);
    
      // Return early if no customized items
      if (customizedLineIds.length === 0) {
        return NO_CHANGES;
      }
    
      // Find locations with required equipment
      const validLocations = input.locations
        .filter(location => location.metafield?.value === "true")
        .map(location => location.id);
    
      // Return early if no valid locations
      if (validLocations.length === 0) {
        return NO_CHANGES;
      }
    
      // Create the fulfillment constraint
      return {
        operations: [
          {
            deliverableLinesMustFulfillFromAdd: {
              deliverableLineIds: customizedLineIds,
              locationIds: validLocations
            }
          }
        ]
      };
    };
    Performance Cost (JavaScript)

    246123 instructions

    Output JSON (Rust)
    {
      "operations": [
        {
          "deliverableLinesMustFulfillFromAdd": {
            "deliverableLineIds": [
              "gid://shopify/CartLine/1"
            ],
            "locationIds": [
              "gid://shopify/Location/1"
            ]
          }
        }
      ]
    }
    Output JSON (JavaScript)
    {
      "operations": [
        {
          "deliverableLinesMustFulfillFromAdd": {
            "deliverableLineIds": [
              "gid://shopify/CartLine/1"
            ],
            "locationIds": [
              "gid://shopify/Location/1"
            ]
          }
        }
      ]
    }
  • Fulfill orders from VIP customers from designated locations.

    This function checks if a customer is a VIP and if so, it checks if the item is being shipped from a location that has a specific metafield value to fulfill VIP orders

    cart.fulfillment-constraints.generate.run

    Input Query (Rust)
    query Input($vipTag: String! = "VIP") {
      cart {
        buyerIdentity {
          customer {
            hasTags(tags: [$vipTag]) {
              hasTag
            }
          }
        }
        deliverableLines {
          id
        }
      }
      locations {
        id
        metafield(namespace: "vip_fulfillment", key: "is_vip_location") {
          value
        }
      }
    }
    Input Query (JavaScript)
    query RunInput($vipTag: String! = "VIP") {
      cart {
        buyerIdentity {
          customer {
            hasTags(tags: [$vipTag]) {
              hasTag
            }
          }
        }
        deliverableLines {
          id
        }
      }
      locations {
        id
        metafield(namespace: "vip_fulfillment", key: "is_vip_location") {
          value
        }
      }
    }
    Input Object (Rust)
    {
      "cart": {
        "buyerIdentity": {
          "customer": {
            "hasTags": [
              {
                "hasTag": true
              }
            ]
          }
        },
        "deliverableLines": [
          {
            "id": "gid://shopify/CartLine/1"
          },
          {
            "id": "gid://shopify/CartLine/2"
          }
        ]
      },
      "locations": [
        {
          "id": "gid://shopify/Location/1",
          "metafield": {
            "value": "true"
          }
        },
        {
          "id": "gid://shopify/Location/2",
          "metafield": null
        }
      ]
    }
    Input Object (JavaScript)
    {
      "cart": {
        "buyerIdentity": {
          "customer": {
            "hasTags": [
              {
                "hasTag": true
              }
            ]
          }
        },
        "deliverableLines": [
          {
            "id": "gid://shopify/CartLine/1"
          },
          {
            "id": "gid://shopify/CartLine/2"
          }
        ]
      },
      "locations": [
        {
          "id": "gid://shopify/Location/1",
          "metafield": {
            "value": "true"
          }
        },
        {
          "id": "gid://shopify/Location/2",
          "metafield": null
        }
      ]
    }
    Function Code (Rust)
    use crate::schema;
    use shopify_function::prelude::*;
    use shopify_function::Result;
    
    #[shopify_function]
    fn cart_fulfillment_constraints_generate_run(
        input: schema::cart_fulfillment_constraints_generate_run::Input,
    ) -> Result<schema::CartFulfillmentConstraintsGenerateRunResult> {
        // Check if the customer is a VIP
        let is_vip = input
            .cart()
            .buyer_identity()
            .and_then(|identity| identity.customer())
            .and_then(|customer| customer.has_tags().first())
            .map_or(false, |tag| *tag.has_tag());
    
        if !is_vip {
            return Ok(no_fulfillment_constraints_result());
        }
    
        // Collect all deliverable line IDs
        let deliverable_line_ids: Vec<String> = input
            .cart()
            .deliverable_lines()
            .iter()
            .map(|line| line.id().clone())
            .collect();
    
        // Find locations with the required metafield value
        let valid_locations: Vec<String> = input
            .locations()
            .iter()
            .filter(|location| {
                location
                    .metafield()
                    .as_ref()
                    .map_or(false, |metafield| metafield.value() == "true")
            })
            .map(|location| location.id().clone())
            .collect();
    
        if valid_locations.is_empty() {
            return Ok(no_fulfillment_constraints_result());
        }
    
        // Create the fulfillment constraint
        let operations = vec![must_fulfill_from_operation(
            deliverable_line_ids,
            valid_locations,
        )];
    
        Ok(schema::CartFulfillmentConstraintsGenerateRunResult { operations })
    }
    
    fn must_fulfill_from_operation(
        deliverable_line_ids: Vec<String>,
        location_ids: Vec<String>,
    ) -> schema::Operation {
        schema::Operation::DeliverableLinesMustFulfillFromAdd(
            schema::DeliverableLinesMustFulfillFromAddOperation {
                deliverable_line_ids: Some(deliverable_line_ids),
                location_ids,
            },
        )
    }
    
    fn no_fulfillment_constraints_result() -> schema::CartFulfillmentConstraintsGenerateRunResult {
        schema::CartFulfillmentConstraintsGenerateRunResult { operations: vec![] }
    }
    
    
    Performance Cost (Rust)

    41412 instructions

    Function Code (JavaScript)
    // @ts-check
    
    /**
     * @typedef {import("../generated/api").RunInput} RunInput
     * @typedef {import("../generated/api").CartFulfillmentConstraintsGenerateRunResult} CartFulfillmentConstraintsGenerateRunResult
     * @typedef {import("../generated/api").Operation} Operation
     */
    
    /**
     * @type {CartFulfillmentConstraintsGenerateRunResult}
     */
    const NO_CHANGES = {
      operations: [],
    };
    
    /**
     * Creates a DeliverableLinesMustFulfillFromAdd operation with the specified line and location IDs
     * @param {string[]} deliverableLineIds
     * @param {string[]} locationIds
     * @returns {Operation}
     */
    function createMustFulfillFromOperation(deliverableLineIds, locationIds) {
      return {
        deliverableLinesMustFulfillFromAdd: {
          deliverableLineIds,
          locationIds
        }
      };
    }
    
    /**
     * @param {RunInput} input
     * @returns {CartFulfillmentConstraintsGenerateRunResult}
     */
    export function cartFulfillmentConstraintsGenerateRun(input) {
      // Check if the customer is a VIP
      const isVip = input.cart?.buyerIdentity?.customer?.hasTags?.[0]?.hasTag ?? false;
    
      if (!isVip) {
        return NO_CHANGES;
      }
    
      // Collect all deliverable line IDs
      const deliverableLineIds = input.cart.deliverableLines.map(line => line.id);
    
      // Find locations with the required metafield value
      const validLocations = input.locations
        .filter(location => location.metafield?.value === "true")
        .map(location => location.id);
    
      if (validLocations.length === 0) {
        return NO_CHANGES;
      }
    
      // Create the fulfillment constraint
      return {
        operations: [
          createMustFulfillFromOperation(deliverableLineIds, validLocations)
        ]
      };
    }
    Performance Cost (JavaScript)

    238174 instructions

    Output JSON (Rust)
    {
      "operations": [
        {
          "deliverableLinesMustFulfillFromAdd": {
            "deliverableLineIds": [
              "gid://shopify/CartLine/1",
              "gid://shopify/CartLine/2"
            ],
            "locationIds": [
              "gid://shopify/Location/1"
            ]
          }
        }
      ]
    }
    Output JSON (JavaScript)
    {
      "operations": [
        {
          "deliverableLinesMustFulfillFromAdd": {
            "deliverableLineIds": [
              "gid://shopify/CartLine/1",
              "gid://shopify/CartLine/2"
            ],
            "locationIds": [
              "gid://shopify/Location/1"
            ]
          }
        }
      ]
    }

Input query

query Input {
cart {
cost {
subtotalAmount {
amount
currencyCode
}
}
deliverableLines {
id
}
}
fulfillmentConstraintRule {
metafield(namespace: "$app:fulfillment-constraints", key: "configuration") {
jsonValue
}
}
}

Input object (response)

JSON
{
"cart": {
"cost": {
"subtotalAmount": {
"amount": "49.99",
"currencyCode": "USD"
}
},
"deliverableLines": [
{
"id": "gid://shopify/CartLine/1"
},
{
"id": "gid://shopify/CartLine/2"
}
]
},
"fulfillmentConstraintRule": {
"metafield": {
"jsonValue": {
"threshold": 50.0
}
}
}
}

Function code

use crate::schema;
use shopify_function::prelude::*;
use shopify_function::Result;

#[derive(Deserialize, Default, PartialEq)]
pub struct Configuration {
threshold: f64,
}

#[shopify_function]
fn cart_fulfillment_constraints_generate_run(
input: schema::cart_fulfillment_constraints_generate_run::Input,
) -> Result<schema::CartFulfillmentConstraintsGenerateRunResult> {
// Parse configuration from metafield
let config = match input.fulfillment_constraint_rule().metafield() {
Some(metafield) => metafield.json_value(),
None => &Configuration::default(),
};

// Get the cart subtotal and convert threshold to Decimal
let subtotal = input.cart().cost().subtotal_amount().amount();
let threshold = Decimal::from(config.threshold);

// If the subtotal is below the threshold, prevent splitting
if subtotal.lt(&threshold) {
let deliverable_line_ids: Vec<String> = input
.cart()
.deliverable_lines()
.iter()
.map(|line| line.id().clone())
.collect();

let operations = vec![
schema::Operation::DeliverableLinesMustFulfillFromSameLocationAdd(
schema::DeliverableLinesMustFulfillFromSameLocationAddOperation {
deliverable_line_ids: Some(deliverable_line_ids),
},
),
];

return Ok(schema::CartFulfillmentConstraintsGenerateRunResult { operations });
}

// No constraints if the subtotal is above the threshold
Ok(schema::CartFulfillmentConstraintsGenerateRunResult { operations: vec![] })
}

Function run result

JSON

Anchor to Location fulfillment rulesLocation fulfillment rules

You can fulfill specific items in a cart from any of the locations in a list, as long as all items come from the same location to avoid splitting orders.


Anchor to Delivery method typesDelivery method types

You can associate fulfillment constraint functions with one or more delivery method types. Customized constraint types aren't currently supported.

Note

Checkouts and orders can include multiple delivery methods, such as shipping and pickup in the same order. When your app uses delivery or fulfillment data, iterate over all delivery groups or fulfillment orders to determine the delivery method for each one. Don't assume one method for the order. For more information, refer to split carts in checkout.


The Function's title and description are merchant-facing values, and are rendered as part of the user interface in the Shopify admin settings under Shipping and delivery > Order routing.


Anchor to Additional resourcesAdditional resources

Explore comprehensive guides and references to help you build, deploy, and optimize your Shopify Functions.

Anchor to Working with FunctionsWorking with Functions

These guides cover essential concepts for building Shopify Functions effectively. Learn how functions process data, execute during checkout, and handle versioning, localization, and external APIs.

Anchor to Performance and troubleshootingPerformance and troubleshooting

Optimize function performance and ensure reliable operation from development through production deployment.


Was this page helpful?