- Issue created by @rszrama
- Status changed to Needs review
about 1 year 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.
- First commit to issue fork.
- @agoradesign opened merge request.
- π¦πΉAustria agoradesign
opened a MR, addressing #4, as I fully agree that CheckoutEvents::COMPLETION is the event that should be used here
And I further have observed that DI is really not working when using a delayed event. I haven't chased this problem down, but I'm 99% sure that the problems derive from serialization and deserialization of the plugin. This is the main difference between the sync and the delayed events