Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pramodjodhani/8e75eb10538eef6c379bdef0b2809f82 to your computer and use it in GitHub Desktop.
Save pramodjodhani/8e75eb10538eef6c379bdef0b2809f82 to your computer and use it in GitHub Desktop.
<?php
/**
* Orderable - code snippet to hide the product addon price on mini cart.
*/
add_action(
'init',
function() {
remove_filter( 'woocommerce_get_item_data', array( 'Orderable_Addons_Pro_Fields', 'display_field_value_on_cart' ), 10 );
add_filter(
'woocommerce_get_item_data',
function( $item_data, $cart_item ) {
if ( empty( $cart_item['orderable_fields'] ) ) {
return $item_data;
}
foreach ( $cart_item['orderable_fields'] as $field ) {
if ( empty( $field['value'] ) ) {
continue;
}
$value = is_array( $field['value'] ) ? implode( ', ', array_filter( $field['value'] ) ) : $field['value'];
if ( empty( $value ) ) {
continue;
}
$item_data[] = array(
'key' => $field['label'],
'value' => $value,
);
}
return $item_data;
},
10,
2
);
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment