Using product bundles with Shopify Scripts
Bundles can be sold with Shopify Scripts published in your store. Before you start using bundles in your store, review the following considerations:
- Shipping and payment scripts are fully compatible with bundles.
- Line item scripts work normally with non-bundle line items. However, line item scripts apply to bundle line items only for read-only methods. Mutating line item methods aren't applied to bundle line items.
- Bundle components aren't readable in the cart.
- Bundle line items are readable in the cart, so cart methods are applied to them.
Scripts apply to bundles by default, except for line item scripts. If you don't want your scripts to be applied to bundles in your store, then consider updating your scripts to filter out products by using methods such as variant, product, or line item methods.
Discounts that are created by line item scripts aren't applied to bundles. Do one of the following if you want to apply a discount to a bundle:
- Create a discount code for the bundle.
- Manually change the price of the bundle.
- Use Cart transform to make price adjustments.
Bundles and Shopify Scripts methods
Before you start using bundles in your store, review the methods in your existing scripts to ensure that they function as desired on bundled products.
Cart methods such as
total_weight include bundles in their output. For example, if there's a bundle in the cart, then the bundle's subtotal price is included in the total subtotal price when
subtotal_price is called.
.line_items include bundles, so calls to
.length also include information from bundled products in their count.
delete_if method is a mutating line item script method that can be applied to non-bundle line items. However, it does not apply to bundle line items.
Line item methods
Read-only line item methods work with line items that are included in bundles. Some examples of read-only line item methods are
Mutating line item methods are ignored if the methods are applied to line items that are included in bundles. Some examples of mutating line item methods are