From 0937ebe0d249552fac8f66c34ad0c93265219bc8 Mon Sep 17 00:00:00 2001 From: Wouter Steenmeijer Date: Fri, 5 Jul 2024 10:18:12 +0200 Subject: [PATCH] Changed Tax settings When config is set in magento to display prices incl tax, send the price to GA incl tax. When excluding tax or both, send ex tax --- Observer/SendPurchaseEvent.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Observer/SendPurchaseEvent.php b/Observer/SendPurchaseEvent.php index 18499d4..4236eac 100644 --- a/Observer/SendPurchaseEvent.php +++ b/Observer/SendPurchaseEvent.php @@ -189,9 +189,9 @@ public function sendPurchaseEvent($client, DataObject $transactionDataObject, ar */ private function getPaidProductPrice(\Magento\Sales\Model\Order\Item $orderItem) { - return $this->scopeConfig->getValue('tax/display/type') == \Magento\Tax\Model\Config::DISPLAY_TYPE_EXCLUDING_TAX - ? $orderItem->getBasePrice() - : $orderItem->getBasePriceInclTax(); + return $this->scopeConfig->getValue('tax/display/type') === \Magento\Tax\Model\Config::DISPLAY_TYPE_INCLUDING_TAX + ? $orderItem->getBasePriceInclTax() + : $orderItem->getBasePrice(); } /** @@ -201,8 +201,8 @@ private function getPaidProductPrice(\Magento\Sales\Model\Order\Item $orderItem) */ private function getPaidShippingCosts(\Magento\Sales\Model\Order\Invoice $invoice) { - return $this->scopeConfig->getValue('tax/display/type') == \Magento\Tax\Model\Config::DISPLAY_TYPE_EXCLUDING_TAX - ? $invoice->getBaseShippingAmount() - : $invoice->getBaseShippingInclTax(); + return $this->scopeConfig->getValue('tax/display/type') == \Magento\Tax\Model\Config::DISPLAY_TYPE_INCLUDING_TAX + ? $invoice->getBaseShippingInclTax() + : $invoice->getBaseShippingAmount(); } }