Post-transaction setup

After creating a transaction

Creating a transaction returns a txnId, but that alone doesn't add anything to the cart. This page covers everything you do after Create transaction to correctly add the bundle to the cart and apply its discount.

At a high level:

  1. Add the bundle lines to the cart with the Shopify /cart/add.js call, tagging each line so Loop recognises it as a bundle.
  2. Apply the bundle discount - the method differs for Preset (FIXED) and BYOB (RANGE) bundles.

Step 1 - Add the bundle to the cart

Add every child line of the bundle in a single /cart/add.js call, and tag each line so Loop links it to the transaction.

  • Set the line-item property that carries the transaction ID on every bundle line.
  • The property key must match exactly - a wrong or missing key means Loop won't treat the line as part of a bundle.
⚠️

Property name depends on bundle type. Preset bundles use _loopBundleTxnId (shown below). BYOB bundles use _bundleId.


Step 2 - Apply the bundle discount

Linking the lines does not apply the discount on its own. Do this based on the bundle type.

Preset bundle (type: FIXED)

Pass the discount as a cart attribute on the same /cart/add.js call, and tag each bundle line with the preset-bundle properties.

Cart attribute - _loopBundleDiscountAttributes is a stringified JSON object, keyed by the transaction ID:

FieldTypeDescription
discountTypestringPERCENTAGE, FIXED, or FIXED_PRICE.
discountValuenumberThe configured discount value (e.g. 20 for 20%).
discountComputedValuenumberThe actual amount discounted, computed for this cart.

Line-item properties on each bundle line:

PropertyTypeDescription
_loopBundleTxnIdstringThe txnId from Create transaction.
_isPresetBundleProductbooleantrue for preset bundle lines.
bundleName or _bundleNamestringDisplay name of the bundle.

In Shopify, you can hide line item properties from the cart and checkout UI by prefixing the property name with an underscore (_). Any property starting with (e.g., _bundleName) will be automatically hidden from customers, while still remaining accessible in the backend and APIs.


Example /cart/add.js payload:

{
  "items": [
    {
      "id": 43244297912397,
      "quantity": "1",
      "selling_plan": 16639098957,
      "properties": {
        "_loopBundleTxnId": "01KY9QAVS44F8Y8T553WZ2E82G",
        "_isPresetBundleProduct": true,
        "bundleName": "The Late-Night Prototyper's Bundle"
      }
    }
  ],
  "attributes": {
    "_loopBundleDiscountAttributes": "{\"01KY9QAVS44F8Y8T553WZ2E82G\":{\"discountType\":\"PERCENTAGE\",\"discountValue\":20,\"discountComputedValue\":7.036}}"
  }
}

The _loopBundleDiscountAttributes value is a JSON string (note the escaped quotes), and its key is the same txnId you set in _loopBundleTxnId.

BYOB bundle (type: RANGE)

Apply the discount by calling Shopify's discount URL with the bundle discount code (from discounts[].code in Read bundle details):

curl 'https://your-store-name.myshopify.com/discount/LPBNDLorubv'

Here LPBNDLorubv is the discount code. This registers the discount on the customer's cart so it is applied at checkout.