Skip to content

Commit cd5c53f

Browse files
authored
Merge pull request #26 from magefan/10304-send-revenue-without-taxes-v2
10304-send-revenue-without-taxes-v2
2 parents 3ddd2c7 + 4368844 commit cd5c53f

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

Model/DataLayer/Purchase.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function get(Order $order, string $requester = ''): array
6161
'event' => 'purchase',
6262
'ecommerce' => [
6363
'transaction_id' => $order->getIncrementId(),
64-
'value' => $this->formatPrice((float)$order->getGrandTotal()),
64+
'value' => $this->getOrderValue($order),
6565
'tax' => $this->formatPrice((float)$order->getTaxAmount()),
6666
'shipping' => $this->formatPrice((float)$order->getShippingAmount()),
6767
'currency' => $this->getCurrentCurrencyCode(),
@@ -79,16 +79,17 @@ public function get(Order $order, string $requester = ''): array
7979
}
8080

8181
/**
82-
* @param array $data
83-
* @return array
82+
* @param $order
83+
* @return float
8484
*/
85-
protected function eventWrap(array $data): array
85+
protected function getOrderValue($order): float
8686
{
87-
$data = parent::eventWrap($data);
87+
$orderValue = (float)$order->getGrandTotal();
88+
8889
if (!$this->config->isPurchaseTaxEnabled()) {
89-
unset($data['ecommerce']['tax']);
90+
$orderValue -= $order->getTaxAmount();
9091
}
9192

92-
return $data;
93+
return $this->formatPrice($orderValue);
9394
}
9495
}

etc/adminhtml/system.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,6 @@ To create a new secret, navigate in the
346346
<comment><![CDATA[<strong class="colorRed">Warning!</strong> Enabling this option may cause the performance impact.]]></comment>
347347
</field>
348348
</group>
349-
<!--
350349
<group id="events" translate="label" type="text" sortOrder="62" showInDefault="1" showInWebsite="1" showInStore="1">
351350
<label>Events</label>
352351
<group id="purchase" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
@@ -358,7 +357,6 @@ To create a new secret, navigate in the
358357
</field>
359358
</group>
360359
</group>
361-
-->
362360
<group id="page_speed_optimization" translate="label" type="text" sortOrder="65" showInDefault="1" showInWebsite="1" showInStore="1">
363361
<label>Page Speed Optimization</label>
364362
<field id="enabled" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">

0 commit comments

Comments
 (0)