Skip to content

Commit b9e170f

Browse files
committed
Use order currency, not context
1 parent a40cb2b commit b9e170f

3 files changed

Lines changed: 24 additions & 14 deletions

File tree

classes/Hook/HookDisplayBackOfficeHeader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function run()
101101
'value' => (float) $transaction['revenue'],
102102
'tax' => (float) $transaction['tax'],
103103
'shipping' => (float) $transaction['shipping'],
104-
'currency' => $this->context->currency->iso_code,
104+
'currency' => $transaction['currency'],
105105
'event_callback' => "function() {
106106
$.get('" . $transaction['url'] . "', " . json_encode($callbackData, JSON_UNESCAPED_UNICODE) . ');
107107
}',

classes/Hook/HookDisplayOrderConfirmation.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,12 @@ public function run()
6363
$gaTagHandler = new GanalyticsJsHandler($this->module, $this->context);
6464
$productWrapper = new ProductWrapper($this->context);
6565

66+
// Prepare currency information
67+
$currency = new Currency((int) $order->id_currency);
68+
6669
// Add payment data
6770
$eventData = [
68-
'currency' => $this->context->currency->iso_code,
71+
'currency' => $currency->iso_code,
6972
'payment_type' => $order->payment,
7073
];
7174
$gaScripts = $this->module->getTools()->renderEvent(
@@ -76,13 +79,13 @@ public function run()
7679
// Prepare transaction data
7780
$transaction = [
7881
'id' => (int) $order->id,
79-
'affiliation' => (Shop::isFeatureActive()) ? $this->context->shop->name : Configuration::get('PS_SHOP_NAME'),
82+
'affiliation' => Shop::isFeatureActive() ? $this->context->shop->name : Configuration::get('PS_SHOP_NAME'),
8083
'revenue' => (float) $order->total_paid,
8184
'shipping' => (float) $order->total_shipping,
8285
'tax' => (float) $order->total_paid_tax_incl - $order->total_paid_tax_excl,
8386
'url' => $this->context->link->getModuleLink('ps_googleanalytics', 'ajax', [], true),
8487
'customer' => (int) $order->id_customer,
85-
'currency' => $this->context->currency->iso_code,
88+
'currency' => $currency->iso_code,
8689
];
8790

8891
// Prepare order products

classes/Wrapper/OrderWrapper.php

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,23 @@ public function wrapOrder($id_order)
4343
{
4444
$order = new Order((int) $id_order);
4545

46-
if (Validate::isLoadedObject($order)) {
47-
return [
48-
'id' => $id_order,
49-
'affiliation' => Shop::isFeatureActive() ? $this->context->shop->name : Configuration::get('PS_SHOP_NAME'),
50-
'revenue' => $order->total_paid,
51-
'shipping' => $order->total_shipping,
52-
'tax' => $order->total_paid_tax_incl - $order->total_paid_tax_excl,
53-
'url' => $this->context->link->getAdminLink('AdminGanalyticsAjax'),
54-
'customer' => $order->id_customer,
55-
];
46+
// Check order still exists
47+
if (!Validate::isLoadedObject($order)) {
48+
return;
5649
}
50+
51+
// Prepare currency information
52+
$currency = new Currency((int) $order->id_currency);
53+
54+
return [
55+
'id' => (int) $order->id,
56+
'affiliation' => Shop::isFeatureActive() ? $this->context->shop->name : Configuration::get('PS_SHOP_NAME'),
57+
'revenue' => (float) $order->total_paid,
58+
'shipping' => (float) $order->total_shipping,
59+
'tax' => (float) $order->total_paid_tax_incl - $order->total_paid_tax_excl,
60+
'url' => $this->context->link->getAdminLink('AdminGanalyticsAjax'),
61+
'customer' => (int) $order->id_customer,
62+
'currency' => $currency->iso_code,
63+
];
5764
}
5865
}

0 commit comments

Comments
 (0)