Gravity Wiz

Magically enhanced tutorials, snippets and plugins for Gravity Forms!

  • Gravity Perks
    • Gravity Perks
    • Tutorials & Snippets
    • About
  • Support
    • Documentation
    • Support
    • Account

Gravity Forms eCommerce Fields

Make Gravity Forms more eCommerce-friendly with support for Tax, Discounts, and Subtotal fields plus a bunch of other helpful eCommerce features.

This plugin is part of Gravity Perks, a suite of 32+ essential Gravity Forms addons with support you can count on.

  • View All Perks
  • Buy Gravity Perks

What does it do?

With the GF eCommerce Fields plugin you can easily add eCommerce field types to your Gravity Forms. The new pricing fields include Discount, Tax, and Subtotal. This plugin also improves upon the functionality of Gravity Forms’ Coupons and Shipping fields.

GF eCommerce also adds support for special merge tags for including the subtotal, coupon and discount amounts in calculation-enabled fields along with a handy merge tag for displaying the order summary in your confirmations and notifications.

gp-ecommerce-fields-featured

Features

  • New pricing fields.
    New Discount, Tax, and Subtotal fields allow you to create advanced eCommerce forms.
  • Adjustable taxes.
    New Tax field calculates and applies percentage discount based on the total or a specific products.
  • Flexible discounts.
    New Discount field applies flat or percentage discount to the total or specific products. Use conditional logic to only apply the discount when certain conditions are met.
  • Helpful subtotals.
    Help your users better understand their orders; show the subtotal before shipping, coupons and taxes have been applied.
  • Tight integration with existing Gravity Forms fields.
    The Coupons and Shipping fields have been improved to better integrate with Subtotals, Discounts and Taxes.
  • Calculation-ready merge tags.
    Make custom calculations based on the subtotal or coupon and discount amounts with Gravity Forms’ calculation feature and GF eCommerce merge tags.
  • Improved order summary.
    We’ve completely revamped the order summary to support the new pricing fields and make it even easier to digest.
  • Seamless, easy-to-use UI.
    Integrates directly with the Gravity Forms toolbar. A single click activates the preview.
  • Automatic updates.
    Get updates and latest features right in your dashboard.
  • Awesome support.
    We’re here to help! And we mean it.

Documentation

  1. How do I enable this functionality?
  2. Feature Details
    1. Fields
      1. Tax Field
      2. Subtotal Field
      3. Discount Field
      4. Coupon Field
      5. Shipping Field
    2. Merge Tags
      1. {subtotal}
      2. {coupons}
      3. {discounts}
      4. {order_summary}
  3. Developer’s Notes
  4. FAQs
    1. How can I programmatically set the discount amount?
  5. Hooks
  6. Related Articles

How do I enable this functionality?

This document assumes you know how to create a form. For information on creating a form, visit Creating a form.

Fields described in this document can be found under “Pricing fields”. Pricing fields allow you to add fields to your form to calculate pricing for selling goods and services.

gp-ecommerce-fields-pricing-fields

Feature Details

Fields

Tax Field

The Tax Field allows you to add a preconfigured tax to the form. End users can view the Field Label, the amount to be paid, and the Description.

The Tax Field supports percentage values only. You can apply the tax to all products, specific products or all products except one(s) selected. You can add multiple Tax Fields to the form.

The tax influences the Total amount. The tax is not included in the Subtotal and Discount amounts.
gp-ecommerce-fields-tax-settings
Subtotal Field

The Subtotal Field is used to display the sum of the line item total prices in the form. As the user selects products and options, the subtotal automatically updates. End users can view the Field Label, the subtotal amount, and the Description.

Subtotal does not include tax and discounts. You can select if to calculate subtotal values for all listed products, specific products or to exclude the selected products. You can add multiple Subtotal Fields to the form.

You can add a subtotal for a group of products.
gp-ecommerce-fields-subtotal-settings
Discount Field

The Discount Field allows you to add a preconfigured discount to the form. End users can view the Field Label, the amount to be discounted, and the Description.

The amount to be discounted can be a flat rate adjustment or a percentage of the price of the product. You can apply the discount to the form total, specific products or apply to all products except one(s) selected. You can add multiple Discount Fields to the form.

gp-ecommerce-fields-discount-settings
Coupon Field

Coupons are price reductions. The Coupon Field is available when you use the Gravity Forms Coupons Add-on. The Coupon Field displays the Field Label, the coupon code entry field and the Description on your form. The end user types in the code to the field and clicks the displayed “Apply” button to reveal the new total.

Coupons reduce the amount subject to the Tax. When GF eCommerce Fields is active, coupon automatically will not include shipping. Coupons will also not influence the value of Subtotal or Discount fields.

Shipping Field

The Shipping Field is a default Gravity Forms field allowing a shipping fee to be added to the form. GF eCommerce Fields alters the default functionality. End users can view the field label, the shipping fee to be paid, and the description.

The shipping value is not included in the subtotal, discounts or coupons. The shipping charge is always included in Tax fields and the form total.

Merge Tags

Gravity Forms uses merge tags to allow you to populate dynamic data in various contexts throughout the plugin. GF eCommerce Fields expands this functionality to provide the {subtotal}, {coupons}, and {discounts} merge tags for use in calculation formulas and other places Gravity Forms merge tags are supported. GFEC also provides support for a {order_summary} for displaying the order summary in notifications and confirmations.

Gravity Forms uses merge tags to allow you to populate submitted field values and other dynamic information in calculation of the field values, notification emails, post content templates, etc.

gp-ecommerce-fields-merge-tags-formulagp-ecommerce-fields-merge-tags

The following merge tags can be used in calculation of field values.

{subtotal}

The sum of all product prices. This merge tag can be used in calculation of Number and Product Fields in calculation formulas. The result of the formula is dynamically populated as the value for this field.

When used in a Calculated Product, the Calculated Product will automatically exclude itself when calculating the subtotal.
{coupons}

The sum of all coupon deductions. This merge tag can be used in calculation of Number and Product Fields in calculation formulas.

{discounts}

The sum of all discount and coupons deductions. This merge tag can be used in calculation of Number and Product Fields in calculation formulas.

{order_summary}

Gravity Forms provides an order summary that is automatically appended to any entry that has a Gravity Forms Pricing field. It can be inserted into confirmations and notifications using {pricing_fields} merge tag.

GF eCommerce Fields improves on this summary to better support the new Pricing fields it provides. It also adds the improved {order_summary} merge tag as a replacement for {pricing_fields}.

The {order_summary} merge tag displays a preformatted HTML table containing the order summary (the list of products, subtotal, discount, coupons, shipping, taxes and grand total). This merge tag can be used in areas such as notifications and confirmations to preview the order information.

gp-ecommerce-fields-featured-order-summaryExample output of the {order_summary} merge tag.
Do not use {pricing_fields} merge tag; use {order_summary} instead. GF eCommerce Fields changes how some default pricing fields are calculated. The {pricing_fields} merge tag can sometimes display incorrect information.

Developer’s Notes

GF eCommerce Fields makes some changes to how Gravity Forms processes pricing fields. If you are a developer, you will want to be aware of the following.

  • Field types are processed in this order:
    Subtotal › Discounts › Coupons › Shipping › Taxes › Total
  • Shipping is automatically excluded from Discounts and Coupons.
  • Shipping is automatically included in Taxes and Total.
  • Coupons are displayed in the totals section of the order summary, rather than the products list.

FAQs

How can I programmatically set the discount amount?

If you’d like to set the discount for a field programmatically, use this snippet as a blueprint. Follow these steps to use the snippet:

  1. Paste everything below the opening <?php line to your theme’s functions.php file.
  2. Update 123 to your Form ID.
  3. Update 2 to your Discount field ID and set the discount amount.

Hooks

  • gpecf_apply_custom_order_summary
  • gpecf_discount_total (JS)
  • gpecf_discount_total (PHP)
  • gpecf_order_labels
  • gpecf_order_sumary_markup
  • gpecf_order_summary
  • gpecf_styles
Gravity Forms has hundreds of hooks. Check out our Gravity Forms Hook Reference for the most thorough guide to Gravity Forms’ many actions and filters.

Related Articles

  • How to Apply Discounts with Gravity Forms
  • How to Calculate Tax or VAT with Gravity Forms
  • Gravity Forms eCommerce Tutorial | The Comprehensive Guide
  • How to Setup Gravity Forms to Accept Stripe Payments

Perk Deets

  • Version 1.0.41
  • Updated August 17, 2020
  • Released February 26, 2017
  • View Changelog

Changelog

1.0.41

  • Fixed dependency on jQuery.migrate that has been removed as of WordPress 5.5.
  • Fixed issue with Gravity Forms 2.5 where markup was being rendered in the field label.
  • Added $modifiers as an 8th parameter to the gpecf_order_sumary_markup filter.
  • Added acceptance tests. (#5)
  • Added 14 new acceptance tests.
  • Added new tests and edited exsisting tests.

1.0.40

  • Fixed notices generated when updating an entry (via the GF entry update screen) with a calculation-enabled field containing a GPECF merge tag.

1.0.39

  • Added support for showing formatted value when fetched via the GFAddon::get_value_entry_detail() method.

1.0.38

  • Added gpecf_order_sumary_markup to allow modifying the order summary markup.

1.0.37

  • Fixed invalid value when using the {discounts} merge tag in a Calculated Product field.

1.0.36

  • Fixed issue where Tax fields that excluded products could result in unexpected values when product fields contained negative values.

1.0.35

  • Fixed notices generated when no quantity was specified for a Calculated Product field.

1.0.34

  • Added acceptance tests.
  • Fixed recursion with Calculated Product field containing {subtotal} merge tag.
  • Fixed issue where Calculated Product field containing {subtotal} merge tag could result in infinite recursion.

1.0.33

  • Fixed performance issue on AJAX-enabled forms when many Calculated Products were present.

1.0.32

  • Added compatibility fix for upcoming GF Coupons 2.9.3.

1.0.31

  • Fixed fatal error that could occur when Gravity Perks was active but Gravity Forms was not.
  • Updated to use GP_Plugin class.

1.0.30

  • Fixed issue with versions of GF prior to 2.4.15 (which is unreleased at the time of this commit).
  • Fixed issue where Calculated Number fields containing only GPECF merge tags (e.g. {subtotal}) were not recalculated when Calculated Product fields' prices changed.

1.0.29

  • Fixed missing <tr> in order summary header which caused PDF generators to render the order summary correctly.

1.0.28

  • Fixed issue where product-specific Tax fields failed to account for coupon discounts.

1.0.27

  • Fixed issue where Discount fields which excluded specific products were not correctly exempted when calculating an excluded product's individual price.

1.0.26

  • Fixed notice generated in PHP 7.3.

1.0.25

  • Fixed issue where {discounts} merge tag was not correctly calculated when no Coupon field was present on the form.

1.0.24

  • Fixed notice of missing "item_index" with GF 2.4.

1.0.23

  • Added PHP and JS filter "gpecf_discount_total" to allow filtering the calculated discount for a Discount field.

1.0.22

  • Fixed error with GF 2.4 where field objects now have a "fields" property.

1.0.21

  • Added support for using choice values in order summary: {order_summary:value}.

1.0.20

  • Fixed issue where product-specific discounts were incorrectly calculated when the product total was 0.

1.0.19

  • Fixed issue where {subtotal} merge tag replacement was inaccurate when multiple Calculation Product fields contained a {subtotal} merge tag.

1.0.18

  • Fixed order-of-events issue where calculations containing the {coupons} were recalculated prematurely.

1.0.17

  • Added support for style/script minimization.
  • Fixed bug where field values were not fetched correctly when reevaluating calculations (w/ GF 2.3).

1.0.16.6

  • Fixed JS error where multiple forms were on the page and only one implemented GF calculations.

1.0.16.5

  • Fixed JS error where multiple forms were on a page and current form contained an eCommerce merge tag but no coupon field.

1.0.16.4

  • Fixed issue where incorrect parameter type would cause fatal error on negative total fix.

1.0.16.3

  • Fixed issue where Gravity Forms allows negative totals.

1.0.16.2

  • Fixed issue where flat, product-specific discounts would discount more than the applicable products' total.

1.0.16.1

  • Fixed issue where flat discounts were not correctly calculated for product-specific tax fields.

1.0.16

  • Fixed infinite loop conflict with GP Conditional Pricing (requires latest version of Gravity Forms as well).

1.0.15

  • Added 'gpecf_order_summary' filter to allow filtering the $order_summary before it is rendered.

1.0.14

  • Added support for showing subtotal if custom-added tax/discount line items exist in order summary.

1.0.13

  • Added support for showing custom-added tax/discount line items in the order summary.

1.0.12

  • Fixed issue where calculation-enabled fields were recalculated even when hidden via conditional logic.

1.0.11

  • Fixed a JS issue where fields hidden via conditional logic would always trigger a change event creating an infinite loop.
  • Fixed issue where change event was triggered for fields when values were the same but of different types (e.g. "40" != 40).
  • Fixed issue where in some browsers, when previously entered values were saved, refreshing the page would result in a mismatch between the displayed value and the input value.

1.0.9

  • Updated field-specific merge tags to automatically display as currency (100 => $100.00).

1.0.8

  • Updated issue where product-specific taxes were calculated incorrectly when no discount applied. Bug introduced by 1.0.7.

1.0.7

  • Fixed issue where product-specific taxes did not correctly deduct product-specific discounts.

1.0.6

  • Fixed issue where including multiple GPEC merge tags in a formula would result in 0; this was caused only the first instance of the GPEC merge tag being replaced.

1.0.5

  • Fixed issue where conditional logic dependent on a Calculation-enabled field that contained an ecommerce merge tag did not evaluate correctly.

1.0.4

  • Added translation support.

1.0.3

  • Updated GP_Ecommerce_Fields::get_order() to use choice text by default.

1.0.2

  • Fixed issue with WC GF Product Add-ons where reprocessed calculations were always blank.

1.0.1

  • Fixed issue with GP Conditional Pricing were Calculation fields that contained an ecommerce merge tag were not always updated when product's price changed.

1.0

  • Ready for production use.
  • Added support for registering eCommerce field types as product field types.
  • Fixed issue where reprocessing calculations would add a new row for the updated value instead of updating the existing values.
  • Updated GP_Bootstrap to v1.2.

1.0.beta1.7

  • Fixed issue where non-US money formats were not correctly rendered on the frontend fields.

1.0.beta1.6

  • Added gpecf_order_labels filter for readily modifying labels used in order summary.

1.0.beta1.5

  • Fixed issue where eCommerce field values were not capped at two decimals which caused miscellaneous conflicts.

1.0.beta1.4

  • Fixed issue where Calculated Products were not captured by GF payment add-ons.

1.0.beta1.3

  • Updated integration with WC GF Product Add-ons to now show eCommerce fields in cart description.

1.0.beta1.2

  • Fixed documentation URL (previously resulted in 404).

1.0.beta1.1

  • Fixed fatal error when gf_coupons() was not available.

1.0.beta1.0

  • Fixed issue where percentage amounts could exceed 100.
  • Fixed issue where unconfigured Tax & Discount fields would break form rendering.
  • Updated GF min required version.

1.0.alpha1.4

  • Updated Discounts to be deducted before coupons are applied.
  • Updated GP_Ecommerce_Fields::has_coupon() to check $entry if no coupon found in $order.

1.0.alpha1.3

  • Added support for saving value to entry for Subtotal, Discount & Tax; allows entries to be filtered/sorted by these values on Entry List.
  • Fixed issue where percentage amounts were not correctly formatted after saving form in Form Editor.
  • Fixed issue where {subtotal} value was not formatted as currency when used outside of a calculation formula.

1.0.alpha1.2

  • Fixed issue where {order_summary} merge tag was not replaced.

1.0.alpha1.1

  • Fixed issue where Subtotal field did not correctly filter products.

1.0.alpha1.0

  • Ready for testing!

All Perks

  • GF Auto Login
  • GF Better User Activation
  • GF Blacklist
  • GF Conditional Logic Dates
  • GF Conditional Pricing
  • GF Copy Cat
  • GF Date Time Calculator
  • GF Disable Entry Creation
  • GF Easy Passthrough
  • GF eCommerce Fields
  • GF Email Users
  • GF Expand Textareas
  • GF File Upload Pro
  • GF Limit Checkboxes
  • GF Limit Choices
  • GF Limit Dates
  • GF Limit Submissions
  • GF Live Preview
  • GF Media Library
  • GF Multi-Page Navigation
  • GF Nested Forms
  • GF Pay Per Word
  • GF PayPal One-time Fee
  • GF Placeholder
  • GF Populate Anything
  • GF Post Content Merge Tags
  • GF Preview Submission
  • GF Price Range
  • GF Read Only
  • GF Reload Form
  • GF Terms Of Service
  • GF Unique ID
  • GF Word Count

Copyright © 2021 · Powered by WordPress · Gravity Wiz LLC

  • Support
  • Affiliates
  • About
  • Sitemap
  • Gravity Perks
    ▼
    • Gravity Perks
    • Tutorials & Snippets
    • About
  • Support
    ▼
    • Documentation
    • Support
    • Account