cwcfp_skip_first

Each conditional field's settings allow you to set a minimum quantity, so that a customer must purchase a minimum amount before the field will appear.

The cwcfp_skip_first filter is different. When a field is set to display it will skip the first X number of fields.

For example, if you have a class registration and the first student is going to be the one filling out their billing and shipping address, you may not need them to enter their name again in a conditional field. In this case you can skip the first conditional field. If the customer is purchasing a registration for 2 or more people, they will be shown the 2nd, 3rd, 4th, etc. fields to provide you with the other student's names.

This filter expects an integer value to be returned.

The filter is passed two arguments:

  • $number_to_skip: Default is 0
  • $field_id: The field ID that you are checking
add_filter( 'cwcfp_skip_first', 'your_custom_function', 10, 2 );
function your_custom_function( $number_to_skip, $field_id ){
	switch( $field_id ){
		// Skip the display of the first two fields on the checkout page for $field_id 1
		case 1:
			$number_to_skip = 2;
			break;
		// Default, you may not want to do anything different. This won't skip any fields.
		default:
			break;
	}
	return $number_to_skip;
}