- Issue created by @rszrama
- Status changed to Needs review
8 months ago 10:32am 12 April 2024 - πΈπ°Slovakia kaszarobert
I attach a patch with a possible solution to use just the
commerce_order.place.post_transition
event. This would also fix another issue I encountered π Drupal Commerce purchase event gets sent multiple times if someone refreshes the checkout success page Active as it would not send a purchase event based on the checkout step multiple times anymore. But as you mentioned, this alters the module's behavior when to send purchase events to the way how Commerce Google Tag Manager β worked.Then this way, I encountered a strange error when
PurchaseEvent::getData
is called:Error: Typed property Drupal\google_tag\Plugin\GoogleTag\Event\Commerce\PurchaseEvent::$transformer must not be accessed before initialization in Drupal\google_tag\Plugin\GoogleTag\Event\Commerce\PurchaseEvent->getData() (line 79 of modules/contrib/google_tag/src/Plugin/GoogleTag/Event/Commerce/PurchaseEvent.php). google_tag_page_attachments(Array) (Line: 311)
I could not fix this with proper DI, so that's why I made those changes there.
- π©πͺGermany marcusx
Just stumbled over this as well. In my case I was confused why the purchased event is tiggered in this form_alter you removed. Was looking into a similar fix.
I wonder if we could use
CheckoutEvents::COMPLETION
as the subscribed event instead of `'commerce_order.place.post_transition'`?
- First commit to issue fork.