It is possible to automatically display information about the bundle items (products within the bundle) in the dummy product description using Shopify metafields and Liquid code.
To do this, please follow these steps:
The metafield (key: "bundle_items") is an array of objects, with each object representing a bundle item (product within the bundle) with the following properties:
{
"product_id": 123,
"variant_id": 234,
"product_title": "Apple",
"variant_title": "Default Title",
"handle": "apple",
"sku": "SKUAPPLERED",
"price": "1.00",
"compare_at_price": "2.00",
"weight_value": 345.0,
"weight_unit": "g",
"bundle_item_quantity": 1
}
{% assign selected_variant = product.selected_or_first_available_variant %}
{% assign bundle_items = selected_variant.metafields.app--5234301.bundle_items.value %}
{% if bundle_items and bundle_items.size > 0 %}
<p>This bundle contains the following items:</p>
<ul>
{% for bundle_item in bundle_items %}
<li>
{{ bundle_item.bundle_item_quantity }} x
{{ bundle_item.product_title }}
{% unless bundle_item.variant_title == "Default Title" %}
({{ bundle_item.variant_title }})
{% endunless %}
</li>
{% endfor %}
</ul>
{% endif %}
For example, in the “Dawn” Shopify theme, you can add the code snippet to the main-product.liquid file.
