Created
October 13, 2020 03:46
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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