Skip to content

Instantly share code, notes, and snippets.

@braddalton
Created November 6, 2023 10:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save braddalton/3dd2b0b2ccf2558486cc7e8a1dac8638 to your computer and use it in GitHub Desktop.
Save braddalton/3dd2b0b2ccf2558486cc7e8a1dac8638 to your computer and use it in GitHub Desktop.
add_filter( 'woocommerce_available_variation', 'unset_variation_attribute', 10, 3 );
function unset_variation_attribute( $data, $product, $variation ) {
// Define the attribute name you want to hide (e.g., "Size")
$attribute_to_hide = 'Size';
// Unset the attribute if it exists in the variation data
if (isset($data['attributes']['attribute_' . sanitize_title($attribute_to_hide)])) {
unset($data['attributes']['attribute_' . sanitize_title($attribute_to_hide)]);
}
return $data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment