Skip to content

Commit cd4ac7b

Browse files
committed
gpls-set-limit-by-woo-product-purchase-count.php: Added new snippet.
1 parent adbdc40 commit cd4ac7b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

gp-limit-submissions/gpls-set-limit-by-woo-product-purchase-count.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
/**
33
* Gravity Perks // Limit Submissions // Dynamically Set Limit by User WooCommerce Product Purchase Count
44
* https://gravitywiz.com/documentaiton/gravity-forms-limit-submissions/
5-
*
5+
*
66
* Dynamically set the limit by how many times the current user has purchased a specific WooCommerce product.
77
* This is useful when a user must complete a form once each time they purchase the product.
88
* Note: This requires users to be logged in, so does not work for guest purchases.
9-
*
9+
*
1010
* Instructions:
11-
*
11+
*
1212
* 1. Install the snippet.
1313
* https://gravitywiz.com/documentation/managing-snippets/
1414
*
@@ -20,7 +20,7 @@
2020
$target_product_id = 4; // Update "4" to your Woo product ID
2121

2222
$current_user_id = get_current_user_id();
23-
if( !$current_user_id ){
23+
if ( !$current_user_id ){
2424
$rule_groups[0]->limit = 0;
2525
return $rule_groups;
2626
}
@@ -45,6 +45,6 @@
4545
}
4646
}
4747

48-
$rule_groups[0]->limit = (int) $count;
48+
$rule_groups[0]->limit = (int) $purchase_count;
4949
return $rule_groups;
5050
} );

0 commit comments

Comments
 (0)