Display product details (template, section and form) on App Proxy

navo17
Shopify Partner
6 0 3

I want to render the Product page along with some custom information when I hit my App Proxy URL and return liquid from it. 

 

res.set('Content-Type', 'application/liquid')

var response = `Proxy page for {{ shop.name }}
{% for product in collections['all'].products %} - 
{{ product.title }} {% if product.title == #condition %} {% assign template = 'product' %} {% section 'product-template' %} {% endif %} {% endfor %} `

If I run this then the below error comes on my store page. The line points to where my form starts inside product-template. How do I make sure the form and product details (image, title, price, etc.) loads? In my understanding, the {% section 'product-template' %} line should render everything correctly as I am passing the 'product'.

 

Liquid error (line ###): product form must be given a product

The product.title and shop.name are being correctly rendered.

 

If I try to send a new form/ layout after the 'section' line then it displays product details correctly but I want to use the already present 'product-template'.

banned
Replies 3 (3)

navo17
Shopify Partner
6 0 3

Can anyone help here? 

banned
HunkyBill
Shopify Expert
4845 60 547

If you read the documentation, the very first thing they show you is that you cannot do what you are trying to do with that pattern.

 

Variables created outside sections are not available within sections. Likewise, variables created in sections are not available outside sections. If a section includes a snippet, the snippet has access to the variables in the section.

 

So it looks like you are going to have to adjust your pattern to suit the needs.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
rishabhJain1
Visitor
2 0 0

@navo17  were you able to load product page with details with out any errors ....I am also trying this out and facing the same issue.

Can you please help me out if this is working ?

error : Liquid error (sections/main-product.liquid line 267): product form must be given a product

Ajax request from main-product liquid

 

        $.ajax({
            method:'GET',
            url: '/apps/dynamic/product/'+productId+ '?customer_segments='+customerTags+'&customer_ip='+ip.ip + '&shop='+ shopUrl + '&customer_timeStamp='+customer_timeStamp + '&customer_fingerprint='+visitorId+ '&customer_loggedIn='+ customer_loogedIn+'&utm_params='+ utm_params+ '&shopify_prod_id='+ shopify_prod_id,
            crossDomain: true,
            async:true,
            dataType: 'html',
            data: {
              section_id: sectionId,
              section_settings: sectionSettings,
            },
            complete: function(data) {
              if(data.status == 200) {$('#contextualized_product').hide().removeClass("contextualized_product").html(data.responseText).fadeIn("slow");

              }
            }
          });

 

I have also added app proxy in app setting which point to node app to get rendered liquid in response