Skip to content

Commit

Permalink
Merge pull request #1053 from solverat/order_extractor_bug
Browse files Browse the repository at this point in the history
fix total tax in tag manager tracker
  • Loading branch information
dpfaffenbauer authored Jul 24, 2019
2 parents cca705c + 3fa4a1e commit c7716b3
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 12 deletions.
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ sudo: false
language: php

addons:
mariadb: '10.1'
mariadb: '10.2'
hosts:
- pimcore-test.dev
services:
- mysql
env:
global:
- PIMCORE_ENVIRONMENT=test
Expand Down Expand Up @@ -75,17 +77,17 @@ matrix:
- sudo: required
php: 7.1
env:
- PIMCORE_VERSION="dev-master"
- PIMCORE_VERSION="dev-5.8"

- sudo: required
php: 7.2
env:
- PIMCORE_VERSION="dev-master"
- PIMCORE_VERSION="dev-5.8"
allow_failures:
- env:
- CORESHOP_SUITE=codestyle
- env:
- PIMCORE_VERSION="dev-master"
- PIMCORE_VERSION="dev-5.8"
fast_finish: true

cache:
Expand Down
2 changes: 1 addition & 1 deletion features/tracking/analytics_enhanced.feature
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ Feature: In order to track ecommerce sales
And I create an order from my cart
Then tracking my order checkout complete with tracker "google-analytics-enhanced-ecommerce" should generate:
"""
ga('require', 'ec'); ga('set', 'currencyCode', 'EUR'); ga('ec:addProduct', {"id":%DataObject(orderItem, {"method": "getId"});,"name":"T-Shirt","category":"","price":24,"quantity":1,"currency":"EUR"}); ga('ec:setAction', 'purchase', {"id":%DataObject(order, {"method": "getId"});,"affiliation":24,"total":24,"tax":null,"shipping":0,"currency":"EUR"});
ga('require', 'ec'); ga('set', 'currencyCode', 'EUR'); ga('ec:addProduct', {"id":%DataObject(orderItem, {"method": "getId"});,"name":"T-Shirt","category":"","price":24,"quantity":1,"currency":"EUR"}); ga('ec:setAction', 'purchase', {"id":%DataObject(order, {"method": "getId"});,"affiliation":24,"total":24,"tax":4,"shipping":0,"currency":"EUR"});
"""
2 changes: 1 addition & 1 deletion features/tracking/global_site_tag.feature
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ Feature: In order to track ecommerce sales
And I create an order from my cart
Then tracking my order checkout complete with tracker "google-gtag-enhanced-ecommerce" should generate:
"""
gtag('event', 'purchase', {"id":%DataObject(order, {"method": "getId"});,"affiliation":24,"total":24,"tax":null,"shipping":0,"currency":"EUR","items":[{"id":%DataObject(orderItem, {"method": "getId"});,"name":"T-Shirt","category":"","price":24,"quantity":1,"currency":"EUR"}]});
gtag('event', 'purchase', {"id":%DataObject(order, {"method": "getId"});,"affiliation":24,"total":24,"tax":4,"shipping":0,"currency":"EUR","items":[{"id":%DataObject(orderItem, {"method": "getId"});,"name":"T-Shirt","category":"","price":24,"quantity":1,"currency":"EUR"}]});
"""
2 changes: 1 addition & 1 deletion features/tracking/tag_manager_classic.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ Feature: In order to track ecommerce sales
Scenario: Track Checkout Complete
Then tracking my order checkout complete with tracker "google-gtm-classic-ecommerce" should generate:
"""
window.dataLayer = window.dataLayer || [];dataLayer.push({"transactionId":%DataObject(order, {"method" : "getId"});,"transactionAffiliation":24,"transactionTotal":24,"transactionTax":null,"transactionShipping":0,"transactionCurrency":"EUR","transactionProducts":[{"id":%DataObject(orderItem, {"method": "getId"});,"name":"T-Shirt","category":"","price":24,"quantity":1}]});
window.dataLayer = window.dataLayer || [];dataLayer.push({"transactionId":%DataObject(order, {"method" : "getId"});,"transactionAffiliation":24,"transactionTotal":24,"transactionTax":4,"transactionShipping":0,"transactionCurrency":"EUR","transactionProducts":[{"id":%DataObject(orderItem, {"method": "getId"});,"name":"T-Shirt","category":"","price":24,"quantity":1}]});
"""
2 changes: 1 addition & 1 deletion features/tracking/tag_manager_enhanced.feature
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ Feature: In order to track ecommerce sales
And I create an order from my cart
Then tracking my order checkout complete with tracker "google-gtm-enhanced-ecommerce" should generate:
"""
window.dataLayer = window.dataLayer || [];dataLayer.push({'ecommerce' : { 'purchase' : {"actionField":{"id":%DataObject(order, {"method": "getId"});,"affiliation":24,"total":24,"tax":null,"shipping":0,"currency":"EUR"},"products":[{"id":%DataObject(orderItem, {"method": "getId"});,"sku":null,"name":"T-Shirt","category":"","price":24,"quantity":1,"currency":"EUR"}]} } });
window.dataLayer = window.dataLayer || [];dataLayer.push({'ecommerce' : { 'purchase' : {"actionField":{"id":%DataObject(order, {"method": "getId"});,"affiliation":24,"total":24,"tax":4,"shipping":0,"currency":"EUR"},"products":[{"id":%DataObject(orderItem, {"method": "getId"});,"sku":null,"name":"T-Shirt","category":"","price":24,"quantity":1,"currency":"EUR"}]} } });
"""
2 changes: 1 addition & 1 deletion features/tracking/universal_ecommerce.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ Feature: In order to track ecommerce sales
And I create an order from my cart
Then tracking my order checkout complete with tracker "google-analytics-universal-ecommerce" should generate:
"""
ga('require', 'ecommerce', 'ecommerce.js'); ga('ecommerce\u003AaddTransaction', {"id":%DataObject(order, {"method": "getId"});,"affiliation":24,"total":24,"tax":null,"shipping":0,"currency":"EUR"}); ga('ecommerce\u003AaddItem', {"id":%DataObject(orderItem, {"method": "getId"});,"name":"T-Shirt","category":"","price":24,"quantity":1,"currency":"EUR"}); ga('ecommerce:send');
ga('require', 'ecommerce', 'ecommerce.js'); ga('ecommerce\u003AaddTransaction', {"id":%DataObject(order, {"method": "getId"});,"affiliation":24,"total":24,"tax":4,"shipping":0,"currency":"EUR"}); ga('ecommerce\u003AaddItem', {"id":%DataObject(orderItem, {"method": "getId"});,"name":"T-Shirt","category":"","price":24,"quantity":1,"currency":"EUR"}); ga('ecommerce:send');
"""
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public function trackCheckoutComplete($order)
$orderData = $this->transformOrder($order);
$items = $order['items'];

$actionData = array_merge($this->transformOrder($orderData), ['items' => []]);
$actionData = array_merge($orderData, ['items' => []]);

foreach ($items as $item) {
$actionData['items'][] = $this->transformProductAction($item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function trackCheckoutComplete($order)
$order['id'],
$order['total'],
$order['subtotal'],
$order['tax'],
$order['totalTax'],
$order['shipping'],
$order['discount'],
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function updateMetadata($object, $data = []): array
'affiliation' => $object->getTotal() / 100,
'total' => $object->getTotal() / 100,
'subtotal' => $object->getSubtotal() / 100,
'tax' => $object->getTotalTax() / 100,
'totalTax' => $object->getTotalTax() / 100,
'shipping' => $object->getAdjustmentsTotal(AdjustmentInterface::SHIPPING) / 100,
'discount' => $object->getAdjustmentsTotal(AdjustmentInterface::CART_PRICE_RULE) / 100,
'currency' => $object->getCurrency()->getIsoCode(),
Expand Down

0 comments on commit c7716b3

Please sign in to comment.