Skip to content

Commit b38b041

Browse files
authored
gw-coupons-exclude-products.php: Refactored code to use new formId parameter passed via the gform_coupons_discount_amount filter. (#266)
~ Pending release of this PR: gravityforms/gravityformscoupons#29
1 parent 4656d8a commit b38b041

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

gravity-forms/gw-coupons-exclude-products.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Requires Gravity Forms Coupons v1.1
88
*
9-
* @version 1.2.1
9+
* @version 1.2.2
1010
* @author David Smith <[email protected]>
1111
* @license GPL-2.0+
1212
* @link http://gravitywiz.com/...
@@ -70,17 +70,9 @@ function output_script() {
7070

7171
if( window.gform ) {
7272

73-
gform.addFilter( 'gform_coupons_discount_amount', function( discount, couponType, couponAmount, price, totalDiscount ) {
73+
gform.addFilter( 'gform_coupons_discount_amount', function( discount, couponType, couponAmount, price, totalDiscount, formId ) {
7474

75-
// pretty hacky... work our way up the chain to see if the 4th func up is the expected func
76-
var caller = arguments.callee.caller.caller.caller.caller;
77-
78-
if( caller.name != 'PopulateDiscountInfo' ) {
79-
return discount;
80-
}
81-
82-
var formId = caller.arguments[1],
83-
price = price - getExcludedAmount( formId );
75+
price -= getExcludedAmount( formId );
8476

8577
if( couponType == 'percentage' ) {
8678
discount = price * Number( ( couponAmount / 100 ) );

0 commit comments

Comments
 (0)