> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.customeow.io/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Cart Binding for Add-Price and Upsell Products

## Plain-language implementation guide

When added to the cart, the main product and related products include hidden properties that define their binding relationship.

**The main product contains:**

```text
_scm_bind = unique binding ID
```

**An addPrice product contains:**

```text
_scm_bind_to = the main product’s _scm_bind
_scm_inject_type = addPrice
```

**An upsell product contains:**

```text
_scm_bind_to = the main product’s _scm_bind
_scm_inject_type = upsell
```

> Do not hard-code `addPrice` or `upsell` detection from product titles, SKUs, handles, or product IDs. Use these hidden properties.

## Implementation requirements

### 1. Read cart item properties

Parse the product attributes/properties/line item properties in the cart line items, and read:

- `_scm_bind`
- `_scm_bind_to`
- `_scm_inject_type`
- `_scm_bind_qty`
- `_scm_bind_delete`

### 2. Establish the binding relationship

- Main product: has `_scm_bind`.
- Related product: has `_scm_bind_to`.
- When a related product’s `_scm_bind_to` equals the main product’s `_scm_bind`, the two products are considered bound.

### 3. Add-on price product rules

`_scm_inject_type = addPrice`

**Requirements:**

- Do not allow independent removal.
- Do not allow manual quantity changes.
- The quantity must follow the main product.
- When the main product is removed, the bound `addPrice` product must also be removed.
- Displayed `addPrice` price = `addPrice` unit price × current quantity.

> **Note:** Do not rely entirely on the `line_price` returned by the cart API, as it may update more slowly than `quantity` on some platforms or themes. Calculate the displayed `addPrice` price using unit price × quantity first.

### 4. Upsell product rules

`_scm_inject_type = upsell`

**By default:**

- Can be identified as a related product.
- Its quantity is not required to follow the main product.
- It can usually be removed independently.

### 5. Give rule fields priority

If rule fields are present, they take priority.

#### Quantity rules

`_scm_bind_qty`

| Value | Meaning |
| ---- | ---- |
| `1 / allow` | Independent quantity changes are allowed. |
| `2 / not_allow` | Quantity changes are not allowed. |
| `3 / follow` | The quantity follows the main product. |

#### Deletion rules

`_scm_bind_delete`

| Value | Meaning |
| ---- | ---- |
| `1 / allow` | Independent removal is allowed. |
| `2 / not_allow` | Independent removal is not allowed. |

### 6. Cart interaction requirements

#### When the main product quantity changes

1. Find all `addPrice` products where `_scm_bind_to` equals the main product’s `_scm_bind`.
2. Sync each `addPrice` product’s quantity to the main product’s quantity.
3. Then refresh the cart UI, subtotal, and total.

#### When the main product is removed

1. Find all `addPrice` products where `_scm_bind_to` equals the main product’s `_scm_bind`.
2. Remove all of those `addPrice` products.
3. Then refresh the cart UI, subtotal, and total.

### 7. UI requirements

#### addPrice products

- Hide the remove button.
- Hide the quantity increase/decrease controls.
- Display only the current quantity.
- Display the price as unit price × current quantity.

#### upsell products

- Do not mistakenly apply `addPrice`’s strict binding logic unless `_scm_bind_qty` or `_scm_bind_delete` explicitly requires it.

### 8. Compatibility requirements

Field names may differ across platforms. For example:

- `properties`
- `line_item.properties`
- `item.properties`
- `attributes`
- `lineItemProperties`

Please write a general-purpose reader that can extract `_scm_*` fields from objects, JSON strings, and property arrays.

### 9. Things not to do

- Do not hard-code product IDs.
- Do not hard-code SKUs.
- Do not hard-code product titles.
- Do not hard-code URL handles.
- Do not merely hide buttons without synchronizing the API.
- Do not update quantity without updating the displayed price.
- Do not change only the frontend while leaving `addPrice` items after the main product is deleted.

## Final goal

- Users operate only the main product.
- `addPrice` automatically follows its quantity and deletion state.
- Upsells are recognized without being incorrectly forced into strict binding.
- When new `addPrice` or `upsell` products are added, no theme-code change is needed as long as their cart properties are correct.

## Developer quick summary

In one sentence:

> In the cart, implement related-product binding using `_scm_bind`, `_scm_bind_to`, and `_scm_inject_type`. The `addPrice` product must follow the main product’s quantity.

## Further Reading


### Getting Started

- [Connect Your Store](https://help.customeow.io/en/article/connect-your-store-9kzhxj/)
- [Beginner Guide: Create Your First Customization Feature Step by Step](https://help.customeow.io/en/article/beginner-guide-create-your-first-customization-feature-step-by-step-3th848/)
- [How to Integrate a Customization Feature into a Product Landing Page (Product Detail Page)](https://help.customeow.io/en/article/how-to-integrate-a-customization-feature-into-a-product-landing-page-product-detail-page-9b1ke5/)

### Advanced Features

- [Templates in CustoMeow](https://help.customeow.io/en/article/templates-in-customeow-d69xbk/)
- [Use Component Conditions to Control Whether Components Are Shown or Hidden](https://help.customeow.io/en/article/use-component-conditions-to-control-whether-components-are-shown-or-hidden-1r2defw/)
- [What Can Workflow Do?](https://help.customeow.io/en/article/what-can-workflow-do-3jwgks/)

### Add-on Pricing and Upselling

- [What Is an Add-on Price Product?](https://help.customeow.io/en/article/what-is-an-add-on-price-product-959ka/)
- [What Is an Upsell Product?](https://help.customeow.io/en/article/what-is-an-upsell-product-9pmt71/)