I have added the shopify code to my website today but the text is showing twice. How do I remove one of them, specifically the line directly under the price?
I’m having a little trouble looking at the code since it’s not added within a code block but confirm something for me first.
Did you add the AfterPay code at the very, very bottom of the theme.liquid template - so after the closing tag? That would not the correct place to put it so ignoring double ups that’s something to also look at resolving.
Can you link to your shop so we can see the code in place on the live store?
I am having the same issue and yes, I put the code at the very bottom the theme.liquid template - after the closing tag? Please help, it looks very unprofessional.
For anyone still wondering, this might be one of the reasons why you’re seeing the widget twice. The issue I had with Afterpay messages rendering twice was because I was initialising Afterpay in theme.js as well when trying to update the Afterpay price to match the selected variant price.
Because Afterpay.init($) in theme.js was executing before the Afterpay widget rendered the html element to the DOM, the element was rendered twice. To get around this I’ve added a condition in theme.js to check if the element existed on the page yet or not. If it is then remove the existing element from the DOM, update the price then initialise the Afterpay messaging widget again.
//Check the afterpay message element exists on the page
if($('afterpay-placement').length){
//Remove the element from the DOM
$('afterpay-placement').remove();
//Update the afterpay_current_variant object with updated price
afterpay_current_variant.price = [UPDATED_PRICE];
//Render new message element to the DOM
Afterpay.initProductPage($);
} else {
//If the element hasn't rendered yet, simply change the
//afterpay_current_variant object price and the message
//element will render to the DOM with the desired price.
afterpay_current_variant.price = [UPDATED_PRICE];
}