You can use the following then. Just make sure to replace the Field IDs (i.e. 8, 9 and 10) with yours.
add_filter("gform_pre_render", "populate_price");
function populate_price($form){
//only applies to form id 165
if($form["id"] != 165)
return $form;
global $post;
//Setting price for product field id 8. Replace 8 with your actual field id. You can get the field id by looking at the input name in the markup.
foreach($form["fields"] as &$field)
if($field["id"] == 8){
$price = get_post_meta($post->ID, "_widget_1_price", true);
$field["basePrice"] = $price;
}
else if($field["id"] == 9){
$price = get_post_meta($post->ID, "_widget_2_price", true);
$field["basePrice"] = $price;
}
else if($field["id"] == 10){
$price = get_post_meta($post->ID, "_widget_3_price", true);
$field["basePrice"] = $price;
}
return $form;
}
Posted 13 years ago on Thursday July 14, 2011 |
Permalink