Merge branch 'ticket-blockOrderSummary' into develop

This commit is contained in:
Marion Muszynski 2016-07-13 15:10:48 +02:00
commit 98b264471c
5 changed files with 247 additions and 29 deletions

View File

@ -100,39 +100,39 @@ class BlockBestSellers extends Module
if (Configuration::get('PS_CATALOG_MODE'))
return ;
global $smarty;
global $cookie;
global $cookie, $smarty, $cart;
$step = Tools::getValue('step');
if(!$step || ($step && $step != 3 && $step != 4)) {
$id_lang = $cookie->id_lang;
$id_lang = $cookie->id_lang;
Tools::enableCache();
$smarty->cache_lifetime = 3600;
$cache_id = "blockbestsellers".$id_lang;
Tools::enableCache();
$smarty->cache_lifetime = 3600;
$cache_id = "blockbestsellers".$id_lang;
if(!$this->isCached('blockbestsellers_'.(int) $cookie->id_lang.'.tpl', $cache_id)) {
$currency = new Currency((int)($params['cookie']->id_currency));
$bestsellers = ProductSale::getBestSalesVp((int)($params['cookie']->id_lang), 0, 5, NULL, NULL, 10);
if (!$bestsellers AND !Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY'))
return;
$best_sellers = array();
if($bestsellers)
foreach ($bestsellers AS $bestseller)
{
$bestseller['price'] = Tools::displayPrice(Product::getPriceStatic((int)($bestseller['id_product'])), $currency);
$best_sellers[] = $bestseller;
}
if(!$this->isCached('blockbestsellers_'.(int) $cookie->id_lang.'.tpl', $cache_id)) {
$currency = new Currency((int)($params['cookie']->id_currency));
$bestsellers = ProductSale::getBestSalesVp((int)($params['cookie']->id_lang), 0, 5, NULL, NULL, 10);
if (!$bestsellers AND !Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY'))
return;
$best_sellers = array();
$smarty->assign(array(
'best_sellers' => $best_sellers,
'mediumSize' => Image::getSize('medium')));
if($bestsellers)
foreach ($bestsellers AS $bestseller)
{
$bestseller['price'] = Tools::displayPrice(Product::getPriceStatic((int)($bestseller['id_product'])), $currency);
$best_sellers[] = $bestseller;
}
$smarty->assign(array(
'best_sellers' => $best_sellers,
'mediumSize' => Image::getSize('medium')));
}
$display = $this->display(__FILE__, 'blockbestsellers_'.(int) $cookie->id_lang.'.tpl', $cache_id);
Tools::restoreCacheSettings();
$smarty->cache_lifetime = -1;
return $display;
}
$display = $this->display(__FILE__, 'blockbestsellers_'.(int) $cookie->id_lang.'.tpl', $cache_id);
Tools::restoreCacheSettings();
$smarty->cache_lifetime = -1;
return $display;
}
// Best sale on lightbox add to cart

View File

@ -0,0 +1,113 @@
<?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)));
}
$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++;
}
if(count($products_keys) > 0) {
foreach(Db::getInstance()->ExecuteS('
SELECT l.`id_delay`, l.`name`
FROM `'._DB_PREFIX_.'privatesale_delay_sale` s
LEFT JOIN `'._DB_PREFIX_.'privatesale_delay_lang` l
ON s.`id_delay` = l.`id_delay`
LEFT JOIN `'._DB_PREFIX_.'product_ps_cache` c
ON s.`id_sale` = c.`id_sale`
WHERE l.`id_lang` = '.(int) $cookie->id_lang.'
AND s.`id_lang` = '.(int) $cookie->id_lang.'
AND c.`id_product` IN ('.implode(', ', array_keys($products_keys)).')
ORDER BY l.`value` ASC
') as $row) {
$delay_name = $row['name'];
break;
}
}
$smarty->assign(array(
'order_address' => $order_address,
'carrier_name' => $carrier_name,
'delay_name' => $delay_name,
));
return $this->display(__FILE__, 'blockordersummary.tpl');
}
}
public function hookRightColumn($params) {
return $this->hookLeftColumn($params);
}
}

View File

@ -0,0 +1,32 @@
{assign var=$products value=$cart->getProducts()}
<div id="blockordersummary">
<div class="content">
<h4>{l s='Summary of my order' mod='blockordersummary'}</h4>
<div class='my-cart'>
<h5>{l s='My cart' mod='blockordersummary'}</h5>
<ul>
{foreach $products as $product}
<li>{$product.quantity} x {$product.name|truncate:20:'…'} <span class="price">{convertPrice price=$product.total_wt}</span></li>
{/foreach}
</ul>
<p>{l s='Products total' mod='blockordersummary'} <span class="price price_total">{convertPrice price=$cart->getOrderTotal(TRUE, 1)}</span></p>
{if {$cart->getOrderTotal(TRUE, 2) != 0}}<p>{l s='Discounts total' mod='blockordersummary'} <span class="price price_total">{convertPrice price=$cart->getOrderTotal(TRUE, 2)}</span></p>{/if}
</div>
<div>
<h5>{l s='Shipping' mod='blockordersummary'}</h5>
<p>{$carrier_name} <span class="price price_total">{convertPrice price=$cart->getOrderTotal(TRUE, 5)}</span></p>
</div>
<div>
<h5>{l s='Delivery delays' mod='blockordersummary'}</h5>
<strong>{$delay_name}</strong>
</div>
<div>
<h5>{l s='My shipping address' mod='blockordersummary'}</h5>
<p class="address">{$order_address}</p>
</div>
<div>
<h5>{l s='My payment' mod='blockordersummary'}</h5>
<p class="order_total">{l s='Total to pay' mod='blockordersummary'} <span class="price price_total">{convertPrice price=$cart->getOrderTotal(TRUE)}</span></p>
</div>
</div>
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 573 B

View File

@ -6659,6 +6659,79 @@ table#carrierTable tbody td {
text-align:center;
}
/**** blockordersummury ****/
#left_column #blockordersummary {
background: #fff;
padding-bottom: 5px;
margin-bottom: 20px;
-moz-box-shadow: 1px 2px 1px #cccccc;
-webkit-box-shadow: 1px 2px 1px #ccc;
-ms-box-shadow: 1px 2px 1px #cccccc;
-o-box-shadow: 1px 2px 1px #cccccc;
box-shadow: 1px 2px 1px #ccc;
clear: both;
}
#left_column #blockordersummary .content {
padding: 5px;
}
#left_column #blockordersummary .content div{
color: #1e1633;
margin: 0px 10px;
font-size: 12px;
padding: 8px 0px 5px;
border-top: 1px dashed #ccc;
line-height: 1.4em;
}
#left_column #blockordersummary .content div.my-cart {
border-top: 1px solid #ccc;
}
#left_column #blockordersummary h4{
display: block;
font-size: 18px;
color: #796dc7;
font-weight: normal;
margin: 0px 10px 2px;
padding: 12px 0px 10px;
border-bottom: 1px solid #ccc;
}
#blockordersummary h5 {
color: #444d52;
font-family: georgia, times new roman, serif;
margin-bottom: 10px;
font-weight: 600;
font-size: 13px;
}
#blockordersummary ul {
margin: 0px 0px 7px;
padding: 0px;
list-style: none;
border-bottom: 1px solid #999;
}
#blockordersummary li {
padding-bottom: 5px;
}
#blockordersummary p {
margin-bottom: 5px;
}
#blockordersummary .price {
float: right;
}
#blockordersummary .price.price_total {
color: #e36ea2;
font-weight: bold;
}
#blockordersummary .address {
color: #1e1633;
}
#blockordersummary .order_total {
color: #e36ea2;
padding: 15px;
font-size: 14px;
font-weight: bold;
background: rgba(226,110,162,0.4) ;
}
@keyframes slideInDown {
0% {
-webkit-transform: translateY(-500px);