Create and manage deferred purchase options
You can create purchase options using the GraphQL Admin API's sellingPlanGroupCreate
mutation. This guide describes the requirements for creating deferred purchase options and shows you how to create and manage deferred purchase options using the GraphQL Admin API mutations.
What you'll learn
Anchor link to section titled "What you'll learn"In this tutorial, you'll learn how to do the following tasks:
- Using the
sellingPlanGroupCreate
mutation, create the following purchase options:- Pre-order
- Try before you buy
- Configure policies required for deferred purchase options
- Manage the purchase options
Requirements
Anchor link to section titled "Requirements"- Familiarize yourself with purchase options and deferred purchase options.
- Complete the Getting started with the GraphQL Admin and REST Admin APIs guide and you're authenticated with the API.
- Create products and product variants in your development store.
- The merchant you're developing for meets the qualifying criteria.
Access scopes
Anchor link to section titled "Access scopes"Your app requires the following access scopes:
write_products
read_all_orders
read_customer_payment_methods
read_purchase_options
write_purchase_options
read_payment_mandate
write_payment_mandate
Step 1: Create deferred purchase options
Anchor link to section titled "Step 1: Create deferred purchase options"Create pre-order and try before you buy purchase options using the sellingPlanGroupCreate
mutation. The SellingPlanGroup
object includes one or more SellingPlan
objects. The SellingPlan
object specifies how a product can be sold.
Learn more about GraphQL Admin API objects for purchase options. For more information on input fields and values, refer to the following resources:
Create a pre-order purchase option with a selling plan (SellingPlan
) that contains the following policies:
- Billing (
billingPolicy.fixed
): The 20% of the total amount will be charged as a deposit at checkout. The remaining amount will be charged on 2022-07-24. - Delivery (
deliveryPolicy.fixed
): The fulfillment timeline is unknown. - Pricing (
pricingPolicies.fixed
): A 15% product reduction is applied to the variant. - Inventory (
inventoryPolicy.reserve
): The inventory will be updated when the order is fulfilled.
The category
field should be set to PRE_ORDER
.
Request: POST /admin/api/2022-07.json
View response
JSON response:
Create a try before you buy with a selling plan (SellingPlan
) that contains the following policies:
- Billing (
billingPolicy.fixed
): There's no deposit. The full amount will be charged 14 days after checkout. TheremainingBalanceChargeTimeAfterCheckout
value must be in ISO 8601 duration format (P14D
). - Delivery (
deliveryPolicy.fixed
): The product will be fulfilled as soon as possible. - Inventory (
inventoryPolicy.reserve
): The inventory will be updated when the order is created.
The category
field should be set to TRY_BEFORE_YOU_BUY
.
Request: POST /admin/api/2022-07.json
View response
JSON response:
Step 2: Manage deferred purchase options (Optional)
Anchor link to section titled "Step 2: Manage deferred purchase options (Optional)"Associate a purchase option to a product or product variant
Anchor link to section titled "Associate a purchase option to a product or product variant"You can use the sellingPlanGroupAddProducts
mutation or the sellingPlanGroupAddProductVariants
mutation to make a separate request to associate a purchase option with a product or product variant, without having to delete and recreate the purchase option.
Associate multiple purchase options to a product or product variant
Anchor link to section titled "Associate multiple purchase options to a product or product variant"You can use the productJoinSellingPlanGroups
mutation or the productVariantJoinSellingPlanGroups
mutation to associate multiple purchase options to a product or product variant.
Edit a purchase option
Anchor link to section titled "Edit a purchase option"You can use the sellingPlanGroupUpdate
mutation to edit the attributes associated with a purchase option. For example, you can change the purchase option's name
.