add to cart button woocommerce code example

Example 1: cart icon in woocommerce

<?php echo do_shortcode("[woo_cart_but]"); ?>

Example 2: how to change add to cart text button woocommerce

// To change add to cart text on single product page
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woocommerce_custom_single_add_to_cart_text' ); 
function woocommerce_custom_single_add_to_cart_text() {
    return __( 'Buy Now', 'woocommerce' ); 
}
// To change add to cart text on product archives(Collection) page
add_filter( 'woocommerce_product_add_to_cart_text', 'woocommerce_custom_product_add_to_cart_text' );  
function woocommerce_custom_product_add_to_cart_text() {
    return __( 'Buy Now', 'woocommerce' );
}

Example 3: woocommerce align add to cart buttons css

.align-bottom .et_pb_column {
padding-bottom:30px;}
.align-bottom .et_pb_button_module_wrapper {
position: absolute;
bottom: 0;
left: 0;
right: 0;
margin: auto;}

Example 4: add content after add to cart button woo commerce

add_action( 'woocommerce_after_add_to_cart_button', 'add_content_after_addtocart_button_func' );

function add_content_after_addtocart_button_func() {

// Echo content.

echo '<div class="second_content">Place your content here!</div>';

}

Tags:

Css Example