Repository › Forums › Support › WooCommerce Extended Coupon Features PRO › How’s the plugin verify First Time Purchase?
- This topic has 9 replies, 2 voices, and was last updated 2 years, 3 months ago by Soft79.
-
AuthorPosts
-
May 6, 2022 at 6:05 am #18835Wilfred ChongParticipant
We tried using a new account to test the first-time purchase feature.
At first, the coupon is successfully applied for the new account, but we canceled the order, then try to apply again for a new order but this time it was unable to apply the coupon anymore.So can we set the first-time verification only apply to be user that didn’t have any complete purchase (failed order doesn’t count)?
May 6, 2022 at 7:19 am #18838Soft79KeymasterA user is considered to having placed a status when an order reaches one of these statuses:
‘wc-completed’, ‘wc-processing’, ‘wc-on-hold’, ‘wc-pending’
Maybe you would like to ignore on-hold and/or pending statuses. You can do that with the following php snippet:
add_filter( 'wjecf_first_order_statuses_to_check', function( $order_statuses ) { return [ 'wc-completed', 'wc-processing' ]; } );
May 6, 2022 at 10:20 am #18839Wilfred ChongParticipantCan I have the complete code for this? I tr y to apply it in the Code Snippet
May 6, 2022 at 11:06 am #18840Soft79KeymasterThat is the complete code…
A purchase is also stored in a cookie, so it’s better to test in a private browser window.
May 6, 2022 at 11:47 am #18841Wilfred ChongParticipantWhen I insert the code and click save, it shows this error:
Don’t Panic
The code snippet you are trying to save produced a fatal error on line 1:Uncaught Error: Call to undefined function add_filters() in /wp-content/plugins/code-snippets/php/admin-menus/class-edit-menu.php(221) : eval()’d code:1 Stack trace:
#0 /wp-content/plugins/code-snippets/php/admin-menus/class-edit-menu.php(221): eval() /wp-content/plugins/code-snippets/php/admin-menus/class-edit-menu.php(271): Code_Snippets_Edit_Menu->test_code(Object(Code_Snippet))
#2 /wp-content/plugins/code-snippets/php/admin-menus/class-edit-menu.php(130): Code_Snippets_Edit_Menu->save_posted_snippet()
#3 /wp-content/plugins/code-snippets/php/admin-menus/class-edit-menu.php(107): Code_Snippets_Edit_Menu->process_actions() #
4 /wp-includes/class-wp-hook.php(307): Code_Snippets_Edit_Menu->load(
The previous version of the snippet is unchanged, and the rest of this site should be functioning normally as before.Please use the back button in your browser to return to the previous page and try to fix the code error. If you prefer, you can close this page and discard the changes you just made. No changes will be made to this site.
May 6, 2022 at 12:03 pm #18842Soft79KeymasterIt must be add_filter instead of add_filters, sorry about that
May 8, 2022 at 2:16 pm #18845Wilfred ChongParticipantApplied, but it shows the error msg when the voucher is in fact usable.
May 8, 2022 at 7:14 pm #18846Soft79KeymasterWhat is the error message? Are you sure the customer doesn’t have a succesful order?
May 9, 2022 at 7:08 am #18847Wilfred ChongParticipantMay 10, 2022 at 6:12 pm #18855Soft79KeymasterI see. Once an order has been placed by a customer that has logged in, this is stored in the session data. Cancelling the order doesn’t remove this information. This snippet is a workaround (stored as ‘AAA Fix first purchase’ in your staging environment):
add_action( 'init', function() { if ( function_exists( 'WJECF' ) ) { WJECF()->set_session( 'has_purchased_before', false ); } } );
In the next release we will apply a more permanent fix for this.
-
AuthorPosts
- You must be logged in to reply to this topic.