Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Shopify app blocks with client side request's dynamic content

Shopify app blocks with client side request's dynamic content

idango
Shopify Partner
16 0 3

Hi there!

 

I want to understand the best practice for building a Shopify App Block with dynamic content.


Says I have an endpoint on some remote server, "https://example.com/product?shop=abc.myshopify.com", which serves as an endpoint with an array of products, and I'd like to display all of those products in a block.


The data must be loaded on the client side, and I want to understand how to display those inside the block with the inherited Product cards and shop style.

 

Thanks.

Replies 4 (4)

Made4uo-Ribe
Shopify Partner
9552 2275 2823

Hi @idango 

 

If you follow the instructions here for app you will be able to create a theme extension that you can use a liquid template. If you want to call a product you can use the handle just like mentioned here. The collection only give maximum of 50 products but I have not heard of any code that will call all product.

 

In the liquid file, you can use the code below as reference.

 

{% for product in collection.products %}
<h2>{{ product.title}}</h2>
<span>{{ product.price | money }}</span>
{% endfor %}

 

I hope it help. 

Please don't forget to Like and Mark Solution to the post that helped you. Thanks!

If this fixed your issue, Likes and Accept as Solution are highly appreciated. Coffee tips fuel my dedication.
Get experienced Shopify developers at affordable rates—visit Made4Uo.com for a quick quote!
Need THEME UPDATES but have custom codes? No worries, for an affordable price.
Create custom Shopify pages effortlessly with PageFly's drag-and-drop ⚙️.
idango
Shopify Partner
16 0 3

This is definitely not answering my question.

 

My question focuses on how to display dynamic content using AJAX calls on client / server side if possible

Made4uo-Ribe
Shopify Partner
9552 2275 2823

Sorry. I overlooked that you want your own server to show the product. If that is the case, you need to write in json for every product, and display it as a json in the app block. Unfortunately, since the source of the product is external it would be hard for you to use liquid code for that. The best option is use javascript and template literal 

If this fixed your issue, Likes and Accept as Solution are highly appreciated. Coffee tips fuel my dedication.
Get experienced Shopify developers at affordable rates—visit Made4Uo.com for a quick quote!
Need THEME UPDATES but have custom codes? No worries, for an affordable price.
Create custom Shopify pages effortlessly with PageFly's drag-and-drop ⚙️.
idango
Shopify Partner
16 0 3

Thank you Ribe, can you elaborate an example? I'm not sure that I fully understood