If your calculation field is used to set or display as a price, you might want to hide the value in the cart meta and just display the price.
To do so, you can use this snippet:
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 calculation field value (not price) from cart | |
*/ | |
function prefix_remove_calculation_value( $value, $item ) { | |
if( $item['type'] == 'calculation' ) { | |
$value = ''; | |
} | |
return $value; | |
} | |
add_filter( 'pewc_filter_item_value_in_cart', 'prefix_remove_calculation_value', 10, 2 ); |
Here’s how to add the snippet.