skip to Main Content

How to add "contact us" text under the tag or above the share button on a single product page

I have added another text below the price of the product, it works

add_action( 'woocommerce_before_add_to_cart_form', 'bbloomer_show_return_policy', 20 );
 
function bbloomer_show_return_policy() {
    echo '<p class="rtrn">   See Our License <a href="mysite.com/license/" target="_blank"> Here! </a>
<br /></p>';
}

if to add text below the tag or above the share button it doesn’t work

add_action (  'woocommerce_after_add_to_cart_button' , 'bbloomer_after_add_to_cart_btn'  ) ;
 
function bbloomer_after_add_to_cart_btn ( ) { 
        echo '<p class="rtrn">   Contact us <a href="mysite/contact-us/" target="_blank"> Here! </a>
<br /></p>';
}

2

Answers


  1. Try this,

    This code is worked for me. Hope this will helps you.

    //Add DIV end element after shop loop item
    add_action('woocommerce_after_shop_loop_item', 'action_woocommerce_after_shop_loop_item', 10, 0);
    function action_woocommerce_after_shop_loop_item( ) {
      echo "</a>";
     };
    //Add DIV start element before shop loop item
    add_action('woocommerce_before_shop_loop_item', 'action_woocommerce_before_shop_loop_item', 10, 0);
    function action_woocommerce_before_shop_loop_item( ) {
       echo "<p class="rtrn">See Our License <a href="mysite.com/license/" target="_blank"> Here!";
    
    };
    
    Login or Signup to reply.
  2. How to add “contact us” text under the tag or above the share button use the following:

    add_action( 'woocommerce_single_product_summary', 'custom_single_product_summary', 45 );
    function custom_single_product_summary() {
        printf( '<p class="rtrn">%s<a href="%s" target="_blank"> %s </a><br /></p>',
        __( "Contact us", "woocommerce" ),
        home_url( '/contact-us/' ),
        __( "Here!", "woocommerce") );
    }
    

    Code goes in functions.php file of your active child theme (or active theme). Tested and works.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search