Gform product info

Description

This filter is fired every time Gravity Forms request the list of products saved in an entry.

Use this filter to manipulate the list of products displayed in the entry detail and sent to third party services via Add-Ons such as the PayPal Add-On.

Usage

<?php
add_filter(“gform_product_info”, “change_product_list”, 10, 3);
?>

You can also specify this per form by adding the form id after the hook name.

<?php
add_filter(“gform_product_info_6”, “change_product_list”, 10, 3);
?>

Parameters

$product_info

(array) The array containing the product information. This array is in the following format:
Array
(
    [products] => Array
        (
            [1] => Array
                (
                    [name] => Some Product
                    [price] => $1,000.00
                    [quantity] => 2
                    [options] => Array
                        (
                            [0] => Array
                                (
                                    [field_label] => Option
                                    [option_name] => First Option
                                    [option_label] => Option: First Option
                                    [price] => 1
                                )

                        )

                )

        )

    [shipping] => Array
        (
            [name] => Shipping
            [price] => 5
        )

)

$form

(Form Object) Current form.

$lead

(array) Current Entry array

Examples

This example adds an Extra Fee line item if the quantity is greater than 200


<?php
add_filter("gform_product_info", "add_fee", 10, 3);
function add_fee($product_info, $form, $lead){

    $quantity = $product_info["products"][1]["quantity"];
    if($quantity > 200)
        $product_info["products"]["extra_fee"] = array("name" => "Extra Fee", "price" => 50, "quantity" => 1);

    return $product_info;
}
?>

Source Code

This filter is located in common.php

Search the Documentation