Access a community of over 900,000 Shopify Merchants and Partners and engage in meaningful conversations with your peers.
Hey everyone,
Recently I have been trying to add a custom section to the product page where it shows other product from the same collection. The section used to load properly in the beginning but then suddenly disappeared for a reason that I could not detect.
I pass this snippet into my product template:
{% include 'custom-featured-collection', collection: collection, current_product: product %}
And the snippet code looks like this:
<section class="HomePage__featured-products-main">
<div class="HomePage__featured-products-container module module-width-restricted text-center p-x-10">
<div class="p-x-10">
<div class="module-title">
{{ collection.description }}
</div>
<p class="HomePage__featured-products-sub-title">{{ section.settings.section-subtitle }}</p>
</div>
<div class="HomePage__featured-products-content-container">
<div class="HomePage__featured-products-content {{ list_class }}">
{% for product in collection.products limit: product_limit %}
{% if product.handle != current_product.handle %}
{% include 'product-list-item' %}
{% endif %}
{% else %}
{% for i in (1..product_limit) %}
{% assign title = 'onboarding.featured_collection.product_title' | t %}
{%
include 'product-list-item',
onboarding: true,
onboarding_title: title,
onboarding_price: 0
%}
{% endfor %}
{% endfor %}
</div>
</div>
</div>
</section>
As you can see in the image, the HTML is displaying itself but the content in the HTML doesn't:
I thought maybe there was a problem with the "product-list-item" snippet, but the collection description doesn't load either so the issue is in here. It's weird that it doesn't show in product page because the section actually shows in another page in the website.
Does anyone have any idea about why this is happening?
Solved! Go to the solution
This is an accepted solution.
Hi @batulkr,
Because the collection object is not callable in the Product Page. You need to assign it first.
Please change code:
{% include 'custom-featured-collection', collection: collection, current_product: product %}
=>
{% assign collection_handle = product.collections[0].handle %}
{% include 'custom-featured-collection', collection: collections[collection_handle], current_product: product %}
Hope it helps!
This is an accepted solution.
Hi @batulkr,
Because the collection object is not callable in the Product Page. You need to assign it first.
Please change code:
{% include 'custom-featured-collection', collection: collection, current_product: product %}
=>
{% assign collection_handle = product.collections[0].handle %}
{% include 'custom-featured-collection', collection: collections[collection_handle], current_product: product %}
Hope it helps!
User | RANK |
---|---|
44 | |
42 | |
23 | |
20 | |
13 |