Allow Zero Amount Coupons

Create coupons with the amount of zero.

Code

Filename: gw-coupons-allow-zero-amount-coupons.php

<?php
/**
 * Gravity Wiz // Gravity Forms Coupons // Allow Zero Amount Coupons
 * https://gravitywiz.com/
 *
 * By default it's not possible to create a coupn with the amount of zero.
 * This snippet allows you to create coupons with the amount of zero.
 *
 * Plugin Name:  Gravity Forms Coupons - Allow Zero Amount Coupons
 * Plugin URI:   https://gravitywiz.com/
 * Description:  Create coupons with the amount of zero.
 * Author:       Gravity Wiz
 * Version:      0.1
 * Author URI:   https://gravitywiz.com/
 */
add_filter( 'gform_gravityformscoupons_feed_settings_fields', function( $settings ) {

	foreach ( $settings as &$group ) {
		foreach ( $group['fields'] as &$field ) {
			if ( $field['name'] == 'couponAmountType' ) {
				$field['validation_callback'] = null;
			}
		}
	}

	return $settings;
} );

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.