Created
November 16, 2015 12:17
-
-
Save kharissulistiyo/94717a59e7d1057c9f36 to your computer and use it in GitHub Desktop.
Change WooCommerce "Add to cart" text.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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