From a2194108015f4855f05c560dc16fdb5bdc7d32af Mon Sep 17 00:00:00 2001 From: David Smith Date: Wed, 9 Feb 2022 15:25:09 -0500 Subject: [PATCH] Refactored code to use new `formId` parameter passed via the `gform_coupons_discount_amount` filter. ~ Pending release of this PR: https://github.com/gravityforms/gravityformscoupons/pull/29 --- gravity-forms/gw-coupons-exclude-products.php | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/gravity-forms/gw-coupons-exclude-products.php b/gravity-forms/gw-coupons-exclude-products.php index 1d3c290e7..eff4a3e76 100644 --- a/gravity-forms/gw-coupons-exclude-products.php +++ b/gravity-forms/gw-coupons-exclude-products.php @@ -6,7 +6,7 @@ * * Requires Gravity Forms Coupons v1.1 * - * @version 1.2.1 + * @version 1.2.2 * @author David Smith * @license GPL-2.0+ * @link http://gravitywiz.com/... @@ -69,17 +69,9 @@ function output_script() { if( window.gform ) { - gform.addFilter( 'gform_coupons_discount_amount', function( discount, couponType, couponAmount, price, totalDiscount ) { + gform.addFilter( 'gform_coupons_discount_amount', function( discount, couponType, couponAmount, price, totalDiscount, formId ) { - // pretty hacky... work our way up the chain to see if the 4th func up is the expected func - var caller = arguments.callee.caller.caller.caller.caller; - - if( caller.name != 'PopulateDiscountInfo' ) { - return discount; - } - - var formId = caller.arguments[1], - price = price - getExcludedAmount( formId ); + price -= getExcludedAmount( formId ); if( couponType == 'percentage' ) { discount = price * Number( ( couponAmount / 100 ) );