Useful Snippets

Change WooCommerce Text String

Pinterest LinkedIn Tumblr

Change WooCommerce Text String

You can change any text in WooCommerce with this code. Add new case to change WooCommerce text string more than one.

case 'Add to cart':
$translation = __("Changed Text", "woocommerce");
break;
/*
*
* Change WooCommerce Text String
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
*
*/

function amc_change_woo_string( $translation, $text, $domain ){


	if ( !is_admin() && $domain == "woocommerce" )

	switch ($translation) {
		
		case 'Add to cart':
			$translation = __("Changed Text", "woocommerce");
		break;
		
		case 'Sale!':
			$translation = __("Changed Text", "woocommerce");
		break;

	}

	return $translation;

}

add_filter( 'gettext', 'amc_change_woo_string', 15, 3 );

Write A Comment