Ive solved this problem.
Installing this plugin allows you to change the button text.
1) Download the plugin & install it to your wp-content/plugins folder (or use the Plugins menu through the WordPress Administration section)
2) Activate the plugin
3) Navigate to ** WooCommerce > Settings > Products > Change “add to cart” labels **.
Customise your labels.
4) Save and enjoy!
This is how I fixed that. Also I’m checking the language of the visitor (DE is standard), by ckecking if the URL contains /EN/ or /IT/…
add_filter( 'woocommerce_product_add_to_cart_text' , 'custom_woocommerce_product_add_to_cart_text' );
/**
* custom_woocommerce_template_loop_add_to_cart
*/
function custom_woocommerce_product_add_to_cart_text() {
global $product;
$url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
$text = "Details ansehen";
if (preg_match('/en/', $url)) {
$text = "View details";
} elseif (preg_match('/it/', $url)) {
$text = "Vedi i dettagli";
}
$product_type = $product->product_type;
switch ( $product_type ) {
case 'external':
return __( $text, 'woocommerce' );
break;
case 'grouped':
return __( $text, 'woocommerce' );
break;
case 'simple':
return __( $text, 'woocommerce' );
break;
case 'variable':
return __( $text, 'woocommerce' );
break;
default:
return __( $text, 'woocommerce' );
}
}
-
This reply was modified 3 years ago by
arsnovum.
Ive solved this problem.
Installing this plugin allows you to change the button text.
1) Download the plugin & install it to your wp-content/plugins folder (or use the Plugins menu through the WordPress Administration section)
2) Activate the plugin
3) Navigate to ** WooCommerce > Settings > Products > Change “add to cart” labels **.
Customise your labels.
4) Save and enjoy!
I COULDN’T UNDERSTAND WHICH PLUGIN?
Here is how I did it, in the case of simple products in WooCommece 3.5.1:
woocommerce/includes/class-wc-product-simple.php line 53 you’ll see ‘Read more’. Change that text to what you would like it to be (eg Shop Now).
The full line of code for this section is:
$text = $this->is_purchasable() && $this->is_in_stock() ? __( ‘Add to cart’, ‘woocommerce’ ) : __( ‘Read more’, ‘woocommerce’ );
Keep in mind with this solution if you update your plugin version in the future you’ll lose this customisation.