Problem/Motivation
The current architecture and implementation with final plugin classes and duplicated and different implementations to build the order items makes it really hard to customize them, which is a common use case for things like category, see also #3392918: Add category to the item object for ecommerce tracking.
Steps to reproduce
Proposed resolution
Unify the creation of the order item in a method on the trait, trigger an event
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork google_tag-3410273
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
berdirIntroduced a method on the trait used it on all events where it makes sense, only exception is commerce_view_item_list, which calls it item but it's a product variation.
Also added an event and a test that verifies it works.
MR needs work on docs and trait doesn't use DI, that's a bit awkward as every plugin class would need to do the whole DI dance, probably even with BC?
Comment #4
newaytech commentedFantastic @Berdir - thanks for the contrib...
Comment #5
berdirFixed a missing use. Not sure why it's still a Build Successful and not a pass, https://dispatcher.drupalci.org/job/drupal_contrib/724221/console seems OK to me.
Comment #6
berdirI pushed a few updates. I didn't realize that $item is sometimes an order item and sometimes it's actually a product variation. The naming really doesn't help there.
So there are now two methods on the trait and two events. Still would like some first feedback before finishing this up with comments and so on.
Comment #7
japerryOn first glance this looks great! Waiting to see if I can get the new test suite to pass, I committed some changes a week ago that fixed tests for Drupal 10.
Comment #8
rszrama commentedTagging and cross-referencing #3358305: Add alter event processing to collector as one or the other (or both?) of these approaches will be needed. A more general solution for altering event data seems to make sense, though ... for example, determining what coupon code should be present on a purchase event when multiple coupon codes have been applied to an order.
Comment #12
primsi commentedUpdating mr to address php 8.4 deprecations