API reference

Line items

The line item object and the allowed CRUD operations on the related resource endpoint
Line items can be of different types (anything that can have a cost or add a discount and contribute to changing the total order amount):
  • sku
  • bundle
  • shipment
  • payment_method
  • gift_card
  • adjustment
  • any valid promotion type (e.g. fixed_amount_promotion, percentage_discount_promotion, etc.)
Create a line item if you want to add an SKU or bundle to an order. Other types of line items are automatically created (e.g. to add a shipping cost to the order or apply a discount). The sum of all line item amounts makes the order's total, split into subtotal, taxes, and discount. The order object includes all the data you need. No calculation is required on your application.

Updating quantity

When creating a new line item, set the _update_quantity attribute to true if you want to update the line item quantity (if present) instead of creating a new line item for the same SKU.

Overriding amounts externally

Sometimes, you can decide not to manage prices within Commerce Layer but use an external service instead. When adding a line item to an order, set the _external_price attribute to true if you want the line item price to be provided by your external endpoint, instead of Commerce Layer.

Choosing line items that generate subscriptions

Line items that have the frequency attribute populated (with one of the frequency values available for the associated market, as set at the subscription model level) will be used to generate the recurring orders involved in the order subscription process, according to the subscription model's strategy.