123 lines
4.6 KiB
PHP
123 lines
4.6 KiB
PHP
<?php
|
|
if (!defined('_PS_VERSION_'))
|
|
exit;
|
|
|
|
|
|
class BlockOrderSummary extends Module {
|
|
private $types = array();
|
|
|
|
public function __construct() {
|
|
$this->name = 'blockordersummary';
|
|
$this->tab = 'front_office_features';
|
|
$this->version = '1.0';
|
|
$this->author = 'Antadis';
|
|
$this->need_instance = 0;
|
|
|
|
parent::__construct();
|
|
|
|
$this->displayName = $this->l('Order summary block');
|
|
$this->description = $this->l('Displays a summary of the current order');
|
|
}
|
|
|
|
public function install() {
|
|
return parent::install() && $this->registerHook('leftColumn');
|
|
}
|
|
|
|
public function hookLeftColumn($params) {
|
|
global $cookie, $smarty, $cart;
|
|
if(($step = (int) Tools::getValue('step')) && ($step == 3 || $step == 4)) {
|
|
|
|
if(Db::getInstance()->getValue('
|
|
SELECT `id_carrier`
|
|
FROM `'._DB_PREFIX_.'carrier`
|
|
WHERE `id_carrier` = '.(int) $cart->id_carrier.'
|
|
AND `name` LIKE "%so colissimo%"
|
|
')) {
|
|
$socol = Db::getInstance()->getRow('
|
|
SELECT *
|
|
FROM `'._DB_PREFIX_.'socolissimo_delivery_info`
|
|
WHERE `id_cart` = '.(int) $cart->id.'
|
|
');
|
|
|
|
if($socol) {
|
|
$order_address = nl2br(preg_replace("/(\r\n){2,}/", "\r\n", implode("\r\n", array(
|
|
$socol['cefirstname'].' '.$socol['cename'],
|
|
$socol['cecompanyname'],
|
|
$socol['prfirstname'].' '.$socol['prname'],
|
|
$socol['prcompladress'],
|
|
$socol['pradress1'],
|
|
$socol['pradress2'],
|
|
$socol['pradress3'],
|
|
$socol['pradress4'],
|
|
$socol['przipcode'].' '.$socol['prtown'],
|
|
'FRANCE',
|
|
$socol['cephonenumber'],
|
|
!empty($socol['cedoorcode1'])? 'Code porte 1 : '.$socol['cedoorcode1']: '',
|
|
!empty($socol['cedoorcode2'])? 'Code porte 2 : '.$socol['cedoorcode2']: '',
|
|
$socol['cedeliveryinformation'],
|
|
))));
|
|
} else {
|
|
$order_address = nl2br(AddressFormat::generateAddress(new Address((int) $cart->id_address_delivery)));
|
|
}
|
|
} else {
|
|
$order_address = nl2br(AddressFormat::generateAddress(new Address((int) $cart->id_address_delivery)));
|
|
}
|
|
|
|
if ($cookie->id_lang == 3 && (int)$cart->id_carrier == 87) {
|
|
$carrier_name = "SEUR a domicilio";
|
|
} else {
|
|
$carrier_name = Db::getInstance()->getValue('
|
|
SELECT `name`
|
|
FROM `'._DB_PREFIX_.'carrier`
|
|
WHERE `id_carrier` = '.(int) $cart->id_carrier.'
|
|
');
|
|
}
|
|
|
|
$products_keys = array();
|
|
$products_delays = array();
|
|
|
|
$products = $cart->getProducts();
|
|
$i = 0;
|
|
foreach($products as $product) {
|
|
$products_keys[(int) $product['id_product']] = $i;
|
|
$i++;
|
|
}
|
|
|
|
// assign delay to Products
|
|
if (Module::isInstalled('privatesales_delay')) {
|
|
if (!class_exists('SaleDelay')) {
|
|
require_once _PS_ROOT_DIR_.'/modules/privatesales_delay/saledelay.php';
|
|
}
|
|
$delay_products = SaleDelay::associateDelay($products);
|
|
|
|
$delays = array_keys($delay_products);
|
|
$date = new DateTime();
|
|
$delivery_date = SaleDelay::getDeliveryDate($delays, null, $date, true);
|
|
|
|
foreach($delays as $delay) {
|
|
$row = Db::getInstance()->getRow('
|
|
SELECT l.`name`
|
|
FROM `'._DB_PREFIX_.'privatesale_delay_lang` l
|
|
WHERE l.`id_lang` = '.(int) $cookie->id_lang.'
|
|
AND l.`id_delay`='.(int)$delay.'
|
|
');
|
|
$delay_name = $row['name'];
|
|
break;
|
|
}
|
|
}
|
|
|
|
$smarty->assign(array(
|
|
'order_address' => $order_address,
|
|
'carrier_name' => $carrier_name,
|
|
'delay_name' => $delay_name,
|
|
'delivery_date' => (isset($delivery_date)?$delivery_date:null)
|
|
));
|
|
|
|
return $this->display(__FILE__, 'blockordersummary.tpl');
|
|
}
|
|
}
|
|
|
|
public function hookRightColumn($params) {
|
|
return $this->hookLeftColumn($params);
|
|
}
|
|
} |