Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1404503
    mdmason23
    Participant

    Hello,

    I’m trying to add an image after my “add to cart” button on my product pages. I found the following thread in this forum and added the suggested coding:
    https://community.theme.co/forums/topic/image-under-add-to-cart-button/

    My image ended up appearing right at the bottom of the page over-writing the footer, and the javascript text was visible underneath when viewing a product page in customizer. Nothing shows when viewing the website outside customizer.

    I have added the code to my website so you can see what is happening.

    Can you please tell me what I am doing wrong?

    Thanks!

    #1404514
    Christopher
    Moderator

    Hi there,

    Please update your code to :

    jQuery ( function( $ ) { 
      $('<img src="http://placehold.it/350x50" alt="Image after SKU"/>').insertAfter('.button.single_add_to_cart_button.button.alt');
    } );

    Hope it helps.

    #1404517
    mdmason23
    Participant

    I updated the javascript as recommended, and am seeing no change. I will include login credentials in a private reply.

    #1404518
    mdmason23
    Participant
    This reply has been marked as private.
    #1404532
    Paul R
    Moderator

    Hi,

    Please remove the script in your Custom JS that reads

    
     <script type="text/javascript" src="https://cdn.ywxi.net/js/1.js" async></script>
    

    You cannot add it there as it will cause a js error and prevent other scripts from working.

    To add it, add this in your child theme’s functions.php file.

    
    
    function add_js_script() { ?>
      <script type="text/javascript" src="https://cdn.ywxi.net/js/1.js" async></script>
    <?php
    }
    add_action( 'wp_footer', 'add_js_script' );
    

    Hope that helps.

    #1404550
    mdmason23
    Participant

    Thank you! One last question…how can I center the image and nudge it down a little bit?

    #1404562
    Christopher
    Moderator

    Hi there,

    Please update previous JS code to :

    jQuery ( function( $ ) { 
      $('<img src="https://www.taiyaz.com/wp-content/uploads/2017/03/payments-seals.jpg" alt="Image after SKU"/ style="margin: 0 auto;display: block;margin-top: 10px;">').insertAfter('.button.single_add_to_cart_button.button.alt');
    } );

    Hope it helps.

  • <script> jQuery(function($){ $("#no-reply-1404503 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>