Reputation: 65
Is it possible to change label text on "Size" and "Color" product attributes to something else on WooCommerce single variable product pages?
I tried this css code:
.single-product table.variations td.label > label{
visibility: hidden;
}
.single-product table.variations td.label > label:after {
content: 'NEW NAME';
visibility: visible;
}
But it changes both “color” and “Size” Variations. How do I separate them?
The label I want to change is pa_farge
:
Source code “Chrome Developer”
Upvotes: 0
Views: 3770
Reputation: 254398
2021 Update
Instead you can use the following WooCommerce dedicated filter hook to target a specific product attribute and changing its displayed label name as follows:
add_filter( 'woocommerce_attribute_label', 'custom_attribute_label', 10, 3 );
function custom_attribute_label( $label, $name, $product ) {
// For "pa_farge" attribute taxonomy on single product pages.
if( $name == 'pa_farge' && is_product() ) {
$label = __('NEW NAME', 'woocommerce');
}
return $label;
}
Code goes in functions.php file of the active child theme (or active theme). It should works.
Upvotes: 2