You forgot to define the required inputType
in your properties.
The correct way to define a dynamic product in gravityforms is to declare it as a type => product
, define an inputType
like singleproduct
and don′t forget to add the inputs
array to the properties if you are using singleproduct
as inputType
.
Example:
$props = array(
'id' => $new_field_id,
'type' => 'product',
'inputType' => 'singleproduct',
'label' => $beer->post_title,
'basePrice' => floatval( $beer->preis ),
'enableCalculation' => true,
'inputs' => array(
array(
'id' => $new_field_id.'.1',
'label' => $beer->post_title,
'name' => 'param_product'
),
array(
'id' => $new_field_id.'.2',
'label' => 'Price',
'name' => 'param_price'
),
array(
'id' => $new_field_id.'.3',
'label' => 'Quantity',
'name' => 'param_qty'
),
),
);
Available inputTypes for a gravityforms product are:
- singleproduct
- select
- radio
- price
- hiddenproduct
- calculation
Also try to add a dynamic totals calculation to your form like this:
$calculation = GF_Fields::create(array(
'id' => 1000,
'label' => 'Totals',
'type' => 'total',
));
array_push( $form['fields'], $calculation );
Your Gravityforms Hook should work:
add_filter( 'gform_form_post_get_meta_1', 'populate_beers' );
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…