Alejandro, you can use the gform_pre_render filter to populate fields in your form. Here is the documentation for the filter: http://www.gravityhelp.com/documentation/page/Gform_pre_render
[php]
<?php
// change the 7 here to your actual form ID
add_filter('gform_pre_render_7', 'populate_price');
function populate_price($form) {
// documentation: http://bit.ly/15C2BQu
// get the price from the custom field for this post
$price = get_post_meta(get_the_ID(), 'Precio', true);
// set the value of your product price to the value which was retrieved
if ($field['id'] == 1) {
$field['price'] = $price;
}
// always return the modified form
return $form;
}
That code will go in your theme's functions.php file and will need to be customized for the form ID (I used 7) and the field ID (I used 1). I used "Precio" for the meta key. That will need to match exactly as well.
Posted 11 years ago on Tuesday June 25, 2013 |
Permalink