Using Gravity Forms ‘gform_freshbooks_args_pre_create’ PHP filter

The gform_freshbooks_args_pre_create Gravity Forms PHP filter allows you to modify the invoice or estimate object before it is sent to Freshbooks.


To use this filter for all Freshbooks feeds, you can add the following line to your code:

add_filter('gform_freshbooks_args_pre_create', 'your_function_name', 10, 4);


  • $args (object): The Freshbooks invoice or estimate object containing client details, line items, and other relevant information.
  • $form (Form Object): The form that is currently being processed.
  • $entry (Entry Object): The entry that is currently being processed.
  • $feed (Feed Object): The feed that is currently being processed. Available from v2.2.3.

More information

See Gravity Forms Docs: gform_freshbooks_args_pre_create


Add tax

This example shows how to add tax to the line items:

add_filter('gform_freshbooks_args_pre_create', function($args, $form, $entry) {
    $lines = $args->lines;
    foreach ($lines as &$line) {
        $line['tax1Name'] = 'VAT';
        $line['tax1Percent'] = 20;
    $args->lines = $lines;
    return $args;
}, 10, 3);

Set the line items

This example shows how to set the invoice line items, including how to retrieve a value from a form field:

add_filter('gform_freshbooks_args_pre_create', function($args, $form, $entry) {
    $lines = array();
    $name = 'The name';
    $description = 'The description';
    $unit_cost = 10.50;
    $quantity = rgar($entry, '5'); // get the value from field 5
    $amount = $unit_cost * $quantity;

    $lines[] = array(
        'name' => $name,
        'description' => $description,
        'unitCost' => $unit_cost,
        'quantity' => $quantity,
        'amount' => $amount,

    $args->lines = $lines;
    return $args;
}, 10, 3);


Your code snippet should be placed in the functions.php file of your active theme.

Source Code

This filter is located in GFFreshBooks::export_feed() in class-gf-freshbooks.php.