Hi,
I’m running into a problem with my custom script and maybe someone here can point me in the right direction.
We use the gform_pre_render filter on our form to process info from another form.
We have a product field, set to radiobuttons, 3 choices.
in the pre_render we add the prices based on the processed info. And we change the text of each choice to show the package name and price.
Basicly a custom product with 3 choices, not sure yet what the labels will say but will probebly be something like ‘Bronze/silver/gold’ or ‘Basic/premium/pro’. 3 tiers.
Functionally the form does everything well.
Except that the product name on checkout/notification is for example, ‘Premium’ as this is the original label we gave the second choice.
We want to change this - it should conain some info of the custom product.
Something like: Premium - Blue - 3000 words - priority order.
To change the product name on the checkout/notification, you must use the gform_product_info filter provided by Gravity Forms. This filter helps you edit product information before it is sent to payment gateways or shown in notifications.
You could try this code:
add_filter( 'gform_product_info', 'change_product_name', 10, 3 );
function change_product_name( $product_info, $form, $entry ) {
// Make sure it's the right form; replace 'your_form_id' with the actual form ID
if ( $form['id'] != 'your_form_id' ) {
return $product_info;
}
// Go through the products
foreach ( $product_info['products'] as $product_id => $product ) {
// If it's the product you want to change, replace 'your_product_field_id' with the actual field ID
if ( $product_id == 'your_product_field_id' ) {
// Modify the name as needed
$product_name = $product['name'];
$new_name = "{$product_name} - Blue - 3000 words - priority order";
// Update the product name
$product_info['products'][ $product_id ]['name'] = $new_name;
}
}
return $product_info;
}
Replace 'your_form_id' and 'your_product_field_id' with the actual form ID and product field ID. Also, adjust the $new_name variable to include the information you want. This code will update the product name during the checkout and notification processes, ensuring it contains the details you specified in $new_name.