How to subscribe to an event when the order is completed (paid)

Created on 27 July 2020, over 4 years ago
Updated 17 November 2023, about 1 year ago

Tell me where I can find the "deal completed" event (paid).

I created a module that generates a license key in the user field, BUT you need to run it somehow when the user bought the product (there is only one product in the store).

All instructions that do not work on the Internet, I wrote on the forum for creating modules, at drupal.stackexchange.com)

Update 1:
Long search paths led me to the file /web/modules/contrib/state_machine/src/Event/WorkflowTransitionEvent.php

But I but how to subscribe to this event, "completion of the transaction". Drupal seems too confusing.

💬 Support request
Status

Closed: outdated

Version

2.20

Component

Documentation

Created by

🇺🇦Ukraine Devoleksiy

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.

  • 🇪🇸Spain alexortega_98 Seville

    Try out the pre/post transition events:

      public static function getSubscribedEvents() {
        return [
          'commerce_order.place.post_transition' => 'onOrderPlace',
        ];
      }
    
      public function onOrderPlace(WorkflowTransitionEvent $event) {
        ...
    
  • Status changed to Closed: outdated about 1 year ago
  • 🇮🇱Israel jsacksick

    There's a separate event that is dispatched when the order is paid, it is OrderEvents::ORDER_PAID. Closing this as this an outdated issue.

Production build 0.71.5 2024