Add buy button to collection page at Dawn theme

Solved
Miquel1
Excursionist
26 4 7

Hi all, Need some help! 

 

I am trying to add a " buy button"  to my collection page but something is not right. (Dawn Theme)

 

After creating the " buy button"  I copied this code (see below the example) to product-card.liquid in code editor mode at the bottom but then the outpunt is like the screenshot.

So, the products gets repeated over and over again (with a buy button) below the regular collection.

 

Miquel1_0-1647514114523.png

 

Anyone knows what I do wrong?

 

Thanks,

Miquel

 

 

Example of the code:

 
<div id='collection-component-1647513755569'></div>
<script type="text/javascript">
/*<![CDATA[*/
(function () {
var scriptURL = 'https://sdks.shopifycdn.com/buy-button/latest/buy-button-storefront.min.js';
if (window.ShopifyBuy) {
if (window.ShopifyBuy.UI) {
ShopifyBuyInit();
} else {
loadScript();
}
} else {
loadScript();
}
function loadScript() {
var script = document.createElement('script');
script.async = true;
script.src=scriptURL;
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(script);
script.onload = ShopifyBuyInit;
}
function ShopifyBuyInit() {
var client = ShopifyBuy.buildClient({
domain: 'my-mallows.myshopify.com',
storefrontAccessToken: 'c8a57a31276fd30e42115f5f1f0b77f3',
});
ShopifyBuy.UI.onReady(client).then(function (ui) {
ui.createComponent('collection', {
id: '402391564516',
node: document.getElementById('collection-component-1647513755569'),
moneyFormat: '%E2%82%AC%7B%7Bamount_with_comma_separator%7D%7D',
options: {
"product": {
"styles": {
"product": {
"@media (min-width: 601px)": {
"max-width": "calc(25% - 20px)",
"margin-left": "20px",
"margin-bottom": "50px",
"width": "calc(25% - 20px)"
},
"img": {
"height": "calc(100% - 15px)",
"position": "absolute",
"left": "0",
"right": "0",
"top": "0"
},
"imgWrapper": {
"padding-top": "calc(75% + 15px)",
"position": "relative",
"height": "0"
}
},
"title": {
"font-family": "Montserrat, sans-serif",
"font-weight": "normal",
"font-size": "19px",
"color": "#324469"
},
"button": {
"font-family": "Montserrat, sans-serif",
"font-size": "13px",
"padding-top": "14.5px",
"padding-bottom": "14.5px",
":hover": {
"background-color": "#233474"
},
"background-color": "#273a81",
":focus": {
"background-color": "#233474"
},
"border-radius": "0px",
"padding-left": "29px",
"padding-right": "29px"
},
"quantityInput": {
"font-size": "13px",
"padding-top": "14.5px",
"padding-bottom": "14.5px"
},
"price": {
"font-family": "Montserrat, sans-serif",
"font-size": "15px",
"color": "#324469"
},
"compareAt": {
"font-family": "Montserrat, sans-serif",
"font-size": "12.75px",
"color": "#324469"
},
"unitPrice": {
"font-family": "Montserrat, sans-serif",
"font-size": "12.75px",
"color": "#324469"
}
},
"contents": {
"button": false,
"buttonWithQuantity": true
},
"text": {
"button": "Toevoegen"
},
"googleFonts": [
"Montserrat"
]
},
"productSet": {
"styles": {
"products": {
"@media (min-width: 601px)": {
"margin-left": "-20px"
}
}
}
},
"modalProduct": {
"contents": {
"img": false,
"imgWithCarousel": true,
"button": false,
"buttonWithQuantity": true
},
"styles": {
"product": {
"@media (min-width: 601px)": {
"max-width": "100%",
"margin-left": "0px",
"margin-bottom": "0px"
}
},
"button": {
"font-family": "Montserrat, sans-serif",
"font-size": "13px",
"padding-top": "14.5px",
"padding-bottom": "14.5px",
":hover": {
"background-color": "#233474"
},
"background-color": "#273a81",
":focus": {
"background-color": "#233474"
},
"border-radius": "0px",
"padding-left": "29px",
"padding-right": "29px"
},
"quantityInput": {
"font-size": "13px",
"padding-top": "14.5px",
"padding-bottom": "14.5px"
},
"title": {
"font-family": "Helvetica Neue, sans-serif",
"font-weight": "bold",
"font-size": "26px",
"color": "#4c4c4c"
},
"price": {
"font-family": "Helvetica Neue, sans-serif",
"font-weight": "normal",
"font-size": "18px",
"color": "#4c4c4c"
},
"compareAt": {
"font-family": "Helvetica Neue, sans-serif",
"font-weight": "normal",
"font-size": "15.299999999999999px",
"color": "#4c4c4c"
},
"unitPrice": {
"font-family": "Helvetica Neue, sans-serif",
"font-weight": "normal",
"font-size": "15.299999999999999px",
"color": "#4c4c4c"
}
},
"googleFonts": [
"Montserrat"
],
"text": {
"button": "Add to cart"
}
},
"option": {},
"cart": {
"styles": {
"button": {
"font-family": "Montserrat, sans-serif",
"font-size": "13px",
"padding-top": "14.5px",
"padding-bottom": "14.5px",
":hover": {
"background-color": "#233474"
},
"background-color": "#273a81",
":focus": {
"background-color": "#233474"
},
"border-radius": "0px"
},
"title": {
"color": "#324469"
},
"header": {
"color": "#324469"
},
"lineItems": {
"color": "#324469"
},
"subtotalText": {
"color": "#324469"
},
"subtotal": {
"color": "#324469"
},
"notice": {
"color": "#324469"
},
"currency": {
"color": "#324469"
},
"close": {
"color": "#324469",
":hover": {
"color": "#324469"
}
},
"empty": {
"color": "#324469"
},
"noteDescription": {
"color": "#324469"
},
"discountText": {
"color": "#324469"
},
"discountIcon": {
"fill": "#324469"
},
"discountAmount": {
"color": "#324469"
}
},
"text": {
"title": "Winkelwagen",
"total": "Subtotaal",
"empty": "Je winkelwagen is leeg",
"notice": "Verzendkosten worden bij het afrekenen toegevoegd. Verzendkosten bij orders tot €15 zijn €3,90\nVerzendkosten bij orders tussen €15 en €25 zijn €1,90\nOrders boven de €25 worden gratis verzonden",
"button": "Afrekenen"
},
"googleFonts": [
"Montserrat"
]
},
"toggle": {
"styles": {
"toggle": {
"font-family": "Montserrat, sans-serif",
"background-color": "#273a81",
":hover": {
"background-color": "#233474"
},
":focus": {
"background-color": "#233474"
}
},
"count": {
"font-size": "13px"
}
},
"googleFonts": [
"Montserrat"
]
},
"lineItem": {
"styles": {
"variantTitle": {
"color": "#324469"
},
"title": {
"color": "#324469"
},
"price": {
"color": "#324469"
},
"fullPrice": {
"color": "#324469"
},
"discount": {
"color": "#324469"
},
"discountIcon": {
"fill": "#324469"
},
"quantity": {
"color": "#324469"
},
"quantityIncrement": {
"color": "#324469",
"border-color": "#324469"
},
"quantityDecrement": {
"color": "#324469",
"border-color": "#324469"
},
"quantityInput": {
"color": "#324469",
"border-color": "#324469"
}
}
}
},
});
});
}
})();
/*]]>*/
</script>
 
Accepted Solution (1)

Accepted Solutions
Miquel1
Excursionist
26 4 7

This is an accepted solution.

Installed an app for it.

Miquel

View solution in original post

Reply 1 (1)
Miquel1
Excursionist
26 4 7

This is an accepted solution.

Installed an app for it.

Miquel