[*] MO : TM - Blockcart added Layer
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<module>
|
||||
<name>blockbestsellers</name>
|
||||
<displayName><![CDATA[Top-seller block]]></displayName>
|
||||
<version><![CDATA[1.2]]></version>
|
||||
<version><![CDATA[1.3]]></version>
|
||||
<description><![CDATA[Add a block displaying your store's top-selling products.]]></description>
|
||||
<author><![CDATA[PrestaShop]]></author>
|
||||
<tab><![CDATA[front_office_features]]></tab>
|
||||
|
||||
@@ -253,6 +253,14 @@ var ajaxCart = {
|
||||
.fadeOut(100, function() {
|
||||
ajaxCart.updateCartInformation(jsonData, addedFromProductPage);
|
||||
$(this).remove();
|
||||
if (!jsonData.hasError)
|
||||
{
|
||||
$('.crossseling').html(jsonData.crossSelling)
|
||||
$(jsonData.products).each(function(){
|
||||
if (this.id != undefined && this.id == parseInt(idProduct))
|
||||
ajaxCart.updateLayer(this);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
@@ -581,6 +589,25 @@ var ajaxCart = {
|
||||
return (content);
|
||||
},
|
||||
|
||||
updateLayer : function(product) {
|
||||
$('#layer_cart_product_title').text(product.name);
|
||||
$('#layer_cart_product_attributes').text('');
|
||||
if (product.hasAttributes && product.hasAttributes == true)
|
||||
$('#layer_cart_product_attributes').html(product.attributes);
|
||||
$('#layer_cart_product_price').text(product.price);
|
||||
$('#layer_cart_product_quantity').text(product.quantity);
|
||||
$('.layer_cart_img').prop({'src' : product.image, 'alt' : product.name, 'title' : product.name});
|
||||
var h = parseInt($(window).height());
|
||||
var s = parseInt($(window).scrollTop());
|
||||
var t = $('#layer_cart').outerHeight(true);
|
||||
if (t < h)
|
||||
var n = parseInt(((h-t) / 2) + s) + 'px';
|
||||
$('.layer_cart_overlay').css('width',$('body').width());
|
||||
$('.layer_cart_overlay').css('height',$('body').height());
|
||||
$('.layer_cart_overlay').show();
|
||||
$('#layer_cart').css({'top': n}).fadeIn('fast');
|
||||
crossselling_serialScroll();
|
||||
},
|
||||
|
||||
//genarally update the display of the cart
|
||||
updateCart : function(jsonData) {
|
||||
@@ -615,7 +642,6 @@ var ajaxCart = {
|
||||
//update general cart informations everywhere in the page
|
||||
updateCartEverywhere : function(jsonData) {
|
||||
$('.ajax_cart_total').text($.trim(jsonData.productTotal));
|
||||
|
||||
if (parseFloat(jsonData.shippingCostFloat) > 0 || jsonData.nbTotalProducts < 1)
|
||||
$('.ajax_cart_shipping_cost').text(jsonData.shippingCost);
|
||||
else if (typeof(freeShippingTranslation) != 'undefined')
|
||||
@@ -623,6 +649,16 @@ var ajaxCart = {
|
||||
$('.ajax_cart_tax_cost').text(jsonData.taxCost);
|
||||
$('.cart_block_wrapping_cost').text(jsonData.wrappingCost);
|
||||
$('.ajax_block_cart_total').text(jsonData.total);
|
||||
$('.ajax_block_products_total').text(jsonData.productTotal);
|
||||
$('.ajax_total_price_wt').text(jsonData.total_price_wt);
|
||||
|
||||
if (parseFloat(jsonData.freeShippingFloat) > 0)
|
||||
{
|
||||
$('.ajax_cart_free_shipping').html(jsonData.freeShipping);
|
||||
$('.freeshipping').fadeIn(0);
|
||||
}
|
||||
else if (parseFloat(jsonData.freeShippingFloat) == 0)
|
||||
$('.freeshipping').fadeOut(0);
|
||||
|
||||
this.nb_total_products = jsonData.nbTotalProducts;
|
||||
|
||||
@@ -664,24 +700,8 @@ var ajaxCart = {
|
||||
}
|
||||
};
|
||||
|
||||
function HoverWatcher(selector){
|
||||
this.hovering = false;
|
||||
var self = this;
|
||||
|
||||
this.isHoveringOver = function() {
|
||||
return self.hovering;
|
||||
}
|
||||
|
||||
$(selector).hover(function() {
|
||||
self.hovering = true;
|
||||
}, function() {
|
||||
self.hovering = false;
|
||||
})
|
||||
}
|
||||
|
||||
//when document is loaded...
|
||||
$(document).ready(function(){
|
||||
// expand/collapse management
|
||||
$(document).ready(function()
|
||||
{
|
||||
$('#block_cart_collapse').click(function(){
|
||||
ajaxCart.collapse();
|
||||
});
|
||||
@@ -753,4 +773,56 @@ $(document).ready(function(){
|
||||
$(this).attr('disabled', true).removeClass('exclusive').addClass('exclusive_disabled');
|
||||
$(this).closest("form").get(0).submit();
|
||||
});
|
||||
|
||||
$('#layer_cart .cross, #layer_cart .continue, .layer_cart_overlay').click(function(){
|
||||
$('.layer_cart_overlay').hide(); $('#layer_cart').fadeOut('fast'); return false;
|
||||
});
|
||||
});
|
||||
|
||||
function HoverWatcher(selector){
|
||||
this.hovering = false;
|
||||
var self = this;
|
||||
|
||||
this.isHoveringOver = function() {
|
||||
return self.hovering;
|
||||
}
|
||||
|
||||
$(selector).hover(function() {
|
||||
self.hovering = true;
|
||||
}, function() {
|
||||
self.hovering = false;
|
||||
})
|
||||
}
|
||||
|
||||
function crossselling_serialScrollFixLock(event, targeted, scrolled, items, position)
|
||||
{
|
||||
serialScrollNbImages = $('#blockcart_list li:visible').length;
|
||||
serialScrollNbImagesDisplayed = 4;
|
||||
|
||||
var leftArrow = position == 0 ? true : false;
|
||||
var rightArrow = position + serialScrollNbImagesDisplayed >= serialScrollNbImages ? true : false;
|
||||
|
||||
$('#blockcart_scroll_left').css('cursor', leftArrow ? 'default' : 'pointer').css('display', leftArrow ? 'none' : 'block').fadeTo(0, leftArrow ? 0 : 1);
|
||||
$('#blockcart_scroll_right').css('cursor', rightArrow ? 'default' : 'pointer').fadeTo(0, rightArrow ? 0 : 1).css('display', rightArrow ? 'none' : 'block');
|
||||
return true;
|
||||
}
|
||||
|
||||
function crossselling_serialScroll()
|
||||
{
|
||||
$('#blockcart_list').serialScroll({
|
||||
items:'li:visible',
|
||||
prev:'#blockcart_scroll_left',
|
||||
next:'#blockcart_scroll_right',
|
||||
axis:'x',
|
||||
offset:0,
|
||||
start:0,
|
||||
stop:true,
|
||||
onBefore:crossselling_serialScrollFixLock,
|
||||
duration:300,
|
||||
step: 1,
|
||||
lazy: true,
|
||||
lock: false,
|
||||
force:false
|
||||
});
|
||||
$('#blockcart_list').trigger('goto', 0);
|
||||
}
|
||||
@@ -31,8 +31,9 @@
|
||||
{ldelim}
|
||||
"id": {$product.id_product},
|
||||
"link": "{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category, null, null, $product.id_shop, $product.id_product_attribute)|addslashes|replace:'\\\'':'\''}",
|
||||
"quantity": {$product.cart_quantity},
|
||||
"quantity": {$product.cart_quantity|intval},
|
||||
"priceByLine": "{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total}{else}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total_wt}{/if}",
|
||||
"image": "{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')|addslashes|replace:'\\\'':'\''}",
|
||||
"name": "{$product.name|html_entity_decode:2:'UTF-8'|truncate:15:'...':true|escape:'htmlall'}",
|
||||
"price": "{if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total}{else}{displayWtPrice|html_entity_decode:2:'UTF-8' p=$product.total_wt}{/if}",
|
||||
"price_float": "{$product.total}",
|
||||
@@ -99,6 +100,8 @@
|
||||
"nbTotalProducts": "{$nb_total_products}",
|
||||
"total": "{$total|html_entity_decode:2:'UTF-8'}",
|
||||
"productTotal": "{$product_total|html_entity_decode:2:'UTF-8'}",
|
||||
"freeShipping": "{displayWtPrice|html_entity_decode:2:'UTF-8' p=$free_shipping}",
|
||||
"freeShippingFloat": "{$free_shipping|html_entity_decode:2:'UTF-8'}",
|
||||
{if isset($errors) && $errors}
|
||||
"hasError" : true,
|
||||
"errors" : [
|
||||
|
||||
@@ -110,4 +110,51 @@
|
||||
text-align: right;
|
||||
width: 15px;
|
||||
}
|
||||
|
||||
#layer_cart {
|
||||
background-color:#f9f9f9;
|
||||
border:1px solid #dcdcdc;
|
||||
padding:4px;
|
||||
position:absolute;
|
||||
left:0;
|
||||
clear:both;
|
||||
display:none;
|
||||
z-index:99;
|
||||
}
|
||||
.layer_cart_overlay {
|
||||
background-color:#000;
|
||||
display:none;
|
||||
height:100%;
|
||||
left:0;
|
||||
position:fixed;
|
||||
top:0;
|
||||
width:100%;
|
||||
z-index:98;
|
||||
opacity:.50;
|
||||
-moz-opacity:.50;
|
||||
filter:alpha(opacity=50);
|
||||
}
|
||||
* html .layer_cart_overlay {
|
||||
filter:alpha(opacity=50);
|
||||
position:absolute;
|
||||
left:0;
|
||||
margin-left:-160px;
|
||||
}
|
||||
#layer_cart .continue {
|
||||
cursor: pointer;
|
||||
}
|
||||
#layer_cart p {
|
||||
padding: 0px;
|
||||
}
|
||||
#blockcart_list {
|
||||
width: 232px;
|
||||
overflow: hidden;
|
||||
}
|
||||
#blockcart_list ul {
|
||||
display: block;
|
||||
height: 90px;
|
||||
}
|
||||
#blockcart_list li {
|
||||
list-style-type: none;
|
||||
float: left;
|
||||
width: 58px;
|
||||
}
|
||||
@@ -33,7 +33,7 @@ class BlockCart extends Module
|
||||
{
|
||||
$this->name = 'blockcart';
|
||||
$this->tab = 'front_office_features';
|
||||
$this->version = '1.2';
|
||||
$this->version = '1.3';
|
||||
$this->author = 'PrestaShop';
|
||||
$this->need_instance = 0;
|
||||
|
||||
@@ -99,6 +99,17 @@ class BlockCart extends Module
|
||||
}
|
||||
}
|
||||
|
||||
$total_free_shipping = 0;
|
||||
if ($free_shipping = Tools::convertPrice(floatval(Configuration::get('PS_SHIPPING_FREE_PRICE')), new Currency(intval($params['cart']->id_currency))))
|
||||
{
|
||||
$total_free_shipping = floatval($free_shipping - ($params['cart']->getOrderTotal(true, Cart::ONLY_PRODUCTS) + $params['cart']->getOrderTotal(true, Cart::ONLY_DISCOUNTS)));
|
||||
$discounts = $params['cart']->getCartRules(CartRule::FILTER_ACTION_SHIPPING);
|
||||
if ($total_free_shipping < 0)
|
||||
$total_free_shipping = 0;
|
||||
if (is_array($discounts) && count($discounts))
|
||||
$total_free_shipping = 0;
|
||||
}
|
||||
|
||||
$this->smarty->assign(array(
|
||||
'products' => $products,
|
||||
'customizedDatas' => Product::getAllCustomizedDatas((int)($params['cart']->id)),
|
||||
@@ -115,7 +126,8 @@ class BlockCart extends Module
|
||||
'total' => Tools::displayPrice($totalToPay, $currency),
|
||||
'order_process' => Configuration::get('PS_ORDER_PROCESS_TYPE') ? 'order-opc' : 'order',
|
||||
'ajax_allowed' => (int)(Configuration::get('PS_BLOCK_CART_AJAX')) == 1 ? true : false,
|
||||
'static_token' => Tools::getToken(false)
|
||||
'static_token' => Tools::getToken(false),
|
||||
'free_shipping' => $total_free_shipping
|
||||
));
|
||||
if (count($errors))
|
||||
$this->smarty->assign('errors', $errors);
|
||||
@@ -134,6 +146,16 @@ class BlockCart extends Module
|
||||
else
|
||||
Configuration::updateValue('PS_BLOCK_CART_AJAX', (int)($ajax));
|
||||
$output .= $this->displayConfirmation($this->l('Settings updated'));
|
||||
|
||||
if (!($productNbr = Tools::getValue('PS_BLOCK_CART_XSELL_LIMIT')) || empty($productNbr))
|
||||
$output .= $this->displayError($this->l('Please complete the "products to display" field.'));
|
||||
elseif ((int)($productNbr) == 0)
|
||||
$output .= $this->displayError($this->l('Invalid number.'));
|
||||
else
|
||||
{
|
||||
Configuration::updateValue('PS_BLOCK_CART_XSELL_LIMIT', (int)(Tools::getValue('PS_BLOCK_CART_XSELL_LIMIT')));
|
||||
$output .= $this->displayConfirmation($this->l('Settings updated'));
|
||||
}
|
||||
}
|
||||
return $output.$this->renderForm();
|
||||
}
|
||||
@@ -145,7 +167,8 @@ class BlockCart extends Module
|
||||
|| $this->registerHook('top') == false
|
||||
|| $this->registerHook('header') == false
|
||||
|| $this->registerHook('actionCartListOverride') == false
|
||||
|| Configuration::updateValue('PS_BLOCK_CART_AJAX', 1) == false)
|
||||
|| Configuration::updateValue('PS_BLOCK_CART_AJAX', 1) == false
|
||||
|| Configuration::updateValue('PS_BLOCK_CART_XSELL_LIMIT', 12) == false)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@@ -172,7 +195,13 @@ class BlockCart extends Module
|
||||
return;
|
||||
|
||||
$this->assignContentVars($params);
|
||||
$res = $this->display(__FILE__, 'blockcart-json.tpl');
|
||||
$res = Tools::jsonDecode($this->display(__FILE__, 'blockcart-json.tpl'), true);
|
||||
if (is_array($res) && $id_product = Tools::getValue('id_product'))
|
||||
{
|
||||
$this->smarty->assign('orderProducts', OrderDetail::getCrossSells($id_product, $this->context->language->id, Configuration::get('PS_BLOCK_CART_XSELL_LIMIT')));
|
||||
$res['crossSelling'] = $this->display(__FILE__, 'crossselling.tpl');
|
||||
}
|
||||
$res = Tools::jsonEncode($res);
|
||||
return $res;
|
||||
}
|
||||
|
||||
@@ -192,7 +221,10 @@ class BlockCart extends Module
|
||||
|
||||
$this->context->controller->addCSS(($this->_path).'blockcart.css', 'all');
|
||||
if ((int)(Configuration::get('PS_BLOCK_CART_AJAX')))
|
||||
{
|
||||
$this->context->controller->addJS(($this->_path).'ajax-cart.js');
|
||||
$this->context->controller->addJqueryPlugin(array('scrollTo', 'serialScroll'));
|
||||
}
|
||||
}
|
||||
|
||||
public function hookTop($params)
|
||||
@@ -227,7 +259,14 @@ class BlockCart extends Module
|
||||
'label' => $this->l('Disabled')
|
||||
)
|
||||
),
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Products to display in cross selling'),
|
||||
'name' => 'PS_BLOCK_CART_XSELL_LIMIT',
|
||||
'class' => 'fixed-width-xs',
|
||||
'desc' => $this->l('Define the number of products to be displayed in the cross selling block.')
|
||||
),
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
@@ -260,7 +299,7 @@ class BlockCart extends Module
|
||||
{
|
||||
return array(
|
||||
'PS_BLOCK_CART_AJAX' => Tools::getValue('PS_BLOCK_CART_AJAX', Configuration::get('PS_BLOCK_CART_AJAX')),
|
||||
'PS_BLOCK_CART_XSELL_LIMIT' => Tools::getValue('PS_BLOCK_CART_XSELL_LIMIT', Configuration::get('PS_BLOCK_CART_XSELL_LIMIT'))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
<module>
|
||||
<name>blockcart</name>
|
||||
<displayName><![CDATA[Cart block]]></displayName>
|
||||
<version><![CDATA[1.2]]></version>
|
||||
<version><![CDATA[1.3]]></version>
|
||||
<description><![CDATA[Adds a block containing the customer's shopping cart.]]></description>
|
||||
<author><![CDATA[PrestaShop]]></author>
|
||||
<tab><![CDATA[front_office_features]]></tab>
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
{*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
{if isset($orderProducts) && count($orderProducts) > 0}
|
||||
<h2>{l s='Customers who bought this product also bought:' mod='blockcart'}</h2>
|
||||
<a id="blockcart_scroll_left" class="blockcart_scroll_left{if count($orderProducts) < 5} hidden{/if}" title="{l s='Previous' mod='crossselling'}" rel="nofollow">{l s='Previous' mod='blockcart'}</a>
|
||||
<div id="blockcart_list">
|
||||
<ul {if count($orderProducts) > 4}style="width: {math equation="width * nbImages" width=58 nbImages=$orderProducts|@count}px"{/if}>
|
||||
{foreach from=$orderProducts item='orderProduct' name=orderProduct}
|
||||
<li>
|
||||
<a href="{$orderProduct.link}" title="{$orderProduct.name|htmlspecialchars}" class="lnk_img"><img src="{$orderProduct.image}" alt="{$orderProduct.name|htmlspecialchars}" /></a>
|
||||
<p class="product_name"><a href="{$orderProduct.link}" title="{$orderProduct.name|htmlspecialchars}">{$orderProduct.name|truncate:15:'...'|escape:'htmlall':'UTF-8'}</a></p>
|
||||
{if $orderProduct.show_price == 1 AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE}
|
||||
<span class="price_display">
|
||||
<span class="price">{convertPrice price=$orderProduct.displayed_price}</span>
|
||||
</span>
|
||||
{else}
|
||||
<br />
|
||||
{/if}
|
||||
<!-- <a title="{l s='View' mod='blockcart'}" href="{$orderProduct.link}" class="button_small">{l s='View' mod='blockcart'}</a><br /> -->
|
||||
</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
<a id="blockcart_scroll_right" class="blockcart_scroll_right{if count($orderProducts) < 5} hidden{/if}" title="{l s='Next' mod='blockcart'}" rel="nofollow">{l s='Next' mod='blockcart'}</a>
|
||||
{/if}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
|
||||
function upgrade_module_1_3($object)
|
||||
{
|
||||
return Configuration::updateValue('PS_BLOCK_CART_XSELL_LIMIT', 12);
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
<module>
|
||||
<name>blocknewproducts</name>
|
||||
<displayName><![CDATA[New products block]]></displayName>
|
||||
<version><![CDATA[1.4]]></version>
|
||||
<version><![CDATA[1.5]]></version>
|
||||
<description><![CDATA[Displays a block featuring your store's newest products.]]></description>
|
||||
<author><![CDATA[PrestaShop]]></author>
|
||||
<tab><![CDATA[front_office_features]]></tab>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<module>
|
||||
<name>homefeatured</name>
|
||||
<displayName><![CDATA[Featured products on the homepage.]]></displayName>
|
||||
<version><![CDATA[1.1]]></version>
|
||||
<version><![CDATA[1.2]]></version>
|
||||
<description><![CDATA[Displays featured products in the middle of your homepage.]]></description>
|
||||
<author><![CDATA[PrestaShop]]></author>
|
||||
<tab><![CDATA[front_office_features]]></tab>
|
||||
|
||||
Reference in New Issue
Block a user