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 = 'https://' . $_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 6 years, 10 months ago by arsnovum.