Remove the Attribute From the Product Title

In a recent version of WooCommerce the developers made a tweak to how variable products are show when they only have one attribute. The chose attribute value is shown directly in the product title when, in example, the product is added to the cart.

I’ve noticed that not everyone likes this new feature and some asked to revert it back to how it was before.

Can we accommodate everyone? Yes, here is how.

Let’s Write Some Code!

I created a Pull Request not too long ago to add the filter woocommerce_is_attribute_in_product_name to the core of WooCommerce.

This filter can be used to show the attributes below the product title, like it was before the most recent version of WooCommerce.

You can add this code to the functions.php file in wp-content/themes/your-child-theme-name/ to do that:

add_filter( 'woocommerce_is_attribute_in_product_name', '__return_false' );

view raw


hosted with ❤ by GitHub

This code alone though is not enough. You will now see the attributes table below the product title, but also you will see the attribute in the product title.

To remove it from there, you need some more code:

* Removes the attribute from the product title, in the cart.
* @return string
function remove_variation_from_product_title( $title, $cart_item, $cart_item_key ) {
$_product = $cart_item['data'];
$product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key );
if ( $_product->is_type( 'variation' ) ) {
if ( ! $product_permalink ) {
return $_product->get_title();
} else {
return sprintf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $_product->get_title() );
return $title;
add_filter( 'woocommerce_cart_item_name', 'remove_variation_from_product_title', 10, 3 );

view raw


hosted with ❤ by GitHub

Using both these snippets together will make sure that you only show the attributes table like it was before, and the title of the product will be the one that you set in the Dashboard, with nothing added to it.

More Posts That You Might Like…

13 responses to “Remove the Attribute From the Product Title”

  1. This is great, thank you so much!
    I used only the part to add the attribute below the title and changed the rest manually by changing get_name to get_title within the templates (had them anyway in my childtheme because I already changed some code). I had some reasons to do it like this instead of using your function, too complicated to explain why. Anyway, if I change get_name to get_title in order/oder-details-item, it doesnt work. It says:
    “Fatal error: Uncaught Error: Call to undefined method WC_Order_Item_Product::get_title() in …/woocommerce/order/order-details-item.php:41 Stack trace: #0 /wp-content/plugins/woocommerce/includes/wc-core-functions.php(204)…..”
    Also with your function, it doesnt work in the order details (it shows no error but its simply not applied ). Sorry for my english, I hope you understand what I mean 🙂
    Any idea how to get rid of this error would be really appreciated!

    1. No idea for my question? Any help would be so appreciated! Many thanks in advance!

    2. Also looking for a solution to hide the attributes in order-details-item. Any help would be soooo appreciated. Many thanks in advance!

  2. Thank you so much for this, it was really helpful.

    1. You’re welcome Kasia!

  3. Hi again Nicola, I was wondering if it might be possible for you to help me modify your code to remove the product attributes from the titles on the Thank You page and the My Account > Orders page in the Order Details section. These use the woocommerce_order_item_name rather than woocommerce_cart_item_name. I have been trying to play around with what you’ve done and apply it here, but I’m not having any success making it work. Many thanks in advance!

    1. Same problem here. Did you find a way to fix it? It would be great if you’d share it! Many thanks in advance!

  4. this code below works fine for me except it does not remove the original a tag but just creates a new one, any suggestion on why is that?

  5. for a version that is a bit simpler than the above, you can also use a combination of these two oneliners:

    add_filter( ‘woocommerce_product_variation_title_include_attributes’, ‘__return_false’ );
    add_filter( ‘woocommerce_is_attribute_in_product_name’, ‘__return_false’ );

  6. This code works great during add to cart and during checkout. However, this attribute is re-added to the title on the successful order page and in the successful order e-mail. Does’t seem to stay away. Is it possible to keep the coding removed after the order is fulfilled and in order e-mails?

  7. Hi, how do you remove the attribute on the order details page?

    Something along the lines of this:

    add_filter( ‘woocommerce_order_item_name’, ‘remove_variation_from_product_title’, ‘__return_false’ );

    Thank you

  8. Saved my day – thanks a lot!!

  9. Kevin Minderhout Avatar
    Kevin Minderhout

    For people struggling with the e-mail templates. These two filters will do the job but it appears that once an item has been written to an order the name will not change. This threw me through a loop.

    add_filter( ‘woocommerce_product_variation_title_include_attributes’, ‘__return_false’ );
    add_filter( ‘woocommerce_is_attribute_in_product_name’, ‘__return_false’ );

Leave a Reply



Receive new articles from this blog directly in your inbox!

No spam guaranteed!

Blog at

%d bloggers like this: