File tree 3 files changed +8
-1
lines changed
app/code/Magento/GoogleAnalytics
3 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,7 @@ public function getOrdersTrackingCode()
120
120
$ result [] = "ga('require', 'ec', 'ec.js'); " ;
121
121
122
122
foreach ($ collection as $ order ) {
123
+ $ result [] = "ga('set', 'currencyCode', ' " . $ order ->getBaseCurrencyCode () . "'); " ;
123
124
foreach ($ order ->getAllVisibleItems () as $ item ) {
124
125
$ result [] = sprintf (
125
126
"ga('ec:addProduct', {
@@ -243,6 +244,7 @@ public function getOrdersTrackingData()
243
244
'tax ' => $ order ->getBaseTaxAmount (),
244
245
'shipping ' => $ order ->getBaseShippingAmount (),
245
246
];
247
+ $ result ['currency ' ] = $ order ->getBaseCurrencyCode ();
246
248
}
247
249
return $ result ;
248
250
}
Original file line number Diff line number Diff line change @@ -103,6 +103,7 @@ public function testOrderTrackingCode()
103
103
$ this ->storeManagerMock ->expects ($ this ->once ())->method ('getStore ' )->willReturn ($ this ->storeMock );
104
104
105
105
$ expectedCode = "ga('require', 'ec', 'ec.js');
106
+ ga('set', 'currencyCode', 'USD');
106
107
ga('ec:addProduct', {
107
108
'id': 'sku0',
108
109
'name': 'testName0',
@@ -165,7 +166,8 @@ public function testOrderTrackingData()
165
166
'price ' => 0.00 ,
166
167
'quantity ' => 1
167
168
]
168
- ]
169
+ ],
170
+ 'currency ' => 'USD '
169
171
];
170
172
171
173
$ this ->gaBlock ->setOrderIds ([1 , 2 ]);
@@ -213,6 +215,7 @@ protected function createOrderMock($orderItemCount = 1)
213
215
$ orderMock ->expects ($ this ->once ())->method ('getBaseGrandTotal ' )->willReturn (10 );
214
216
$ orderMock ->expects ($ this ->once ())->method ('getBaseTaxAmount ' )->willReturn (2 );
215
217
$ orderMock ->expects ($ this ->once ())->method ('getBaseShippingAmount ' )->willReturn ($ orderItemCount );
218
+ $ orderMock ->expects ($ this ->once ())->method ('getBaseCurrencyCode ' )->willReturn ('USD ' );
216
219
return $ orderMock ;
217
220
}
218
221
Original file line number Diff line number Diff line change @@ -57,6 +57,8 @@ define([
57
57
if ( config . ordersTrackingData ) {
58
58
ga ( 'require' , 'ec' , 'ec.js' ) ;
59
59
60
+ ga ( 'set' , 'currencyCode' , config . ordersTrackingData . currency ) ;
61
+
60
62
// Collect product data for GA
61
63
if ( config . ordersTrackingData . products ) {
62
64
$ . each ( config . ordersTrackingData . products , function ( index , value ) {
You can’t perform that action at this time.
0 commit comments