Hi. I’m currently working on displaying a list of products and their corresponding quantities on the product page, which I’ve added through a custom field in the backend.
Here’s the code I’m using:
{% for quantity in product.metafields.kit_includes.quantity.value %}
{{ quantity }}
{% if block.settings.product_list %}
{% for product in block.settings.product_list %}
{{ product.selected_or_first_available_variant.sku }}: {{ product.metafields.kit_includes.item_name }}
{% endfor %}
{% endif %}
{% endfor %}
I’ve managed to get the information displayed, but I’m encountering an issue with aligning the quantities with their respective products. Specifically, I want the first quantity to match the first product, the second quantity to match the second product, and so on.
I’m thinking that incorporating [forloop.index0] might be the solution, but I’m uncertain about where to include it or if it’s the right approach.
Here’s the desired outcome I’m aiming for:
However, here’s what I’m currently getting:
Any guidance on how to address this issue would be greatly appreciated. Thanks!