Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

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;
}
Source by exploretech.dev #
 
PREVIOUS NEXT
Tagged: #WooCommerce #Change #Add #To #Cart #Button #Text
ADD COMMENT
Topic
Name
2+3 =