This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.
This hook is used to adjust specific values or field names displayed in the cart or order.
Usage
add_filter('wc_fp_cart_item_data', 'modify_frm_woo_display', 10, 2);
Parameters
- $values (array)
- 'name' (string) - the field name
- 'value' (string) - the field value
- 'display' (string) - the displayed value
- $args (array)
- 'field' (object)
Examples
Adjust values displayed in cart
This example will remove the ($2.00) string that is added to any numeric value in the cart. Replace 123, 124, and 125 with your field IDs.
add_filter( 'wc_fp_cart_item_data', 'modify_frm_woo_display', 10, 2 );
function modify_frm_woo_display( $values, $args ) {
if ( in_array( $args['field']->id, array( 123, 124, 125 ) ) ) {
$end_position = strpos( $values['display'], ' (' );
$values['display'] = substr( $values['display'], 0, $end_position );
}
return $values;
}
Adjust values displayed in cart for specific field types
This example will remove the ($2.00) string that is added to any numeric value in the cart for specific field types. Replace number with the type of field in your cart.
add_filter( 'wc_fp_cart_item_data', 'modify_frm_woo_display_for_number_fields', 10, 2 );
function modify_frm_woo_display_for_number_fields( $values, $args ) {
if ( $args['field']->type =="number") {
$end_position = strpos( $values['display'], ' (' );
$values['display'] = substr( $values['display'], 0, $end_position );
}
return $values;
}