Hide variation info from cart item title in WooCommerce 3+

Viewed 9361

Ever since we upgraded to Woocommerce version 3 our order confirmations are showing huge titles that include the variation detail. I don't like how it looks and it breaks some important functionalities in some custom-made plugins.

Reference: Order Name Showing Variations since update to WC version 3

There is a filter that can be used to disable this data displaying in the title called woocommerce_product_variation_title_include_attribute_name from what I understand. But I have no idea where to apply the filter.

Is there a quick way to apply the filter to change it back to display as it did before?

4 Answers

A quick gotcha if you're using this filter to remove attributes from e-mail items. It appears that once an item has been written to an order the properties of it will not change.

add_filter( 'woocommerce_product_variation_title_include_attributes', '__return_false' );

As @freemason_17 pointed out, @LoicTheAztec's answer could potentially hide those details at other places as well so just to be sure I added a condition that would limit this to the cart page alone:

function custom_product_variation_title($should_include_attributes, $product){
    if(is_cart()) {
        $should_include_attributes = false;
        return $should_include_attributes;
    }
}
add_filter( 'woocommerce_product_variation_title_include_attributes', 'custom_product_variation_title', 10, 2 );

I use this:

/* -------------------- Remove variation names from title ------------------- */
add_filter( 'woocommerce_product_variation_title_include_attributes', '__return_false' );
add_filter( 'woocommerce_is_attribute_in_product_name', '__return_false' );
Related