Skip to content
Advertisement

Hide specific variation attributes displayed in WooCommerce cart items

I want to hide specific variations from the cart page in Woocommerce, I was able to hide all the variation names but I want to keep 3 that need to be shown. The following code shows all the variations in the cart page, would someone know how to apply a filter in here?

JavaScript

For example I need to hide one of these:

JavaScript

Advertisement

Answer

You were not that far! You were just missing a simple conditional statement inside that foreach loop. Something like if ( $data['key'] !== 'Kcalperdag' ): should do the trick. I’ve tested it with a bogus array and it seems perfect.

We use the $data['key'] as a condition to chose if we want to display or not our content.

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement