“WooCommerce modifier le texte du bouton de panier” Réponses codées

Comment changer le bouton Ajouter au panier dans WordPress

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

Comment changer d'ajouter le bouton de texte du panier 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' );
}
deejay

WooCommerce modifier le texte du bouton de panier

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
}
Filthy Falcon

WooCommerce modifier le texte du bouton de panier

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";
}
Filthy Falcon

WooCommerce modifier le texte du bouton de panier

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";
}
Filthy Falcon

WooCommerce modifier le texte du bouton de panier

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;
}
Filthy Falcon

Réponses similaires à “WooCommerce modifier le texte du bouton de panier”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code