Product Page Doesn't Load a Custom Section

Solved
batulkr
Excursionist
43 1 2

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:

Ekran Alıntısı.PNG

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?

 

Accepted Solution (1)

Accepted Solutions
LitExtension
Shopify Partner
3802 753 792

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!

LitExtension - #1 Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Have not had your Shopify store yet? Start the 14-day free trial HERE
Are you looking for a solution to migrate to Shopify? Try our FREE DEMO now!

View solution in original post

Replies 2 (2)
LitExtension
Shopify Partner
3802 753 792

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!

LitExtension - #1 Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Have not had your Shopify store yet? Start the 14-day free trial HERE
Are you looking for a solution to migrate to Shopify? Try our FREE DEMO now!
batulkr
Excursionist
43 1 2

Thanks so much!