woocommerce_before_add_to_cart_button
woocommerce_after_add_to_cart_button
woocommerce_after_add_to_cart_quantity
woocommerce_before_add_to_cart_quantity
woocommerce_before_add_to_cart_form
woocommerce_after_add_to_cart_form
Before Add to Cart Button Content
<?php
add_action( 'woocommerce_before_add_to_cart_button', 'cxc_before_add_to_cart_btn_content' );
function cxc_before_add_to_cart_btn_content(){
echo '<p>Hello Cxc Button Before Content ... !!!</p>';
}
?>
After Add to Cart Button Content
<?php
add_action( 'woocommerce_after_add_to_cart_button', 'cxc_after_add_to_cart_btn_content' );
function cxc_after_add_to_cart_btn_content(){
echo '<p>Hello Cxc Button After Content ... !!!</p>';
}
?>
Shop And Product Category Pages Content
<?php
add_filter( 'woocommerce_loop_add_to_cart_link', 'cxc_shop_before_after_add_to_cart_btn_content', 10, 3 );
function cxc_shop_before_after_add_to_cart_btn_content( $add_to_cart_html, $product, $args ){
$before_content = '<p>Hello Cxc Button Before Content ... !!!</p>'; // Cxc Some text or HTML here ...
$after_content = '<p>Hello Cxc Button After Content ... !!!</p>'; // Add some text or HTML here as well ...
return $before_content . $add_to_cart_html . $after_content;
}
?>
<?php
add_filter( 'woocommerce_loop_add_to_cart_link', 'cxc_shop_before_after_add_to_cart_btn_on_sale_content', 10, 3 );
function cxc_shop_before_after_add_to_cart_btn_on_sale_content( $add_to_cart_html, $product, $args ){
$before_content = '<p>Hello Cxc Button Before Content ... !!!</p>'; // Cxc Some text or HTML here ...
$after_content = '<p>Hello Cxc Button After Content ... !!!</p>'; // Add some text or HTML here as well ...
if( $product->is_on_sale() ) {
return $before_content . $add_to_cart_html . $after_content;
}
}
?>
Single Product Page Specific product id Add to Cart Button Content
<?php
add_action( 'woocommerce_single_product_summary', 'cxc_add_content_after_add_to_cart_button', 30 );
function cxc_add_content_after_add_to_cart_button() {
global $product;
if ( function_exists( 'method_exists' ) && method_exists( $product, 'get_id' ) ) {
$product_id = $product->get_id();
} else {
$product_id = $product->id;
}
if( $product_id == 181 ) {
echo '<p>Hello Cxc Button After Content ... !!!</p>';
}
}
add_filter( 'woocommerce_short_description', 'cxc_add_content_before_add_to_cart_button', 99, 1 );
function cxc_add_content_before_add_to_cart_button( $content ) {
global $product;
if( is_single() ){
// get product id
if ( function_exists( 'method_exists' ) && method_exists( $product, 'get_id' ) ) {
$product_id = $product->get_id();
} else {
$product_id = $product->id;
}
if( $product_id == 181 ){
$content .= '<p>Hello Cxc Button Before Content ... !!!</p>';
}
}
return $content;
}
?>
Was this article helpful?
YesNo