| CARVIEW |
Select Language
HTTP/2 301
date: Sun, 28 Dec 2025 15:31:50 GMT
content-type: text/html; charset=UTF-8
location: https://docs.gravityforms.com/gform_product_total/
server: cloudflare
strict-transport-security: max-age=604800
strict-transport-security: max-age=31536000; includeSubDomains
x-content-type-options: nosniff
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
x-xss-protection: 1; mode=block
x-frame-options: SAMEORIGIN
x-frame-options: SAMEORIGIN
content-security-policy: frame-ancestors 'self';
referrer-policy: no-referrer
referrer-policy: strict-origin-when-cross-origin
x-redirect-by: WordPress
fastcgi-cache: EXPIRED
cf-cache-status: DYNAMIC
nel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}
report-to: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=3yYGU8h6zTJ8aEfIa8PSDSFYOgk%2BehtT8D3SuP9NLhKzTfBSylBi9NlB3DRxJyVRIhl6oSZpc410ORyHVZro3usmXtg9mRl%2BNwYxlHvRGK5BMv2h"}]}
cf-ray: 9b521b5aebf7c1a4-BLR
HTTP/2 200
date: Sun, 28 Dec 2025 15:31:51 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
vary: Accept-Encoding
strict-transport-security: max-age=604800
strict-transport-security: max-age=31536000; includeSubDomains
x-content-type-options: nosniff
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
x-xss-protection: 1; mode=block
x-frame-options: SAMEORIGIN
x-frame-options: SAMEORIGIN
content-security-policy: frame-ancestors 'self';
referrer-policy: no-referrer
referrer-policy: strict-origin-when-cross-origin
link: ; rel="https://api.w.org/"
link: ; rel="alternate"; title="JSON"; type="application/json"
link: ; rel=shortlink
fastcgi-cache: HIT
report-to: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=UHSa4kcWDVOzFo%2FuuS9UQ3xqxGeLmlgnaXyiA52vYgoVlm%2F92z%2FYw8pQ7OKumThWCvNk9ZqYxh7jEEXEw26dqIaNTiRWIg9oui7i65hNf4NlWIA%2F"}]}
cf-cache-status: DYNAMIC
nel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}
content-encoding: gzip
cf-ray: 9b521b62aeeec1a4-BLR
gform_product_total - Gravity Forms Documentation
gform_product_total
Description
This function fires before updating the Total value for forms with pricing fields. It allows users to implement custom logic to manipulate the Total value.
Note: This filter only applies to the form front-end JavaScript and will only change the display of the Total. You must also implement the gform_product_info filter to ensure the total is displayed correctly on the entry pages and sent properly to third-party services via add-ons such as the PayPal Add-On.
Usage
gform.addFilter( 'gform_product_total', function(total, formId){
// do something with the total
return total;
} );
Parameters
Examples
Add a value to the total
This example adds $50 to the total price if the quantity field is greater than 100.
gform.addFilter('gform_product_total', function(total, formId) {
// Only apply logic to form ID 165
if (formId !== 165) {
return total;
}
const quantityInput = document.querySelector(".ginput_quantity");
if (quantityInput && parseInt(quantityInput.value, 10) > 100) {
total += 50;
}
return total;
});
Prevent totals less than zero
// Prevent the total from being less than zero
gform.addFilter('gform_product_total', function(total, formId) {
return total < 0 ? 0 : total;
});
Placement
Reference the article Adding JavaScript Code to the Frontend of Your Site.
Source Code
This filter is located in js/gravityforms.js