Instead of copying the variation product name in the variation description, you can assign it to the description dynamically using this very simple hooked function:
add_filter( 'woocommerce_product_variation_get_description', 'wc_product_variation_get_description_filter', 10, 2 );
function wc_product_variation_get_description_filter( $description, $product ){
return $product->get_name();
}
Or you can also append it to the description using:
add_filter( 'woocommerce_product_variation_get_description', 'wc_product_variation_get_description_filter', 10, 2 );
function wc_product_variation_get_description_filter( $description, $product ){
return $description . $product->get_name();
}
Or prepend it with:
add_filter( 'woocommerce_product_variation_get_description', 'wc_product_variation_get_description_filter', 10, 2 );
function wc_product_variation_get_description_filter( $description, $product ){
return $product->get_name() . $description;
}
Code goes in functions.php file of the active child theme (or active theme). Tested and works.
On some cases when products have been created since a long time, the attributes are not displayed in the product variation name… You will need to add the following line:
add_filter( 'woocommerce_product_variation_title_include_attributes', '__return_true' );
Code goes in functions.php file of the active child theme (or active theme). Tested and works.
Related: