95 lines
2.5 KiB
PHP
Executable File
95 lines
2.5 KiB
PHP
Executable File
<?php
|
|
|
|
class OrderConfirmationController extends OrderConfirmationControllerCore
|
|
{
|
|
public function preProcess()
|
|
{
|
|
// Fix : delay after payment from paybox or paypal
|
|
// so that the order has enough time to be created.
|
|
sleep(5);
|
|
|
|
parent::preProcess();
|
|
|
|
$order = new Order($this->id_order);
|
|
$products = $order->getProducts();
|
|
foreach ($products as $product) {
|
|
$productIds[] = (int) $product['product_id'];
|
|
}
|
|
|
|
self::$smarty->assign(array(
|
|
'order' => $order,
|
|
'productIds' => $productIds,
|
|
'currency' => Currency::getCurrency((int) $order->id_currency),
|
|
));
|
|
}
|
|
|
|
public function displayContent()
|
|
{
|
|
$customer = Context::getContext()->customer;
|
|
|
|
$order = new Order($this->id_order);
|
|
$products = $order->getProducts();
|
|
$address_delivery = new Address($order->id_address_delivery);
|
|
$address_invoice = new Address($order->id_address_invoice);
|
|
|
|
foreach ($products as $key => $product) {
|
|
$cover = Product::getCover((int) $product['product_id']);
|
|
$products[$key]['id_image'] = $cover['id_image'];
|
|
}
|
|
|
|
// assign delay to Products
|
|
if (Module::isInstalled('privatesales_delay')) {
|
|
require_once _PS_ROOT_DIR_.'/modules/privatesales_delay/saledelay.php';
|
|
$products = SaleDelay::associateDelay($products);
|
|
}
|
|
|
|
$analytics_timeover = 0;
|
|
$transCpt = 0;
|
|
|
|
// Cookie
|
|
global $cookie;
|
|
// Reset
|
|
if (isset($cookie->id_transaction)) {
|
|
if ($cookie->id_transaction != $order->id) {
|
|
unset($cookie->id_transaction);
|
|
unset($cookie->transCpt);
|
|
}
|
|
}
|
|
// Set counter
|
|
if (isset($cookie->transCpt)) {
|
|
$transCpt = (int) $cookie->transCpt;
|
|
}
|
|
$transCpt++;
|
|
if ($transCpt > 1) {
|
|
$analytics_timeover = 1;
|
|
}
|
|
// Check date order if page is refresh and not affect analytics
|
|
if ($analytics_timeover == 0) {
|
|
$timestamp_check = new DateTime();
|
|
$timestamp_check->createFromFormat('Y-m-d H:i:s', $order->date_add);
|
|
$timestamp_check->add(new DateInterval('PT10M'));
|
|
$timestamp = $timestamp_check->getTimestamp();
|
|
if (time() > $timestamp) {
|
|
$analytics_timeover = 1;
|
|
$transCpt++;
|
|
}
|
|
}
|
|
// Write cookie
|
|
$cookie->transCpt = $transCpt;
|
|
$cookie->id_transaction = $order->id;
|
|
$cookie->write();
|
|
|
|
self::$smarty->assign(
|
|
array(
|
|
'customer' => $customer,
|
|
'order' => $order,
|
|
'address_delivery' => $address_delivery,
|
|
'address_invoice' => $address_invoice,
|
|
'products' => $products,
|
|
'analytics_timeover' => $analytics_timeover,
|
|
)
|
|
);
|
|
self::$smarty->display(_PS_THEME_DIR_.'order-confirmation.tpl');
|
|
}
|
|
|
|
} |