Deleting Cached Entry Data

Introduction

Gravity Forms caches product-related calculations (like totals, prices, and quantities) at the time of submission to improve performance when loading entry views later.

When To Use The Snippet

This snippet can be useful in the context of Gravity Forms when dealing with product fields, viewing an entry in the admin, and encountering issues with how product data is displayed.

However, there are cases where that cached data becomes outdated or incorrect:

  • A pricing field formula or product field was changed after submitting the entry.
  • There are add-ons or customizations that manipulate the data during submission.
  • You’re debugging or displaying dynamic product data in the entry view.
  • You are modifying the form programmatically and need the most current product calculations reflected in the backend.

This snippet will allow the cached entry data for products to be deleted when viewing an entry. Note that the cached data should only be removed if absolutely necessary, as it will impact performance.

add_action( 'gform_entry_detail_content_before', function ( $form, $entry ) {
GFFormsModel::refresh_product_cache( $form, $entry );
}, 10, 2 );

When Not To Use It

Refreshing product cache adds overhead because it recalculates product related data every time an entry is viewed which defeats the purpose of caching. This might:

  • Slow down the entry admin view (especially with large forms or many calculations).
  • Introduce inconsistencies if the form has changed significantly since the entry was submitted.