Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
\Drupal\commerce_google_tag_manager\EventTrackerService::purchase
is missing to calculate tax costs.
Proposed resolution
Calculate tax costs and submit it as part of purchase data.
Remaining tasks
Write a patch- Write a test to cover - shipping, taxes (included & excluded from price) and total price value
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#12 | 3040954-12.patch | 24.84 KB | wengerk |
| |||
#8 | 3040954-08.patch | 12.35 KB | wengerk |
| |||
#4 | 3040954-calculate-tax-costs-4.patch | 2.15 KB | mbovan |
Comments
Comment #2
mbovan CreditAttribution: mbovan at MD Systems GmbH for Unic commentedI am submitting a patch that adds tax costs.
Comment #3
schtifu CreditAttribution: schtifu at Gridonic commentedThanks for your contribution mbovan, looking good! Just two things:
1)
public function calculateTax(OrderInterface $order) {
Could you make this private since it is a helper method and not part of the public API of EventTrackerService.
2) Do you have time to extend the test cases to cover this feature? I can do it if you don't find the time :)
P.S. If you prefer, you can also send a pull request via GitHub: https://github.com/gridonic/commerce_google_tag_manager
Cheers
Comment #4
mbovan CreditAttribution: mbovan as a volunteer and at MD Systems GmbH for Unic commentedThanks for the feedback @schtifu.
Please find the attached patch that changes the method to private.
Unfortunately, I will not have time at the moment to write tests. Feel free to work on it.
Comment #5
wengerkMany thanks for your contrib !!
Sorry it takes me ages to get into this issue ...
Here is a reroll patch, I will work on a functional tests asap.
Comment #6
wengerkHere is the same patch with a tests ensuring
\Drupal\commerce_google_tag_manager\EventTrackerService::purchase
apply 'revenue' and 'taxes' properly when included or excluded from the unit_price of productComment #7
wengerkoupsy, I added the file
tests/src/Functional/PurchaseTest.php
which should not be part of those patches ...Comment #8
wengerkhere a fix, a Unit test was broken since we make a call to
collectAdjustments
and this call was not mockedComment #9
wengerkComment #10
wengerkComment #11
mbovan CreditAttribution: mbovan as a volunteer and at MD Systems GmbH for Unic commentedThanks for taking the time to work on tests!
I am not sure if it is worth testing a case when there are 2 different tax rates applied to 2 different order items?
Small typo on "revenu".
Comment #12
wengerkYay you'r right, here is a refactored tests coverage.
Comment #13
wengerkComment #14
wengerk