File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 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 *
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 }
4545 }
4646 }
4747
48- $ rule_groups [0 ]->limit = (int ) $ count ;
48+ $ rule_groups [0 ]->limit = (int ) $ purchase_count ;
4949 return $ rule_groups ;
5050} );
You can’t perform that action at this time.
0 commit comments