1. Home
  2. Docs
  3. WooCommerce Order Builder
  4. Actions and Filters
  5. wwob_add_product_group_field

wwob_add_product_group_field

Use this action to add an additional field within product field inside WWOB metabox.

The following example will add a recommendation field to products:

[enlighter lang=”php”]
add_action( ‘wwob_add_product_group_field’, ‘wwob_add_product_group_field’, 3, 10 );
function wwob_add_product_group_field($cmb_repeat, $group_repeat, $prefix_field){

$cmb_repeat->add_group_field( $group_repeat, array(
‘name’ => ‘Recommendation’,
‘id’ => $prefix_field.’recommendation’,
‘type’ => ‘text’,
‘classes’ => ‘wwob-parameters’,
) );

}
[/enlighter]

The following example will display recommendation field value directly after each product items:

[enlighter lang=”php”]
add_action( ‘wwob_after_product_item’, ‘do_something_after_product_items’, 2, 10 );
function do_something_after_product_items($form_id, $field){

$recommendation= !empty($field[‘wwob_field_recommendation’]) ? $field[‘wwob_field_recommendation’] : “”;
echo $recommendation;

}
[/enlighter]

Placement

This code should be placed in the functions.php file of your active theme.

Note

Available field types can be found on CMB2 Wiki