Shopify Storefront API Selling Plans: Price Each Variant

To show Shopify Storefront API selling plans on a headless product page, read two fields. product.sellingPlanGroups supplies the names for the picker. The selected variant’s sellingPlanAllocations says which of those plans that variant can be bought with and what each one costs, already worked out by Shopify. The chosen plan’s ID then goes on the cart line as sellingPlanId.

Everything here was written against Storefront API 2026-10, the version shopify.dev’s latest alias pointed at in December 2026. The two GraphQL documents validate against that schema, and the helper was run on hand-written data in the schema’s shape. None of it has been run against a store.

What does the token need first?

One extra scope. Each selling plan type page we read in the reference opens with the same line: “Requires unauthenticated_read_selling_plans access scope.” Shopify’s access scopes list describes it as “Selling plan content on Product”. On the Headless channel you grant it from the Storefront API permissions card of a storefront, and the Headless channel guide cautions that those permissions are shared across all storefronts.

We did not provoke a missing-scope response for these fields. Our post on public and private Storefront tokens shows one for quantityAvailable: status 200, with an error entry that names the scope. So check errors even when the request succeeds.

The plans themselves are created elsewhere. A subscriptions app writes the selling plan groups through the Admin API, and we covered that half, including who charges the card on renewal day, in the Admin side of selling plans.

Which Shopify Storefront API selling plans fields do you query?

Three types matter. A SellingPlanGroup is the offer as the merchant named it, “Subscribe and save” for instance. It holds SellingPlan records, one per choice, each with an id, a name, options such as “Delivery every” with the value “2 weeks”, and a recurringDeliveries flag. A SellingPlanAllocation is one variant paired with one plan, and it carries the prices that result.

query ProductPlans($handle: String!, $selectedOptions: [SelectedOptionInput!]) {
  product(handle: $handle) {
    requiresSellingPlan
    sellingPlanGroups(first: 10) {
      nodes {
        name
        sellingPlans(first: 20) {
          nodes {
            id
            name
            recurringDeliveries
            options { name value }
            priceAdjustments { orderCount }
          }
        }
      }
    }
    selectedOrFirstAvailableVariant(selectedOptions: $selectedOptions) {
      id
      price { amount currencyCode }
      sellingPlanAllocations(first: 20) {
        nodes {
          sellingPlan { id }
          checkoutChargeAmount { amount currencyCode }
          remainingBalanceChargeAmount { amount currencyCode }
          priceAdjustments {
            price { amount currencyCode }
            compareAtPrice { amount currencyCode }
            perDeliveryPrice { amount currencyCode }
          }
        }
      }
    }
  }
}

The group has no id in the Storefront schema. It has appName, name, options and sellingPlans, so key the interface on plan IDs.

The query also asks for one variant, through selectedOrFirstAvailableVariant, instead of the whole variants list. Allocations are a connection inside each variant, so asking for them on every variant of a large product multiplies the response for prices nobody is looking at. The first values are our guess at a ceiling. Each connection has pageInfo if a catalogue outgrows them.

Why build the picker from the variant?

Because the product’s list covers every variant, and the shopper is buying one. The reference describes sellingPlanGroups as the groups “associated with the product either directly, or through the product’s variants”. Read literally, a group attached to a single variant still shows up on the product, beside variants it does not apply to. The variant’s allocations are the list specific to the thing about to go in the cart.

So the helper takes names and order from the groups, and keeps a plan only when the variant has an allocation for it:

const amount = (money) => Number(money.amount);

export function planChoices(product) {
  const variant = product.selectedOrFirstAvailableVariant;
  const allocations = new Map(
    variant.sellingPlanAllocations.nodes.map((a) => [a.sellingPlan.id, a]),
  );

  const groups = product.sellingPlanGroups.nodes
    .map((group) => ({
      name: group.name,
      plans: group.sellingPlans.nodes
        .filter((plan) => allocations.has(plan.id))
        .map((plan) => {
          const allocation = allocations.get(plan.id);
          const [first, later] = allocation.priceAdjustments;
          const withoutPlan = amount(first.compareAtPrice);
          return {
            sellingPlanId: plan.id,
            label: plan.options.map((o) => o.value).join(', ') || plan.name,
            recurring: plan.recurringDeliveries,
            perDelivery: first.perDeliveryPrice,
            dueToday: allocation.checkoutChargeAmount,
            dueLater: allocation.remainingBalanceChargeAmount,
            savingPercent: withoutPlan
              ? Math.round((1 - amount(first.price) / withoutPlan) * 100)
              : 0,
            later: later
              ? {
                  perDelivery: later.perDeliveryPrice,
                  afterOrders: plan.priceAdjustments[0]?.orderCount ?? null,
                }
              : null,
          };
        }),
    }))
    .filter((group) => group.plans.length > 0);

  return { oneTimeAllowed: !product.requiresSellingPlan, groups };
}

We ran it on sample data with two variants, where a “Prepaid” group applies to the larger one only. It returned one group for the smaller variant and two for the larger. A variant with no allocations returned no groups, which is the cue to render a plain Add to cart. oneTimeAllowed comes from requiresSellingPlan: when that is true, there is no one-time purchase to offer.

One caution about that field. Its description says a product made subscription-only “is unpublished from all channels, except the online store”. We have not tested what that means for a Headless channel or custom app token. Query a subscription-only product with your own token before designing a page around it.

Which price do you show?

Each allocation has priceAdjustments, a list of at most two entries, each holding four prices. Whatever the field name suggests, these are finished prices, and the reference for the type defines them with a worked example.

price is what the buyer pays for the purchase. On a prepaid plan that is the whole prepayment: six deliveries of 10.00 granola at 20% off comes to 48.00. perDeliveryPrice divides it back down to 8.00. compareAtPrice is the same number of deliveries bought without a plan, 60.00 here. unitPrice is null unless the variant is sold by quantity or measurement.

That makes perDeliveryPrice the figure to put beside each option, since it is the one that compares fairly between a prepaid plan and a pay-per-delivery one.

It also means the allocation’s compareAtPrice is a different thing from the variant’s compareAtPrice. On the variant, the field marks a sale: the reference says it “can be used to mark a variant as on sale”. On the allocation, it is the variant’s price multiplied by the deliveries. Feed the wrong one to a strikethrough component and it prints the wrong figure.

When the list has two entries, the first applies at the time of purchase and the second starts after a certain number of orders. That number is orderCount on the plan’s own priceAdjustments, which is why the query asks for it. The plan-level list also carries the rule itself (adjustmentPercentage, adjustmentAmount or a fixed price), but the allocation already holds the result for this variant. The only arithmetic in the helper is the saving badge, worked out from two prices Shopify supplied.

checkoutChargeAmount and remainingBalanceChargeAmount are described as the charge due at checkout and the remaining balance due for the purchase. Selling plans also model pre-orders and try-before-you-buy, so do not assume the second is zero. The helper passes both through.

How does the plan reach the cart?

As one more field on the line. CartLineInput takes an optional sellingPlanId beside merchandiseId and quantity, for cartCreate and cartLinesAdd alike.

mutation AddSubscriptionLine($cartId: ID!, $lines: [CartLineInput!]!) {
  cartLinesAdd(cartId: $cartId, lines: $lines) {
    cart {
      lines(first: 50) {
        nodes {
          id
          quantity
          sellingPlanAllocation {
            sellingPlan { id name }
            priceAdjustments {
              perDeliveryPrice { amount currencyCode }
            }
          }
        }
      }
    }
    userErrors { code field message }
    warnings { code message target }
  }
}
{
  "cartId": "gid://shopify/Cart/abc",
  "lines": [
    {
      "merchandiseId": "gid://shopify/ProductVariant/12",
      "quantity": 1,
      "sellingPlanId": "gid://shopify/SellingPlan/3"
    }
  ]
}

The line has a sellingPlanAllocation field of the same type as the variant’s, so the cart can print the plan name and per-delivery price from Shopify’s figures. CartLineUpdateInput accepts sellingPlanId too, and its description lists “associate a different selling plan” among the things cartLinesUpdate does. The reference does not say whether sending null turns a subscription line back into a one-time purchase. Until you have tried that on your own store, remove the line and add it again.

Two CartErrorCode values belong to this flow, and they arrive in userErrors. VARIANT_REQUIRES_SELLING_PLAN is described as “Variant can only be purchased with a selling plan.” and SELLING_PLAN_NOT_APPLICABLE as “Selling plan is not applicable.” Going by those descriptions, the first answers a subscription-only variant sent with no plan, and the second a plan sent with a variant it does not cover. We have not provoked either one.

Two CartWarningCode values are worth rendering as well. MERCHANDISE_SELLING_PLAN_NOT_APPLICABLE_ON_COMPANY_LOCATION reads “Only one-time purchase is available for B2B orders.” and DISCOUNT_INCOMPATIBLE_PURCHASE_TYPE reads “The purchase type is incompatible with this discount.” Warnings sit beside userErrors on the payload, not inside it.

A Liquid theme reads the same model through variant.selling_plan_allocations and line_item.selling_plan_allocation. Shopify’s theme subscriptions tutorial covers that route, as its headless subscriptions guide covers this one.

What would we ship?

The query above with the product, and the variant half of it again each time the shopper changes an option, because the allocations change with the variant. perDeliveryPrice goes beside every plan, checkoutChargeAmount appears wherever it differs, and sellingPlanId is sent only for a plan the current variant has an allocation for.

We would stop there. The 2026-10 Storefront schema describes the offer and nothing after it: we found no type in it that represents a subscription once it exists. Pausing, skipping and cancelling act on subscription contracts, which this API does not expose, so we would leave them to the subscriptions app.

Whoooop builds and customises Shopify stores, Hydrogen storefronts among them, and adds the features a stock setup leaves out. If a subscription offer needs its own product page, our Shopify development team can build it.

Need this built properly?

Get in touch

Hack the planet!