cwcfp_after_checkout_fields_grouping

The action cwcfp_after_checkout_fields_grouping allows you to customize what is displayed after each conditional field.

Two arguments are passed to the action:

  • $repeat - The number that the field is being repeated. To illustrate, if a field will repeat three times, this action will be called all three times with $repeat changing from 1 to 2 to 3.
  • $field_id - The conditional field's ID, which is also found in the field settings.

Similar to After Field in conditional field settings

Previously, it was possible to insert custom HTML in the After Field setting for each conditional field. However, this had the potential for abuse from a security perspective, so we have removed this ability. Instead, you can customize with code.

To insert content after all instances of fields with ID 1 and 2

/**
 * The values after the "case" text are your field IDs.
 * This function will output the text shown in-between the "case" and "break" lines when displaying the field indicated by the value after "case".
 */
add_action( 'cwcfp_after_checkout_fields_grouping', 'your_custom_function', 10, 2 );
function your_custom_function( $repeat, $field_id ){
	switch ( $field_id ) {
		case 1:
			echo '<h3>Header</h3>This is some <strong>text</strong><br />Some other text on a new line';
			break;
		
		case 2:
			echo '<img src="http://example.com/img.png" alt="" />;
			break;
		
		default:
			// Nothing, unless there is common text you want on most, but not all fields.
			break;
	}
}

To insert content after the second instance of fields with ID 1 and 2

/**
 * The values after the "case" text are your field IDs.
 * This function will output the text shown in-between the "case" and "break" lines when displaying the field indicated by the value after "case".
 */
add_action( 'cwcfp_after_checkout_fields_grouping', 'your_custom_function', 10, 2 );
function your_custom_function( $repeat, $field_id ){
	if( 2 == $repeat ){
		switch ( $field_id ) {
			case 1:
				echo '<h3>Header</h3>This is some <strong>text</strong><br />Some other text on a new line';
				break;
		
			case 2:
				echo '<img src="http://example.com/img.png" alt="" />;
				break;
		
			default:
				// Nothing, unless there is common text you want on most, but not all fields.
				break;
		}
	}
}