Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions DataLayer/Event/PurchaseWebhookEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,24 @@ public function purchase(OrderInterface $order)
]
];

// Additional shipping, base currency and payment data used by AdPage to
// calculate the actual profit (COGS, carrier rate, payment fees) per order.
// Purely additive: existing keys keep their name, meaning and value.
try {
$data['ecommerce'] += [
'shipping_method' => $order->getShippingDescription() ?? '',
'shipping_method_code' => $order->getShippingMethod() ?? '',
'shipping_excl_tax' => $this->priceFormatter->format((float)$order->getShippingAmount()),
'base_shipping_excl_tax' => $this->priceFormatter->format((float)$order->getBaseShippingAmount()),
'base_value' => $this->priceFormatter->format((float)$order->getBaseGrandTotal()),
'base_tax' => $this->priceFormatter->format((float)$order->getBaseTaxAmount()),
'base_currency' => $order->getBaseCurrencyCode() ?? '',
'payment_type' => $order->getPayment() ? (string)$order->getPayment()->getMethod() : ''
];
} catch (\Exception $e) {
$this->debugger->debug('PurchaseWebhookEvent::purchase(): could not resolve shipping/base data: ' . $e->getMessage());
}

try {
$data['user_data'] = [
"customer_id" => $order->getCustomerId() ?? '',
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tagginggroup/gtm",
"version": "1.6.0",
"version": "1.7.0",
"license": "OSL-3.0",
"type": "magento2-module",
"description": "AdPage tagging integration for Magento 2",
Expand Down
Loading