Tickets are being generated two times at checkout

Created on 11 June 2021, over 3 years ago
Updated 7 October 2023, about 1 year ago

Problem/Motivation

I noticed that the tickets are generated twice at checkout.

Steps to reproduce

So I check out with a qty of 1 for a ticket product and get 2 tickets generated. I than debugged into this and noticed that on checkout the onOrderPresave in OrderEventSubscriber.php gets called multiple times, which leads two this code, which is executed 2 times in my case:

if ($order->getState()->getId() != 'draft') {
  // Only proceed, if order is paid.
  if ($order->isPaid()) {
    $this->createTickets($order);
    $this->autoActivateTickets($order);
  }
}

$this->createTickets($order) is called two times. Inside the method there is a check to not generate tickets multiple times, but this

$existing_tickets = $storage->loadMultiple($ticket_ids)

returns no results in both calls (even in the second call, when a ticket was already created, it is empty).

This leads to the following: in the first call a ticket is generated, in the second call the duplicated, second ticket gets generated and added to the order along with the first ticket.

🐛 Bug report
Status

Closed: works as designed

Version

1.0

Component

Code

Created by

🇩🇪Germany daveiano

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇪Ireland marksmith

    Coming back to this issue upon an update of the Stripe payment method, which also affects Commerce Ticketing. I'm not sure where the problem may be. Sorry if choosing the wrong forum.

    Having Commerce Stripe 8.x-1.0 as the payment gateway, the commerce tickets were created as expected, but failed to be activated on order completion (even if this was the expected behaviour set on the product variation page, the ticket state remained: Created).

    After updating to the recent Commerce Stripe 8.x-1.1 the tickets are indeed activated (!) on order completion, but each ticket is created (and activated) twice.

  • 🇮🇪Ireland marksmith

    On a closer look, this has nothing to do with Stripe (although it appeared on my site after I deleted and recreated a Stripe payment gateway). It duplicates tickets with any (including Manual) payment method.

Production build 0.71.5 2024