Limit by Gravity Flow Approved Entries Only

When using Gravity Flow with an “Approval” step, only count “Approved” entries towards the inventory limit.

Code

Filename: gpi-limit-by-gravity-flow-approved-entries-only.php

<?php
/**
 * Gravity Perks // Inventory // Limit by Gravity Flow Approved Entries Only
 * https://gravitywiz.com/documentation/gravity-forms-inventory/
 *
 * When using Gravity Flow with an "Approval" step, only count "Approved" entries towards the inventory limit.
 */
// Update "123" to your form ID.
add_filter( 'gpi_query_123', function( $query ) {
	global $wpdb;

	$query['join'] .= ' INNER JOIN wp_gf_entry_meta emgflow ON emgflow.entry_id = em.entry_id ';
	// Update "4" to the ID of your Gravity Flow Approval step feed.
	$query['where'] .= ' AND emgflow.meta_key = "workflow_step_status_4" AND emgflow.meta_value = "approved" ';

	return $query;
} );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.