Skip to content

Instantly share code, notes, and snippets.

@rochow
Created October 13, 2020 03:46
Show Gist options
  • Save rochow/6600858273a5076a5dbf41c6314fe60a to your computer and use it in GitHub Desktop.
Save rochow/6600858273a5076a5dbf41c6314fe60a to your computer and use it in GitHub Desktop.
Remove variation data from WooCommerce Cart & Emails (used by YITH Product Addons and similar too) #woocommerce #yith-product-addons
<?php
// Remove bits of variation data from WooCommerce cart & emails we don't want to show
add_filter( 'woocommerce_get_item_data', 'mr_filter_variable_item_data', 10, 2 );
function mr_filter_variable_item_data( $item_data, $cart_item ) {
// Labels we want to remove
$items_to_remove = [ 'Base price' ];
// Remove any items where the label matches
foreach( $item_data as $key => $data ) {
if( in_array( $data['name'], $items_to_remove ) ) {
unset( $item_data[ $key ] );
}
}
return $item_data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment