Search
 
SCRIPT & CODE EXAMPLE
 

PHP

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' );
}
Comment

change cart totals text woocommerce

add_filter( 'gettext', 'change_cart_totals_text', 20, 3 );
function change_cart_totals_text( $translated, $text, $domain ) {
    if( is_cart() && $translated == 'Cart totals' ){
        $translated = __('Your custom text', 'woocommerce');
    }
    return $translated;
}
Comment

woocommerce show before add to cart button

add_action( 'woocommerce_before_add_to_cart_button', 'misha_before_add_to_cart_btn' );

function misha_before_add_to_cart_btn(){
	echo 'Some custom text here';
}
Comment

Woocommerce change add to cart message

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;
}
Comment

WooCommerce Change Add To Cart Button Text

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) {
    return "My Custom Text";
}
Comment

WooCommerce Change Add To Cart Button Text

add_filter('woocommerce_product_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) {
    return "My Custom Text";
}
Comment

WooCommerce Change Add To Cart Button Text

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) {
   if ('31' ==$product->get_id()) {
     return 'Customized Text';
   }
   $product_categories = $product->get_category_ids();
   if (in_array('19', $product_categories)) {
      //if product has category with id=19 (say Tshirts)
      return 'ExploreTech Customized Text';
    }
    return $text;
}
Comment

WooCommerce Change Add To Cart Button Text

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
}
Comment

PREVIOUS NEXT
Code Example
Php :: loop in loop wordpress 
Php :: wp image size names 
Php :: how laravel return the old value 
Php :: convert Persian/Arabic numbers to English numbers PHP 
Php :: how to data save usigng request all laravel 
Php :: explode example in php 
Php :: check website ssl certificate using php 
Php :: TRANSACTON LARAVEL QUERY BUILDER 
Php :: laravel blade check if request url matches 
Php :: if else if php code reflect 
Php :: laravel check if email is real 
Php :: get value from url in laravel blade 
Php :: laravel @disabled in laravel-9 
Php :: how to disable opcache 
Php :: update image in database using php 
Php :: laravel get data from request 
Php :: get file size in php 
Php :: custom autoload without composer 
Php :: qr code generator php 
Php :: search laravel 
Php :: delete and return response and nocontent laravel 
Php :: check the request type in laravel 
Php :: i+= in php 
Php :: laravel get data in pivot table 
Php :: codeigniter 3 or where in 
Php :: validation laravel 
Php :: json_encode alternative 
Php :: get redirect url for laravel socialite with api 
Php :: php artisan add row in table 
Php :: enum in migration laravel 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =