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 determines if a field should show in the Woocommerce cart
Usage
add_filter( 'wc_fp_include_field_in_cart', 'frm_show_field_in_cart', 10, 3 );
Parameters
- None
Examples
Include or exclude fields in cart
Use this hook to determine if a field should appear in the WooCommerce cart and the email confirmation from WooCommerce. Replace 123, 345, and 456 with the field IDs you want to show. Replace 987, 765, and 543 with the field IDs you want to remove from the cart.
add_filter( 'wc_fp_include_field_in_cart', 'frm_show_field_in_cart', 10, 3 );
function frm_show_field_in_cart( $display, $field, $value ) {
if ( in_array( $field->id, array( '123', '345', '456' ) ) ) {
$display = true;
} else if ( in_array( $field->id, array( '987', '765', '543' ) ) ) {
$display = false;
}
return $display;
}