Tickets are being mailed despite fact that payment was cancelled

Home Forums Ticket Products Event Tickets Plus Tickets are being mailed despite fact that payment was cancelled

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1057253
    Barbara
    Participant

    Hi guys,

    Currently I’m testing the implementation of WooCommerce and Event Tickets Plus on my site and have run in to the following problem. I am using the Mollie plugin from WooCommerce to fullfill the payments and in testing mode, you have the option to re-enact a cancelled payment. That would equal customers going to their bank’s gateway to pay but then deciding not to. So, there never was any kind of payment whatsoever.

    Choosing this option returns me to the ‘invoice’ page from WooCommerce but with a clear ‘Cancelled’ order status. So far, everything goes as excpected. I also don’t get an email from the WooCommerce platform with an invoice, so still as expected.

    But… I do receive the two tickets from the Event Tickets Plus platform, with the QR codes, ticket number etc…. Definitely not as excpected and not the way it should be!

    Typing this, it got me thinking. I have a little piece of code added to automatically accept orders when placed to prevent us from having to approve the order before the customer gets his tickets. I got this piece of code from these forums after browsing that initial problem (of having to approve orders in the first place). So, other people might be having this issue.

    /**
     * Auto Complete all WooCommerce orders.
     */
    add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' );
    function custom_woocommerce_auto_complete_order( $order_id ) { 
        if ( ! $order_id ) {
            return;
        }
    
        $order = wc_get_order( $order_id );
        $order->update_status( 'completed' );
    }
    

    My next step now is to delete this from the theme’s functions.php to see if this fixes this issue.

    Yep, this appears to fix this issue. However, I still would like the option to auto approve ticket sales since why the hell would I want to approve them, if I’ve set a max number of tickets to be sold, I’d want the customers to receive their tickets as soon as possible.

    I have re-enabled the piece of code, but I’d love to have a look from you guys to see if this is fixable.

    THanks,
    Hans

    #1057998
    Brook
    Participant

    Howdy Hans,

    Thanks for your detailed description and testing without that snippet. That really narrows it down.

    It is very probably this line of the snippet that is causing issues:

    $order->update_status( 'completed' );

    Right there the status is being pushed to completed anytime the thank you page is being shown. You will need to add some logic to detect what the order_status is using $order->has_status(), before updating it. I am not familiar with the Mollie plugin, but from the sound of it the order status may be ‘cancelled’ in your case. You can use $order->get_status() to find out what the status is and work from there.

    Does that all make sense? Will that work for you? Please let me know.

    Cheers!

    – Brook

    #1076874
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Tickets are being mailed despite fact that payment was cancelled’ is closed to new replies.