Adding a product to a page template

New Member
1 0 0

I'm trying to embed products in a page template, including a form to add the product to a cart, but I can't seem to get it working.

 

I have blocks set up like this:

 

  "blocks": [
    {
      "type": "lookbook-products",
      "name": "Lookbook Product",
      "settings": [
        {
          "id": "product",
          "type": "product",
          "label": "Product"
        }
      ]
    }
  ]

And to try and display the data I have this:

      {% for block in section.blocks %}
        {% if block.type == 'lookbook-products' %}

          {% assign product_item = all_products[block.settings.product] %}
          <div class="lookbook-product">
            <div class="lookbook-product--image">
              <img src="{{ block.product | img_url }}" />
            </div>
            <div class="lookbook-product--content">
              <div class="lookbook-product--title">
                {{ product_item.title }}
              </div>
              <div class="lookbook-product--price">
                {{ product_item.price }}
              </div>
              <div class="lookbook-product--addtocart">
              </div>
            </div>
          </div>
        {% endif %}
      {% endfor %}

But no data comes out. Just blank space and the "no image" gif. How do I get the data from the selected products on the page to display?

0 Likes
Shopify Partner
435 83 94

Hello DiazCooper,

 

As i check your code is working just one mistake for image

{% assign featured_image = product_item.selected_or_first_available_variant.featured_image | default: product_item.featured_image %}
<img src="{{ featured_image | img_url }}" /

output.PNG

Want to modify or custom changes on store hire me.
My Email: guleriathakur43@gmail.com
Skype: navrocks1
If helpful then please Like and Accept Solution.
If you are happy and want to donate small Click here (Its my paypal)
0 Likes