Repository Forums Support WooCommerce Extended Coupon Features PRO How’s the plugin verify First Time Purchase?

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #18835
    Wilfred Chong
    Participant

    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)?

    #18838
    Soft79
    Keymaster

    A 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' ];
      } 
    );
    #18839
    Wilfred Chong
    Participant

    Can I have the complete code for this? I tr y to apply it in the Code Snippet

    #18840
    Soft79
    Keymaster

    That is the complete code…

    A purchase is also stored in a cookie, so it’s better to test in a private browser window.

    #18841
    Wilfred Chong
    Participant

    When 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.

    #18842
    Soft79
    Keymaster

    It must be add_filter instead of add_filters, sorry about that

    #18845
    Wilfred Chong
    Participant

    Applied, but it shows the error msg when the voucher is in fact usable.

    #18846
    Soft79
    Keymaster

    What is the error message? Are you sure the customer doesn’t have a succesful order?

    #18847
    Wilfred Chong
    Participant
    #18855
    Soft79
    Keymaster

    I 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.

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.