Answers for "how to change text of update cart in woocommerce"

1

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' );
}
Posted by: Guest on November-04-2020
0

woocommerce update cart price

function before_calculate_totals( $cart_obj ) {
 if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
  return;
 }
 // Iterate through each cart item
 foreach( $cart_obj->get_cart() as $key=>$value ) {  
   if( isset( $value['csCost'] ) ) {
    $getPrice = $value['data']->get_price();
     $price = $value['csCost'] + $getPrice;
     $value['data']->set_price( ( $price ) );
   }
   if( isset( $value['setCost'] ) ) {
    $getPrice = $value['data']->get_price();
     $price = $value['setCost'] + $getPrice;
     $value['data']->set_price( ( $price ) );
   }
  
 }
}
add_action( 'woocommerce_before_calculate_totals', 'before_calculate_totals', 10, 1 );
Posted by: Guest on May-08-2021
1

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' );
}
Posted by: Guest on November-04-2020
0

woocommerce update cart price

function before_calculate_totals( $cart_obj ) {
 if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
  return;
 }
 // Iterate through each cart item
 foreach( $cart_obj->get_cart() as $key=>$value ) {  
   if( isset( $value['csCost'] ) ) {
    $getPrice = $value['data']->get_price();
     $price = $value['csCost'] + $getPrice;
     $value['data']->set_price( ( $price ) );
   }
   if( isset( $value['setCost'] ) ) {
    $getPrice = $value['data']->get_price();
     $price = $value['setCost'] + $getPrice;
     $value['data']->set_price( ( $price ) );
   }
  
 }
}
add_action( 'woocommerce_before_calculate_totals', 'before_calculate_totals', 10, 1 );
Posted by: Guest on May-08-2021

Code answers related to "how to change text of update cart in woocommerce"

Browse Popular Code Answers by Language