toutpratique/override/controllers/front/OrderConfirmationController.php
2015-12-14 16:07:18 +01:00

99 lines
2.5 KiB
PHP

<?php
class OrderConfirmationController extends OrderConfirmationControllerCore
{
public function initContent()
{
FrontController::initContent();
$order = new Order($this->id_order);
$idps = array();
$orderProducts = $order->getProductsDetail();
foreach($orderProducts as $key => $product)
{
$idps[] = $product['id_product'];
$orderProducts[$key]['cat_name'] = Category::getNameStatic($product['id_category_default']);
}
$this->context->smarty->assign(array(
'langIsoCode' => $this->context->language->iso_code,
'idps' => implode(',', $idps),
'orderInfo' => $order,
'orderProducts' => $orderProducts,
'cartCreateOnCMSPage' => $_COOKIE['fromCMS']
));
$this->context->smarty->assign(array(
'is_guest' => $this->context->customer->is_guest,
'HOOK_ORDER_CONFIRMATION' => $this->displayOrderConfirmation(),
'HOOK_PAYMENT_RETURN' => $this->displayPaymentReturn()
));
if ($this->context->customer->is_guest)
{
$this->context->smarty->assign(array(
'id_order' => $this->id_order,
'reference_order' => $this->reference,
'id_order_formatted' => sprintf('#%06d', $this->id_order),
'email' => $this->context->customer->email
));
/* If guest we clear the cookie for security reason */
$this->context->customer->mylogout();
}
$this->setTemplate(_PS_THEME_DIR_.'order-confirmation.tpl');
}
/**
* Execute the hook displayPaymentReturn
*/
public function displayPaymentReturn()
{
if (Validate::isUnsignedId($this->id_order) && Validate::isUnsignedId($this->id_module))
{
$params = array();
$order = new Order($this->id_order);
$currency = new Currency($order->id_currency);
if (Validate::isLoadedObject($order))
{
$params['total_to_pay'] = $order->getOrdersTotalPaid();
$params['currency'] = $currency->sign;
$params['objOrder'] = $order;
$params['currencyObj'] = $currency;
return Hook::exec('displayPaymentReturn', $params, $this->id_module);
}
}
return false;
}
/**
* Execute the hook displayOrderConfirmation
*/
public function displayOrderConfirmation()
{
if (Validate::isUnsignedId($this->id_order))
{
$params = array();
$order = new Order($this->id_order);
$currency = new Currency($order->id_currency);
if (Validate::isLoadedObject($order))
{
$params['total_to_pay'] = $order->getOrdersTotalPaid();
$params['currency'] = $currency->sign;
$params['objOrder'] = $order;
$params['currencyObj'] = $currency;
return Hook::exec('displayOrderConfirmation', $params);
}
}
return false;
}
}