Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author webaware

    (@webaware)

    G’day Gary.

    There’s a filter ‘gfeway_invoice_desc’ for the invoice description, and a filter ‘gfeway_invoice_ref’ for the invoice reference. One-off payments also have ‘gfeway_invoice_option1’ (and 2, 3) filters whereas recurring payments have ‘gfeway_invoice_cust_comments’.

    You use them like this (example for invoice description):

    add_filter('gfeway_invoice_desc', 'my_gfeway_invoice_desc', 10, 2);
    
    /**
    * filter the eWAY invoice description for a Gravity Form post
    * @param string $desc the description before filtering
    * @param array $form the Gravity Form object
    * @return string
    */
    function my_gfeway_invoice_desc($desc, $form) {
        // set by form ID
        switch ($form['id']) {
            case 1:
                $desc = 'Donate form';
                break;
    
            case 6:
                $desc = 'Recurring payment form';
                break;
        }
    
        // set by specified field
        foreach($form['fields'] as $field) {
            if ($field['label'] == 'Invoice Description') {
                $desc = rgpost('input_' . $field['id']);
                break;
            }
        }
    
        return $desc;
    }

    Put that code into a simple plugin, or add to your theme’s functions.php file.

    cheers,
    Ross

    Thread Starter mycustom

    (@mycustom)

    Hi Ross,

    Awesome thanks for the quick reply.

    I have added the fuction.php to my child theme and all seems to be in working order. However the Reference and invoice details are not displaying in the required fields with eWAY.

    Refere to this link https://www.yatessecurity.com.au/Customer Details.docx you can see the sections I have highlighted in Bold Red. The Invoice description is being taken from somewere else that I am not sure of but the Reference is N/A.
    Thanks,
    Gary

    Thread Starter mycustom

    (@mycustom)

    Sorry link should be
    Regards,
    Gary

    Plugin Author webaware

    (@webaware)

    G’day Gary,

    I’ve tested the filters, and they do set the invoice description and invoice reference in the Customer Details section.

    I’ve just added a new filter for setting the invoice transaction reference in the Transaction Details section: “gfeway_invoice_trans_number”.

    NB: this field is limited to only 16 characters (eWAY intends it to hold an invoice number or similar), so you probably want to use “gfeway_invoice_ref” anyway as that can hold up to 255 characters.

    Here’s some code that sets all three, from fields in the form:

    /**
    * filter the eWAY invoice description for a Gravity Form post
    * @param string $desc the description before filtering
    * @param array $form the Gravity Form object
    * @return string
    */
    function test_gfeway_invoice_desc($desc, $form) {
        // set by named field
        foreach($form['fields'] as $field) {
            if ($field['label'] == 'Invoice Description') {
                $desc = rgpost('input_' . $field['id']);
                break;
            }
        }
    
        return $desc;
    }
    
    add_filter('gfeway_invoice_desc', 'test_gfeway_invoice_desc', 10, 2);
    
    /**
    * filter the eWAY invoice reference for a Gravity Form post
    * @param string $ref the reference before filtering
    * @param array $form the Gravity Form object
    * @return string
    */
    function test_gfeway_invoice_ref($ref, $form) {
        // set by named field
        foreach($form['fields'] as $field) {
            if ($field['label'] == 'Invoice Reference') {
                $ref = rgpost('input_' . $field['id']);
                break;
            }
        }
    
        return $ref;
    }
    
    add_filter('gfeway_invoice_ref', 'test_gfeway_invoice_ref', 10, 2);
    
    /**
    * filter the eWAY invoice transaction no. for a Gravity Form post
    * @param string $ref the trans no. before filtering
    * @param array $form the Gravity Form object
    * @return string
    */
    function test_gfeway_invoice_trans_number($transNumber, $form) {
        // set by named field
        foreach($form['fields'] as $field) {
            if ($field['label'] == 'Transaction Number') {
                $transNumber = rgpost('input_' . $field['id']);
                break;
            }
        }
    
        return $transNumber;
    }
    
    add_filter('gfeway_invoice_trans_number', 'test_gfeway_invoice_trans_number', 10, 2);

    cheers,
    Ross

    Thread Starter mycustom

    (@mycustom)

    Thanks Ross,
    All works great now.
    Regards,
    Gary

    Do you have to enter the form and field Id in the above example to get it to work?

    Plugin Author webaware

    (@webaware)

    G’day Paul,

    For your use, you’d need to use the name of the field with the description in it, e.g.

    add_filter('gfeway_invoice_desc', 'my_gfeway_invoice_desc', 10, 2);
    
    /**
    * filter the eWAY invoice description for a Gravity Form post
    * @param string $desc the description before filtering
    * @param array $form the Gravity Form object
    * @return string
    */
    function my_gfeway_invoice_desc($desc, $form) {
        // set by specified field
        foreach($form['fields'] as $field) {
            if ($field['label'] == 'What would you like to donate to') {
                $desc = rgpost('input_' . $field['id']);
                break;
            }
        }
    
        return $desc;
    }

    cheers,
    Ross

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Send specific field information to eWAY’ is closed to new replies.