Afterpay Product Page assets showing twice

Hello,

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?

Product page example: https://www.nogrow.com.au/collections/no-grow-facial-product-range/products/no-grow-female-facial-hair-remover-growth-inhibitor-90ml

Liquid code is noted below.

Thank you

{%- if canonical_url != blank -%}

{%- endif -%}

{%- if settings.favicon != blank -%}

{%- endif -%}

{%- capture seo_title -%}
{%- if request.page_type == ‘search’ and search.performed == true -%}
{{ ‘general.search.heading’ | t: count: search.results_count }}: {{ ‘general.search.results_with_count’ | t: terms: search.terms, count: search.results_count }}
{%- else -%}
{{ page_title }}
{%- endif -%}
{%- if current_tags -%}
{%- assign meta_tags = current_tags | join: ', ’ -%} – {{ ‘general.meta.tags’ | t: tags: meta_tags -}}
{%- endif -%}
{%- if current_page != 1 -%}
– {{ ‘general.meta.page’ | t: page: current_page }}
{%- endif -%}
{%- assign escaped_page_title = page_title | escape -%}
{%- unless escaped_page_title contains shop.name -%}
– {{ shop.name }}
{%- endunless -%}
{%- endcapture -%}

{{ seo_title | strip }}

{%- if page_description -%}

{%- endif -%}

{% include ‘social-meta-tags’ %}

{{ ‘theme.scss.css’ | asset_url | stylesheet_tag }}

{%- if request.page_type contains ‘customers/’ -%}

{%- endif -%}

{{ content_for_header }}

{{ ‘general.accessibility.skip_to_content’ | t }}

{%- if settings.enable_ajax -%}
{% include ‘cart-popup’ %}
{%- endif -%}

{% section ‘header’ %}

{{ content_for_layout }}

{% section ‘footer’ %}

{{- 'sections.slideshow.navigation_instructions' | t -}}
  • {{ 'general.accessibility.refresh_page' | t }}
  • {{ 'general.accessibility.selection_help' | t }}

Bump… please help!

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?

Hi Jason,
Thank you for your response.

Yes, I pasted the code at the end as per the instructions from AfterPay. I have inserted the code in a block, is this better?

Apologies, I am not good at coding so I am learning very quickly here.

My shop link is www.nogrow.com.au

Thank you


  
  
  
  
  

  {%- if canonical_url != blank  -%}
    
  {%- endif -%}

  {%- if settings.favicon != blank -%}
    
  {%- endif -%}

  {%- capture seo_title -%}
    {%- if request.page_type == 'search' and search.performed == true -%}
      {{ 'general.search.heading' | t: count: search.results_count }}: {{ 'general.search.results_with_count' | t: terms: search.terms, count: search.results_count }}
    {%- else -%}
      {{ page_title }}
    {%- endif -%}
    {%- if current_tags -%}
      {%- assign meta_tags = current_tags | join: ', ' -%} – {{ 'general.meta.tags' | t: tags: meta_tags -}}
    {%- endif -%}
    {%- if current_page != 1 -%}
      – {{ 'general.meta.page' | t: page: current_page }}
    {%- endif -%}
    {%- assign escaped_page_title = page_title | escape -%}
    {%- unless escaped_page_title contains shop.name -%}
      – {{ shop.name }}
    {%- endunless -%}
  {%- endcapture -%}
  

  {%- if page_description -%}
    
  {%- endif -%}

  {% include 'social-meta-tags' %}

  {{ 'theme.scss.css' | asset_url | stylesheet_tag }}

  

  {%- if request.page_type contains 'customers/' -%}
    
  {%- endif -%}

  
  
  

  {{ content_for_header }}

  {{ 'general.accessibility.skip_to_content' | t }}

  {%- if settings.enable_ajax -%}
    {% include 'cart-popup' %}
  {%- endif -%}

  {% section 'header' %}

  

    

    {% section 'footer' %}

    
      {{- 'sections.slideshow.navigation_instructions' | t -}}
    

  

  
    - {{ 'general.accessibility.refresh_page' | t }}

    - {{ 'general.accessibility.selection_help' | t }}
  

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.

covaup.com

hello, I’m facing the same problem in product page. afterpay is showin twice in product page kindlyy helppp

Hey mate did you end up by solving the issue ? I’m having the same problem

Hello Nogrow,

Please can you advise how did you add?

You Can Also Add These…

Please can you share the code and instructions please

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];
}