Skip switch statement if value is empty

This commit is contained in:
Alfredo Sumaran 2021-05-10 14:54:40 -05:00
parent 5a5a808182
commit 195acd0866
1 changed files with 17 additions and 15 deletions

View File

@ -696,21 +696,23 @@ class WC_Checkout {
$type = sanitize_title( isset( $field['type'] ) ? $field['type'] : 'text' ); $type = sanitize_title( isset( $field['type'] ) ? $field['type'] : 'text' );
switch ( $type ) { if ( '' !== $value ) {
case 'checkbox': switch ( $type ) {
$value = 1; case 'checkbox':
break; $value = 1;
case 'multiselect': break;
$value = implode( ', ', wc_clean( $value ) ); case 'multiselect':
break; $value = implode( ', ', wc_clean( $value ) );
case 'textarea': break;
$value = wc_sanitize_textarea( $value ); case 'textarea':
break; $value = wc_sanitize_textarea( $value );
case 'password': break;
break; case 'password':
default: break;
$value = wc_clean( $value ); default:
break; $value = wc_clean( $value );
break;
}
} }
$data[ $key ] = apply_filters( 'woocommerce_process_checkout_' . $type . '_field', apply_filters( 'woocommerce_process_checkout_field_' . $key, $value ) ); $data[ $key ] = apply_filters( 'woocommerce_process_checkout_' . $type . '_field', apply_filters( 'woocommerce_process_checkout_field_' . $key, $value ) );