• Hi,

    I’m attempting to add a text below the add to cart button on the product pages. I found the following code. This code positions the text below the add to cart button but outside of the single_variation_wrap class. Ideally the text would be inside of the single_variation_wrap and inside the woocommerce-variation-add-to-cart variations_button class.

    add_action( ‘woocommerce_after_add_to_cart_button’, ‘content_after_addtocart_button’ );

    function content_after_addtocart_button() {
    echo ‘<div class=”content-section”>Add Your HTML, Text Or Image Content Here!</div>’;
    }

    Does anybody have an idea how I can achieve this?

    thanks a lot for your help.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Mina

    (@purpleberryservices)

    Can you share the site URL?

    Thread Starter tabasco86

    (@tabasco86)

    Hi,

    The idea is to have a site secure text within & below the box that I have around the add to cart button rather than outside the box & below.
    Here a link to the page as it currently is:
    cormilu.com.br/loja/fios-de-luz/cordao-de-luz-led-luminaria-de-bolas-branco-aspen/
    here a capture of where I want to add content
    https://s9.postimg.org/ki9ly1hov/Capture.png

    thanks for your help and have a nice week everyone,

    Mina

    (@purpleberryservices)

    Hi,

    Method 1
    If you would like to add custom text within woocommerce-variation-add-to-cart div, add it after statement “<button type=”submit” class=”single_add_to_cart_button button alt”><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button>”

    in woocommerce/single-product/add-to-cart/variation-add-to-cart-button.php file.

    Method 2
    Other way is to use below snippet in functions.php. Note this will add custom text outside woocommerce-variation-add-to-cart div

    add_action( ‘woocommerce_single_variation’, ‘pbs_woo_add_single_variation_add_to_cart_button’, 25 );

    function pbs_woo_add_single_variation_add_to_cart_button( ) {
    echo ‘<div style=”clear:both”></div>’;
    echo ‘<div class=”content-section”>Add Your HTML, Text Or Image Content Here!</div>’;
    }

    Thread Starter tabasco86

    (@tabasco86)

    Hey Mina,

    thanks a lot for your help!
    Excellent advice. I went for method 1 as I precisely want the content to appear within the code within the div.

    Have a great week!

    Mina

    (@purpleberryservices)

    Thank you ??

    Have a wonderful week ahead!!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to place text inside single_variation_wrap below add to cart button’ is closed to new replies.