// 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' );
}
add_filter( 'wc_add_to_cart_message_html', 'exploretech_custom_add_to_cart_message_html' );
function exploretech_custom_add_to_cart_message_html() {
$ext_custom_message = "You have successfully added the product, thanks for shopping with us";
return $ext_custom_message;
}
add_filter('woocommerce_product_single_add_to_cart_text', 'exploretech_change_woocommerce_custom_add_to_cart_text', 11, 2);
function exploretech_change_woocommerce_custom_add_to_cart_text($text, $product) {
$extech_product_type = $product->get_type();
if ('simple' == $extech_product_type) {
return "Simple Product";
}
if ('variable' == $extech_product_type) {
return 'Variable Product';
}
return $text;
//You can also do this with switch statement
}