Auto completing tickets

Home Forums Ticket Products Event Tickets Plus Auto completing tickets

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #952407
    adambowie
    Participant

    Hey guys – We modified an old site in the past to autocomplete the tickets, so they are processed immediately when someone makes a purchase.

    Barry had told us how, but when I find that old support ticket, the link he gave me no longer works.

    Can someone tell me how to do it?

    I found another solution online: http://clicknathan.com/web-design/customizing-wootickets-for-events-calendar/
    and we tried it, but I think it no longer works because of the way Woocommerce started processing orders in 3.2.

    Appreciate the help!

    #952877
    Gustavo Bordoni
    Keymaster

    Hi Adam,

    Thanks for reaching out to us here on our support forums.

    Can you link me which was the solution that Barry provided you? Then I can try it locally and see why it’s not working anymore.

    my Best Regards,

    #952904
    James O’Sullivan
    Participant

    Give this snippet here a try in your functions.php file. What it does is auto complete a transaction for a virtual product in woocommerce and tickets are virtual products so should work well here. Let me know if it helps.

    // Automatically complete orders of virtual products only
    add_filter( 'woocommerce_payment_complete_order_status', 'virtual_order_payment_complete_order_status', 10, 2 );
    
    function virtual_order_payment_complete_order_status( $order_status, $order_id ) {
      $order = new WC_Order( $order_id );
    
      if ( 'processing' == $order_status &&
           ( 'on-hold' == $order->status || 'pending' == $order->status || 'failed' == $order->status ) ) {
    
        $virtual_order = null;
    
        if ( count( $order->get_items() ) > 0 ) {
    
          foreach( $order->get_items() as $item ) {
    
            if ( 'line_item' == $item['type'] ) {
    
              $_product = $order->get_product_from_item( $item );
    
              if ( ! $_product->is_virtual() ) {
                // once we've found one non-virtual product we know we're done, break out of the loop
                $virtual_order = false;
                break;
              } else {
                $virtual_order = true;
              }
            }
          }
        }
    
        // virtual order, mark as completed
        if ( $virtual_order ) {
          return 'completed';
        }
      }
    
      // non-virtual order, return original status
      return $order_status;
    }
    #953686
    niggo
    Participant

    The plugin “WooCommerce – Autocomplete Order” does exactly what you want.

    #953688
    Gustavo Bordoni
    Keymaster

    I’ve tested Niggo’s solution on my LocalHost and It does solve this problem. Adam, can you check if that solves your issue?

    My best Regards,

    #953783
    adambowie
    Participant

    Thanks guys. I tried installing Woocommerce Autocomplete Orders but it did not work – although it may be because I am running 4.1.

    I will test Niggo’s solution now and update the thread once I do. Thank you both!

    #957246
    Gustavo Bordoni
    Keymaster

    Hi Adam,

    Do you have any news on the Niggo’s solution? If you don’t let me know and we can try to wrap this issue.

    My Best Regards,

    #984056
    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 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Auto completing tickets’ is closed to new replies.