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>
Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024The Hydrogen Visual Editor is now available to merchants in Shopify Editions | Summer '...
By JasonH Sep 2, 2024Note: Customizing your CSS requires some familiarity with CSS and HTML. Before you cust...
By JasonH Aug 12, 2024