Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
<amp-script width="500" height="700" script="hello-world">
<div id="products_call"></div>
</amp-script>
<!-- Add [target="amp-script"] to the <script> element. -->
<script id="hello-world" type="text/plain" target="amp-script">
fetch('api url')
.then(response => response.json())
.then(function(data){
var comp_price = '';
if(data.product.variants[0].compare_at_price != ''){
comp_price = '$' + data.product.variants[0].compare_at_price;
}
var prod_data = `<div class="prd_main">
<div class="prd_iner">
<div class="prd_img">
<amp-img src="${data.product.image.src}" alt="product main image" width="100" height="100" layout="responsive"></amp-img >
</div>
<div class="prd_meta">
<p class="title">${data.product.title}</p>
<div class="prd_price">
<span class="price">$ ${data.product.variants[0].price}</span>
<span class="comp_price"><del> ${comp_price} </del></span>
</div>
<div class="prd_action">
<a href="url/cart/${data.product.variants[0].id}:1?checkout" class="btn" id="shopclick"> Shop Now</a>
</div>
</div>
</div>
</div>`;
document.getElementById('products_call').innerHTML=prod_data;
})
</script>
Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025