Here’s a simple code snippet on how to add a new element right after the add to cart button in single product page in WooCommerce. All we need to do is create a function and attach that function to woocommerce_after_add_to_cart_button
hook.
You can add basically anything using this code, for example you can use the woocommerce_after_add_to_cart_button
hook to add a WhatsApp contact button right after the add to cart button.
<?php
/**
* Function to display WhatsApp button right after add to cart button
* in single product page
*
*/
function risblco_element_after_add_to_cart_button() {
echo '<div class="new-element">'. esc_html__('This is the new element', 'text-domain') .'</div>';
}
add_action( 'woocommerce_after_add_to_cart_button', 'risblco_element_after_add_to_cart_button' );
?>
1,744 total views, 1 views today