Я использую тему Ritual v3.2.1. В файле main-collection.liquid я вижу цикл для сбора продуктов коллекции и отображения их в сетке продуктов.
Как только я создаю цикл for для циклического просмотра информации о вариантах продукта, а затем пытаюсь использовать ее, возникают ошибки. Я оставил комментарии в приведенном ниже коде, чтобы пошагово выполнить свои действия.
main-collection.liquid
Код: Выделить всё
//Did not touch this top part of the code before pagination below
{% content_for 'block',
type: 'filters',
id: 'filters',
results: collection,
results_size: collection.products_count
%}
{% assign products_per_page = 24 %}
{% if section.settings.enable_infinite_scroll == false %}
{% assign products_per_page = section.settings.products_per_page %}
{% endif %}
//Below is where I attempt to modify Shopify liquid code
{% paginate collection.products by products_per_page %}
{% capture children %}
{% for product in collection.products %}
{% for variant in product.variants %} //added variant for-loop here
[*] id="{{ section.id }}-{{ product.id }}-{{ variant.id }}"
class="product-grid__item product-grid__item--variant{{ forloop.index0 }}" //added --variant to class (is this ok?)
data-page="{{ paginate.current_page }}"
data-product-id="{{ product.id }}"
data-variant-id="{{ variant.id }}" //added variant id
ref="cards[]"
>
{% # theme-check-disable %}
{% content_for 'block', type: '_product-card', id: 'product-card', closest.product: product %}. //stuck here getting errors when attempting to get closest variant?
{% # theme-check-enable %}
{% endfor %}
{% endfor %}
{% endcapture %}
{% render 'product-grid',
section: section,
children: children,
products: collection.products,
paginate: paginate,
enable_infinite_scroll: section.settings.enable_infinite_scroll
%}
{% endpaginate %}
Как я могу решить эту проблему?
Подробнее здесь: https://stackoverflow.com/questions/798 ... ions-pages
Мобильная версия