Store calculated total price from Gravity Forms in custom database table

I’m building a custom plugin that works with Gravity Forms and I need help with capturing the final calculated price. Right now I can grab all the individual field values and store them in my custom database table when someone submits a form. I’m using the gform_after_submission action hook for this and it works great.

The problem is I can’t figure out how to get the total calculated price that shows up on the form. I can see it displays in the frontend but I need to capture that exact value and save it to my database.

I found this JavaScript snippet online:

<script>
gform.addFilter('gform_product_total', function(finalPrice, formNumber) {
    return finalPrice;
});
</script>

But I’m confused about how to connect this with my PHP code that runs during the gform_after_submission hook. How can I access the calculated total price value in my PHP function that handles the form submission?

Any ideas on the best approach for this?

Skip JavaScript entirely. Hit this exact problem building an inventory system last year.

Use the $form parameter in your gform_after_submission hook. Most people don’t know it exists, but it’s got all the form config you need.

Try this:

$total = GFCommon::get_order_total($form, $entry);

This recalculates the total from actual submitted values and handles conditional pricing logic. Way more reliable than payment_amount - works even without payment processing enabled.

Want to debug? Dump both $entry['payment_amount'] and the calculated total to see which gives the right number. The calculated approach catches more edge cases when users have complex product configs or conditional fields affecting pricing.

Had this exact problem last month with a donation tracker. That JavaScript won’t work - JS runs client-side but your PHP submission hook runs server-side after the form’s already processed. I fixed it by grabbing the entry data directly in my gform_after_submission function. The entry object already has all the calculated totals. Use $entry['payment_amount'] to get the final price - it includes conditional logic, discounts, and product calculations. If that’s empty, try GFCommon::get_order_total($form, $entry) which recalculates based on submitted values. Both worked consistently when I tested different form setups with product fields and pricing options.

This tripped me up when I was building an event booking system. Gravity Forms automatically stores the calculated total in the entry data when the form processes. In your gform_after_submission hook, you’ve got access to the $entry parameter with the final calculated price. Check $entry['payment_amount'] first - it’s got the total after all product calculations, conditional logic, and any coupons or discounts. If you’re not using payment fields, the total might be stored differently based on your form setup. I found rgar($entry, 'payment_amount') works better than direct array access since it handles missing keys. Just make sure your form has pricing fields configured properly, or payment_amount won’t get populated. This has worked reliably for me across different form setups.

hey, you can use GFCommon::get_product_fields() and GFCommon::get_order_total() in your gform_after_submission function. this should give you the exact total without needing any js. hope this helps!