• Resolved grunauer

    (@grunauer)


    Please i would like to know how can i add a trust badge below the “Add to Cart” bottom.

    I really dont know how, I just got the image of the badge

    I am using the shopper theme of Alidropship

    Please help

Viewing 13 replies - 1 through 13 (of 13 total)
  • There are plenty of badge plugins that are out there. I would assume that would be your choice? If you know how to code let me know and I’ll show you how to write a snippet to place there.

    Thread Starter grunauer

    (@grunauer)

    I don’t know coding so I would appreciate if you tell me what exactly to do in order to have it right below the add to card bottom.

    It’s a just a trust badge of secure checkout with payoal/visa stuff, the usual one that is on every product page in any online store

    Just like this one

    https://www.pngkey.com/png/full/110-1105555_safe-checkout-guaranteed-safe-checkout-trust-badge.png

    I would really appreciate any kind of help.

    Thanks in advance

    • This reply was modified 5 years, 10 months ago by grunauer.
    • This reply was modified 5 years, 10 months ago by grunauer.
    • This reply was modified 5 years, 10 months ago by grunauer.

    Do you have access to FTP, do you know how to edit the functions file? If not I would highly suggest looking at a plugin to do this. There are some good ones out there. The kids over at YITH have a nice one, but it is a paid for plugin.

    If you have access to FTP and can edit the functions file you can do this.

    First Thing. Do you want it for specific product? This adds a checkbox in the back just incase you don’t want it everywhere.

    
    //this adds a checkbox to General Tab
    add_action( 'woocommerce_product_options_general_product_data', 'serafin_add_badge_checkbox_to_products' );        
      
    function serafin_add_badge_checkbox_to_products() {           
    woocommerce_wp_checkbox( array( 
       'id' => 'custom_badge', 
       'class' => '', 
       'label' => 'Show Trust Badge'
         ) 
       );      
     }
    
    //This saves that check
    add_action( 'save_post', 'serafin_save_badge_checkbox_to_post_meta' );
      
    function serafin_save_badge_checkbox_to_post_meta( $product_id ) {
        if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
            return;
        if ( isset( $_POST['custom_badge'] ) ) {
                update_post_meta( $product_id, 'custom_badge', $_POST['custom_badge'] );
        } else delete_post_meta( $product_id, 'custom_badge' );
    }
    
    //This will be the image for your badge. change the url to the exact url of your image.
    add_action( 'woocommerce_after_add_to_cart_button', 'serafin_display_badge_if_checkbox', 6 );
      
    function serafin_display_badge_if_checkbox() {
        global $product;     
        if ( get_post_meta( $product->get_id(), 'custom_badge', true ) ) {
            echo '
    <div class="trust-badge"><img src="https://www.exmaple.com/path_to/badge.png"/></div>
     
    ';
        }
    }
    

    If you are not confident in adding this I wouldn’t do it then.
    Depending on your site you’ll need to add a little CSS to make this display how you want.

    Thread Starter grunauer

    (@grunauer)

    It’s for every product page that I have I create from now on

    What exactly do I need to do? I m not really an experts, sorry

    Don’t be sorry. We all had to learn at some point.

    I would use a plugin to be honest. That way you can edit it when you need to. Check the YITH Badge plugin out and Google Custom Badge for WooCommerce. You should be able to find something that works for you.

    Thread Starter grunauer

    (@grunauer)

    wait i found something

    this guys actualy give a code

    https://www.tychesoftwares.com/how-to-add-trust-seal-in-woocommerce-after-add-to-cart/

    i just need to find the product template, any idea where it could be?

    That’s essentially the same thing I wrote you but it’s for all. Which is what you wanted.

    You add this to your functions.php file in your theme.

    Thread Starter grunauer

    (@grunauer)

    OK cool but how or where do I need to go to get access to that file?

    It is in your host files. If you don’t have access to an FTP server to change them you can edit them in WordPress but I always advise against doing that if you don’t know how to code.

    Goto Appearance > Editor > From dropdown choose your theme name > Click Select > Theme Functions or Functions you’ll see. Just after and below the <?php

    You’ll add the script

    
    add_action( 'woocommerce_after_add_to_cart_button', 'show_content_after_add_to_cart' );
    function show_content_after_add_to_cart() {
         echo "<img src='safe_checkout.png' >";
    }
    

    The reason it is better to do in FTP is if you make a mistake you can always revert back. In WordPress it’s hard to do if you make a mistake. So just be careful

    Thread Starter grunauer

    (@grunauer)

    I have my host on siteground so i guess i could ask them to add the for me right?

    how can be sure that when i use the code, i will be able to see the badge that i want?

    I really need a code for this badge, this is the one i need

    https://groomersbundle.com/wp-content/uploads/2019/05/pngkit_trust-badge-png_3598781.png

    I have never seen a host add any code to a site for a customer. That would be a first but then again it’s a new moon so who knows.

    The code is above you. I wrote it twice, three times a lady.

    Simply take out the png and add your url like this.

    
    add_action( 'woocommerce_after_add_to_cart_button', 'show_content_after_add_to_cart' );
    function show_content_after_add_to_cart() {
         echo "<img src='https://groomersbundle.com/wp-content/uploads/2019/05/pngkit_trust-badge-png_3598781.png' >";
    }
    

    Other than that we can’t offer much more assistance on here. You could find a dev somewhere that can add it for you if your host does not.

    Thread Starter grunauer

    (@grunauer)

    Already talked to them and they cant help me

    I am trying to find the place within theme editor to find the that i need to place the code but i dont know where to look

    I would advise you find a developer that can add this. I gave you detailed instructions a few responses up. Although I don’t ever advise adding code that way. You are best off finding a dev to add this for you if you not familiar with the backend editor.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Trust Badge Below “Add to Cart”’ is closed to new replies.