Cannot apply selling plan to variant

Topic summary

A developer encounters a 422 error (“Cannot apply selling plan to variant”) when attempting to add a subscription item to the cart.

Technical Details:

  • Created a subscription group on a product variant using the sellingPlanGroupCreate mutation
  • Configured monthly billing and delivery policies with recurring intervals
  • Set up anchors for payment timing (first of the month)

Root Cause Identified:

  • The developer was incorrectly using sellingPlanGroupId instead of sellingPlanId when adding the item
  • This mismatch between group-level and plan-level identifiers caused the cart error

Resolution:

  • Switched to using the correct sellingPlanId parameter
  • Context: Implementation involves adding subscription items via JavaScript

Status: Issue resolved through proper API parameter usage.

Summarized with AI on November 20. AI used: claude-sonnet-4-5-20250929.

I have created a subscription Group on a products variant, but when I try adding the item to the cart I am getting

status: 422, message: "Cart Error", description: "Cannot apply selling plan to variant"
mutation {
  sellingPlanGroupCreate(
    input: {
      name: "Monthly"
      merchantCode: "Monthly"
      options: ["Monthly"]
      position: 1
      sellingPlansToCreate: [
        {
          name: "Monthly"
          description: "Payments the first of the month"
          options: "Monthly Payments"
          position: 1
          billingPolicy: { recurring: { interval: MONTH, intervalCount: 1 ,maxCycles:8, anchors:{type:MONTHDAY,day:1}} }
          deliveryPolicy: { recurring: { interval: MONTH, intervalCount: 1 , anchors:{type:MONTHDAY,day:1}} }
				   
        }
      ]
    }
    resources: { productIds: [""], productVariantIds["gid://shopify/ProductVariant/4127279"] }
  ) {
    sellingPlanGroup {
      id
    }
    userErrors {
      field
      message
    }
  }
}

I was using SellingPlanGroup id not SellingPlan id

@Tiber Can you explain where are you using the SellingPlanGroup id instead of the SellingPlan id?

Hey @Lokesh_Saini

It was for adding an item with a subscription through JavaScript