I am modifying the horizon theme and want to pass some data to blocks rendered using content_for 'blocks'
. Unlike content_for 'block'
, 'blocks'
doesn’t allow multiple closest
variables or custom data to be passed. What are the workaround for this?
For example, below I want to pass the variant (or the variant id) to the blocks included within the product card:
{% liquid
assign product = closest.product
-%}
{% capture children %}
{% content_for 'blocks', closest.product: product %}
{% endcapture %}
{% render 'product-card', children: children, product: product %}
This doesn’t work:
{% content_for 'blocks', closest.product: product, variant_id: variant_id %}
But this does:
{% content_for 'block', type: '_product-card', closest.product: product, variant_id: variant_id %}