Scripts for subscriptions

Customize the buying experience of subscriptions with Scripts.

When merchants sell subscription products, those product are assigned a selling plan (by the subscription app). When you write scripts, you can use the lineitem object .selling_plan_id to identify when a product is being bought as a subscription.

Line items for subscriptions have a selling plan ID, whereas line items for one-time purchases don't have a selling plan ID.

A product can be bought both as a subscription and as a one-time purchase. For example, a customer could buy the same bar of soap as a subscription and by itself. Usually there is one line item per product variant in an order. The exception is when an order contains subscriptions. Subscriptions have their own line items in orders. For example, when a customer buys the same soap as a subscription and as a one-time purchase, then there is a line item for each. Similarly subscriptions can have their own shipping lines in an order.

Lineitem scripts

Scripts that discount the price of subscriptions apply to:

  • the first payment of a pay-per-delivery only. These discounts aren't applied to scheduled payments.
  • the entire amount of a prepaid subscription order.

Shipping scripts

Scripts that discount shipping rates apply to:

  • the first payment of a pay-per-delivery only. These discounts aren't applied to scheduled payments.
  • the entire amount of a prepaid subscription order.

Payment scripts

Customers can pay for subscription products with Shopify Payments only. Make sure that you don't have a payment script that hides Shopify Payments. Otherwise, your customer won't be able to pay for their subscription order.

Examples

The following topics include examples that use subscriptions:

Learn more

Can’t find the answers you’re looking for? We’re here to help.