1
votes

In Woocommerce I am using the following code to add a custom text under add to cart:

add_action( 'woocommerce_after_add_to_cart_button', 'content_after_addtocart_button_func' );

function content_after_addtocart_button_func() {
    // Echo content.
    echo '<div  style="font-size:10px;"><em>(*Contact us for bulk purchase enquiry)</em></div>';
}

But It is displayed in one line like in this screenshot:

enter image description here

How can I have it under the add to cart button?

2

2 Answers

0
votes

You can try use a <br slyle="clear:both;"> that has a slyling clear argument set to both, to stop the floating styling behavior:

add_action( 'woocommerce_after_add_to_cart_button', 'content_after_addtocart_button_func' );

function content_after_addtocart_button_func() {
    // Echo content.
    echo '<br slyle="clear:both;"><div  style="font-size:10px;"><em>(*Contact us for bulk purchase enquiry)</em></div>';
}

It should work...

0
votes

Just Wrape the Text with <div> as follow:

add_action('woocommerce_after_add_to_cart_button', 'content_after_addtocart_button_func');

function content_after_addtocart_button_func()
{

    // Echo content.
    echo '<div>(*Contact us for bulk purchase enquiry)</div>';
}

or you can use woocommerce_after_add_to_cart_form as follow:

add_action('woocommerce_after_add_to_cart_form', 'content_after_addtocart_button_func');

function content_after_addtocart_button_func()
{

// Echo content.
     echo '<div>(*Contact us for bulk purchase enquiry)</div>';
}