@@ -82,6 +82,7 @@ public function getPageName()
82
82
* @link https://developers.google.com/analytics/devguides/collection/analyticsjs/method-reference#set
83
83
* @link https://developers.google.com/analytics/devguides/collection/analyticsjs/method-reference#gaObjectMethods
84
84
* @deprecated 100.2.0 please use getPageTrackingData method
85
+ * @see getPageTrackingData method
85
86
*/
86
87
public function getPageTrackingCode ($ accountId )
87
88
{
@@ -103,6 +104,7 @@ public function getPageTrackingCode($accountId)
103
104
*
104
105
* @return string|void
105
106
* @deprecated 100.2.0 please use getOrdersTrackingData method
107
+ * @see getOrdersTrackingData method
106
108
*/
107
109
public function getOrdersTrackingCode ()
108
110
{
@@ -124,12 +126,12 @@ public function getOrdersTrackingCode()
124
126
"ga('ec:addProduct', {
125
127
'id': '%s',
126
128
'name': '%s',
127
- 'price': '%f' ,
129
+ 'price': %.2f ,
128
130
'quantity': %d
129
131
}); " ,
130
132
$ this ->escapeJsQuote ($ item ->getSku ()),
131
133
$ this ->escapeJsQuote ($ item ->getName ()),
132
- $ item ->getPrice (),
134
+ round ( $ item ->getPrice (), 2 ),
133
135
$ item ->getQtyOrdered ()
134
136
);
135
137
}
@@ -138,15 +140,15 @@ public function getOrdersTrackingCode()
138
140
"ga('ec:setAction', 'purchase', {
139
141
'id': '%s',
140
142
'affiliation': '%s',
141
- 'revenue': '%f' ,
142
- 'tax': '%f' ,
143
- 'shipping': '%f'
143
+ 'revenue': %.2f ,
144
+ 'tax': %.2f ,
145
+ 'shipping': %.2f
144
146
}); " ,
145
147
$ order ->getIncrementId (),
146
148
$ this ->escapeJsQuote ($ this ->_storeManager ->getStore ()->getFrontendName ()),
147
- $ order ->getGrandTotal (),
148
- $ order ->getTaxAmount (),
149
- $ order ->getShippingAmount ()
149
+ round ( $ order ->getGrandTotal (), 2 ),
150
+ round ( $ order ->getTaxAmount (), 2 ),
151
+ round ( $ order ->getShippingAmount (), 2 )
150
152
);
151
153
152
154
$ result [] = "ga('send', 'pageview'); " ;
@@ -235,16 +237,16 @@ public function getOrdersTrackingData()
235
237
$ result ['products ' ][] = [
236
238
'id ' => $ this ->escapeJsQuote ($ item ->getSku ()),
237
239
'name ' => $ this ->escapeJsQuote ($ item ->getName ()),
238
- 'price ' => ( float )$ item ->getPrice (),
240
+ 'price ' => round (( float )$ item ->getPrice (), 2 ),
239
241
'quantity ' => (int )$ item ->getQtyOrdered (),
240
242
];
241
243
}
242
244
$ result ['orders ' ][] = [
243
245
'id ' => $ order ->getIncrementId (),
244
246
'affiliation ' => $ this ->escapeJsQuote ($ this ->_storeManager ->getStore ()->getFrontendName ()),
245
- 'revenue ' => ( float )$ order ->getGrandTotal (),
246
- 'tax ' => ( float )$ order ->getTaxAmount (),
247
- 'shipping ' => ( float )$ order ->getShippingAmount (),
247
+ 'revenue ' => round (( float )$ order ->getGrandTotal (), 2 ),
248
+ 'tax ' => round (( float )$ order ->getTaxAmount (), 2 ),
249
+ 'shipping ' => round (( float )$ order ->getShippingAmount (), 2 )
248
250
];
249
251
$ result ['currency ' ] = $ order ->getOrderCurrencyCode ();
250
252
}
0 commit comments