Liquid, JavaScript, themes, sales channels
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'.
Can anyone help here?
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.
@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
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024