Â
This guide shows you how to modify your Shopify Order Printer packing slip template to display bundle items (products within the bundle) nested under their dummy bundle products.
Â
Prerequisite
- Enable “Enable bundle metafields” setting in Bundle Kit > Settings > Bundle Metafields.
- Enable “Add bundle items (products within the bundle) to orders” setting in Bundle Kit > Settings > Bundle Order.
- Have the “Shopify Order Printer” app installed.
Â
Steps
1. Access Your Packing Slip Template
Go to Shopify admin > Apps > Shopify Order Printer > Templates > Packing slip.
Â
We recommend backing up your packing slip template in case you would like to revert to the original version.
Â

Â
2. Locate the Line Items Section
Find this similar section in your template:
<tbody> {% for line_item in order.line_items %} <tr> <td style="text-align: left;">{{ line_item.quantity }}</td> <td style="text-align: left;">{{ line_item.title }}</td> </tr> {% endfor %} </tbody>
Â

Â
3. Replace with Bundle-Aware Code
Replace the entire
<tbody>
section with:<tbody> {% assign nested_quantities = '' %} {% comment %}First pass: Display bundle products with their nested bundle items{% endcomment %} {% for line_item in order.line_items %} {% assign bundle_items = line_item.variant.metafields.app--5234301.bundle_items %} {% if bundle_items and bundle_items.size > 0 %} <tr> <td style="text-align: left;">{{ line_item.quantity }}</td> <td style="text-align: left;"><strong>{{ line_item.title }}</strong></td> </tr> {% for bundle_item in bundle_items %} {% assign nested_quantity = bundle_item.bundle_item_quantity | times: line_item.quantity %} <tr> <td style="text-align: left; padding-left: 20px;">{{ nested_quantity }}</td> <td style="text-align: left; padding-left: 20px; font-style: italic;"> {% if bundle_item.variant_title == "Default Title" %}{{ bundle_item.product_title }}{% else %}{{ bundle_item.product_title }} - {{ bundle_item.variant_title }}{% endif %} </td> </tr> {% comment %}Track nested quantities by variant_id{% endcomment %} {% assign variant_key = bundle_item.variant_id | append: ':' %} {% assign existing_quantity = 0 %} {% assign nested_entries = nested_quantities | split: ',' %} {% for nested_entry in nested_entries %} {% if nested_entry contains variant_key %} {% assign entry_parts = nested_entry | split: ':' %} {% assign existing_quantity = entry_parts[1] | plus: 0 %} {% assign old_entry = bundle_item.variant_id | append: ':' | append: existing_quantity %} {% assign nested_quantities = nested_quantities | remove: old_entry %} {% break %} {% endif %} {% endfor %} {% assign new_quantity = existing_quantity | plus: nested_quantity %} {% assign new_entry = bundle_item.variant_id | append: ':' | append: new_quantity %} {% if nested_quantities == blank %} {% assign nested_quantities = new_entry %} {% else %} {% assign nested_quantities = nested_quantities | append: ',' | append: new_entry %} {% endif %} {% endfor %} {% endif %} {% endfor %} {% comment %}Second pass: Display remaining quantities for each unique variant{% endcomment %} {% assign displayed_variants = ',' %} {% for line_item in order.line_items %} {% assign bundle_items = line_item.variant.metafields.app--5234301.bundle_items %} {% unless bundle_items and bundle_items.size > 0 %} {% assign variant_check = ',' | append: line_item.variant_id | append: ',' %} {% unless displayed_variants contains variant_check %} {% comment %}Calculate total quantity for this variant{% endcomment %} {% assign total_quantity = 0 %} {% for all_line_items in order.line_items %} {% assign check_bundle = all_line_items.variant.metafields.app--5234301.bundle_items %} {% unless check_bundle and check_bundle.size > 0 %} {% if all_line_items.variant_id == line_item.variant_id %} {% assign total_quantity = total_quantity | plus: all_line_items.quantity %} {% endif %} {% endunless %} {% endfor %} {% comment %}Get nested quantity for this variant{% endcomment %} {% assign nested_quantity = 0 %} {% assign variant_key = line_item.variant_id | append: ':' %} {% assign nested_entries = nested_quantities | split: ',' %} {% for nested_entry in nested_entries %} {% if nested_entry contains variant_key %} {% assign entry_parts = nested_entry | split: ':' %} {% assign nested_quantity = entry_parts[1] | plus: 0 %} {% break %} {% endif %} {% endfor %} {% assign remaining_quantity = total_quantity | minus: nested_quantity %} {% if remaining_quantity > 0 %} <tr> <td style="text-align: left;">{{ remaining_quantity }}</td> <td style="text-align: left;">{{ line_item.title }}</td> </tr> {% endif %} {% assign displayed_variants = displayed_variants | append: line_item.variant_id | append: ',' %} {% endunless %} {% endunless %} {% endfor %} </tbody>
Â
4. Preview and Save
Â
Original version:

Â
Modified version:
