- Issue created by @kazajhodo
- πΊπΈUnited States kazajhodo
I've pushed my fix into the fork.
Then I'm going to use a patch to resolve this locally for the time being, so here is that should anyone find it useful.
On the purchase event, an item level discount value is passed. The discount value is captured by subtracting the adjusted unit price from the item price.
By default ->getAdjustedUnitPrice() will return a price minus fees, promotions, taxes. I think in most cases the customer will expect the discount field to subtract only the promotion. I could certainly be wrong.
Add a taxed item to cart and check the value of the discount within Drupal\google_tag\Plugin\GoogleTag\Event\Commerce\PurchaseEvent.
I have two possible ideas, we could make the value configurable, allowing choice/combination of the values. Likely there is already code that allows us to pull adjustment types and populate options. getAdjustedUnitPrice() already allows us to pass an array of the adjustments we want, so we just spit out our configured array into line 78 of PurchaseEvent.
Or, if we think no one will ever want their fees and taxes to count as a discount, we simply hardcode the option. I'm pretty heavily leaning towards this, as I can only imagine taxes and fees in a discount causing confusion.
Which is how I ended up here in the first place.
Do it.
None, depending.
None.
None.
Active
2.0
Code
I've pushed my fix into the fork.
Then I'm going to use a patch to resolve this locally for the time being, so here is that should anyone find it useful.