Skip to content

Instantly share code, notes, and snippets.

@kharissulistiyo
Created November 16, 2015 12:17
Show Gist options
  • Save kharissulistiyo/94717a59e7d1057c9f36 to your computer and use it in GitHub Desktop.
Save kharissulistiyo/94717a59e7d1057c9f36 to your computer and use it in GitHub Desktop.
Change WooCommerce "Add to cart" text.
<?php
/**
* Change add to cart text in single product page
*/
add_filter('woocommerce_product_add_to_cart_text', 'modify_add_to_cart_text', 10, 2);
function modify_add_to_cart_text($product){
global $product;
$text = $product->is_purchasable() && $product->is_in_stock() ? __( 'My add to cart', 'textdomain' ) : __( 'Read More', 'textdomain' );
return $text;
}
/**
* Change add to cart text in product archive
*/
add_filter('woocommerce_product_single_add_to_cart_text', 'modify_add_to_cart_text_in_single');
function modify_add_to_cart_text_in_single(){
return __('My add to cart', 'textdomain');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment