I am trying to change something in Woocommerce single product page but I could not find any post about it.
I would like to add the product name in front of all attributes label. Like on product page named 'Car 1' with attribute 'Brand', 'Model' I would have
Car 1 Brand : Honda
Car 1 Model : XXX
CodePudding user response:
You can use the attribute label filter hook woocommerce_attribute_label
add_filter( 'woocommerce_attribute_label', 'custom_attribute_label', 1000, 2 );
function custom_attribute_label( $label, $name ) {
global $product;
if ( is_a( $product, 'WC_Product' ) ) {
return $product->get_name() . ' ' . $label;
}
return $label;
}