Skip to content

Commit 382ab5b

Browse files
committed
ACP2E-1880: adapt for decimal quantity and allow several decimals on price
1 parent 042d199 commit 382ab5b

File tree

1 file changed

+7
-5
lines changed
  • app/code/Magento/GoogleAnalytics/Block

1 file changed

+7
-5
lines changed

app/code/Magento/GoogleAnalytics/Block/Ga.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,19 +237,21 @@ public function getOrdersTrackingData()
237237

238238
foreach ($collection as $order) {
239239
foreach ($order->getAllVisibleItems() as $item) {
240+
$quantity = (float)$item->getQtyOrdered();
241+
$quantity = fmod($quantity, 1) !== 0.00 ? $quantity : (int)$quantity;
240242
$result['products'][] = [
241243
'id' => $this->escapeJsQuote($item->getSku()),
242244
'name' => $this->escapeJsQuote($item->getName()),
243-
'price' => round((float)$item->getPrice(), 2),
244-
'quantity' => (int)$item->getQtyOrdered(),
245+
'price' => (float)$item->getPrice(),
246+
'quantity' => $quantity,
245247
];
246248
}
247249
$result['orders'][] = [
248250
'id' => $order->getIncrementId(),
249251
'affiliation' => $this->escapeJsQuote($this->_storeManager->getStore()->getFrontendName()),
250-
'revenue' => round((float)$order->getGrandTotal(), 2),
251-
'tax' => round((float)$order->getTaxAmount(), 2),
252-
'shipping' => round((float)$order->getShippingAmount(), 2)
252+
'revenue' => (float)$order->getGrandTotal(),
253+
'tax' => (float)$order->getTaxAmount(),
254+
'shipping' => (float)$order->getShippingAmount(),
253255
];
254256
$result['currency'] = $order->getOrderCurrencyCode();
255257
}

0 commit comments

Comments
 (0)