gpecf_field_total (PHP)

  1. Description
  2. Usage
  3. Parameters
  4. Since
  5. Examples
    1. Add a Flat Rate of 5.5 to the Tax field with ID 4.

Description

Modify the calculation of the field total on submission.

This filter must be used with its JS counterpart to handle filtering the discount amount on the frontend.

Usage

Apply to all applicable fields on all forms.

add_filter( 'gpecf_field_total', 'my_custom_function' );

Apply to all applicable fields on a specific form.

add_filter( 'gpecf_field_total_FORMID', 'my_custom_function' );

Apply to a specific field on a specific form.

add_filter( 'gpecf_field_total_FORMID_FIELDID', 'my_custom_function' );

Parameters

  • field_total float

    The total for the current field.

  • args array

    The following properties are passed in the $args array.

    The amount of the current eCommerce field.

    • amountType string

      The type of amount.

    • products array

      The eCommerce field product.

    • productsType string

      The type of product.

    • includeShipping bool

      Whether to include shipping to the field total.

    • includeDiscounts bool

      Whether to include discount to the field total.

    • calculateByProduct bool

      Whether to calcululate by product.

    • field_id int

      The field ID of the current eCommerce field.

  • order array

    The order data.

  • entry array

    The current entry object.

  • total float

    The total for the current order.

Since

This filter is available since GP eCommerce Fields 1.2.18.

Examples

Add a Flat Rate of 5.5 to the Tax field with ID 4.

add_filter('gpecf_field_total_123_4', function( $field_total, $args, $order, $entry, $total ){

    return $field_total + 5.5;

},10,5);