gpi_temporary_payment_statuses

  1. Description
  2. Usage
  3. Parameters
  4. Examples
    1. Counts 'Processing' payment status towards inventory limit for 30 minutes.
    2. Stops counting 'Processing' payment status towards inventory limit.
  5. Since

Description

Filter payment statuses that should count towards inventory for a limited time after entry creation. Return an associative array where the keys are payment statuses and the values are the number of seconds the reservation should remain in effect. By default, the ‘Processing’ payment status counts until Gravity Forms considers the payment stale: 60 minutes, or what gform_payment_stale_threshold_minutes returns. It does not apply when gpi_approved_payment_statuses already counts ‘Processing’. Payment add-ons that take payment after the entry is created (e.g. Stripe Checkout) set ‘Processing’ until the payment completes, so without the hold a second customer could buy the same stock in the meantime.

Usage

Applied globally

add_filter( 'gpi_temporary_payment_statuses', 'my_custom_function' );

Applied to specific form

add_filter( 'gpi_temporary_payment_statuses_FORMID', 'my_custom_function' );

Applied to specific field

add_filter( 'gpi_temporary_payment_statuses_FORMID_FIELDID', 'my_custom_function' );

Parameters

$temporary_statuses array

Associative array of payment statuses => duration in seconds.

$field GF_Field

Field for which inventory is being queried.

Examples

Counts 'Processing' payment status towards inventory limit for 30 minutes.

add_filter( 'gpi_temporary_payment_statuses', function ( $temporary_statuses, $field ) {
  $temporary_statuses['Processing'] = 30 * MINUTE_IN_SECONDS;
  return $temporary_statuses;
}, 10, 2 );

Stops counting 'Processing' payment status towards inventory limit.

add_filter( 'gpi_temporary_payment_statuses', function ( $temporary_statuses, $field ) {
  unset( $temporary_statuses['Processing'] );
  return $temporary_statuses;
}, 10, 2 );

Since

  • 1.0.18 Hook added.

  • 1.0.33 The ‘Processing’ payment status counts until Gravity Forms considers the payment stale by default.