Created
August 31, 2022 06:42
-
-
Save pramodjodhani/8e75eb10538eef6c379bdef0b2809f82 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* 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