@@ -122,17 +122,20 @@ public function getOrdersTrackingCode()
122
122
foreach ($ collection as $ order ) {
123
123
$ result [] = "ga('set', 'currencyCode', ' " . $ order ->getOrderCurrencyCode () . "'); " ;
124
124
foreach ($ order ->getAllVisibleItems () as $ item ) {
125
+ $ quantity = (float )$ item ->getQtyOrdered ();
126
+ $ quantity = fmod ($ quantity , 1 ) !== 0.00 ? $ quantity : (int )$ quantity ;
127
+ $ format = fmod ($ quantity , 1 ) !== 0.00 ? '%.2f ' : '%d ' ;
125
128
$ result [] = sprintf (
126
129
"ga('ec:addProduct', {
127
130
'id': '%s',
128
131
'name': '%s',
129
132
'price': %.2f,
130
- 'quantity': %d
133
+ 'quantity': $ format
131
134
}); " ,
132
135
$ this ->escapeJsQuote ($ item ->getSku ()),
133
136
$ this ->escapeJsQuote ($ item ->getName ()),
134
- round ( $ item ->getPrice (), 2 ),
135
- $ item -> getQtyOrdered ()
137
+ ( float ) $ item ->getPrice (),
138
+ $ quantity
136
139
);
137
140
}
138
141
@@ -146,9 +149,9 @@ public function getOrdersTrackingCode()
146
149
}); " ,
147
150
$ order ->getIncrementId (),
148
151
$ this ->escapeJsQuote ($ this ->_storeManager ->getStore ()->getFrontendName ()),
149
- round ( $ order ->getGrandTotal (), 2 ),
150
- round ( $ order ->getTaxAmount (), 2 ),
151
- round ( $ order ->getShippingAmount (), 2 )
152
+ ( float ) $ order ->getGrandTotal (),
153
+ ( float ) $ order ->getTaxAmount (),
154
+ ( float ) $ order ->getShippingAmount (),
152
155
);
153
156
154
157
$ result [] = "ga('send', 'pageview'); " ;
0 commit comments