Merge branch 'ticket/r12779-lightbox-qty' into develop
This commit is contained in:
commit
2cca3ea857
@ -21,7 +21,7 @@ class CartController extends CartControllerCore
|
|||||||
$qty_to_check = $this->qty;
|
$qty_to_check = $this->qty;
|
||||||
$cart_products = $this->context->cart->getProducts();
|
$cart_products = $this->context->cart->getProducts();
|
||||||
|
|
||||||
if (is_array($cart_products))
|
if (is_array($cart_products) && !Tools::getIsset('fromLightbox'))
|
||||||
foreach ($cart_products as $cart_product)
|
foreach ($cart_products as $cart_product)
|
||||||
{
|
{
|
||||||
if ((!isset($this->id_product_attribute) || $cart_product['id_product_attribute'] == $this->id_product_attribute) &&
|
if ((!isset($this->id_product_attribute) || $cart_product['id_product_attribute'] == $this->id_product_attribute) &&
|
||||||
@ -54,8 +54,9 @@ class CartController extends CartControllerCore
|
|||||||
elseif (!Product::isAvailableWhenOutOfStock($product->out_of_stock) && !Attribute::checkAttributeQty($this->id_product_attribute, $qty_to_check))
|
elseif (!Product::isAvailableWhenOutOfStock($product->out_of_stock) && !Attribute::checkAttributeQty($this->id_product_attribute, $qty_to_check))
|
||||||
$this->errors[] = Tools::displayError('There isn\'t enough product in stock.', !Tools::getValue('ajax'));
|
$this->errors[] = Tools::displayError('There isn\'t enough product in stock.', !Tools::getValue('ajax'));
|
||||||
}
|
}
|
||||||
elseif (!$product->checkQty($qty_to_check))
|
elseif (!$product->checkQty($qty_to_check)) {
|
||||||
$this->errors[] = Tools::displayError('There isn\'t enough product in stock.', !Tools::getValue('ajax'));
|
$this->errors[] = Tools::displayError('There isn\'t enough product in stock.', !Tools::getValue('ajax'));
|
||||||
|
}
|
||||||
|
|
||||||
// If no errors, process product addition
|
// If no errors, process product addition
|
||||||
if (!$this->errors && $mode == 'add')
|
if (!$this->errors && $mode == 'add')
|
||||||
|
@ -4616,12 +4616,20 @@ main#categorycms { margin-bottom: 30px }
|
|||||||
background: #fff;
|
background: #fff;
|
||||||
border-left: 1px solid #f0f0f0;
|
border-left: 1px solid #f0f0f0;
|
||||||
border-right: 1px solid #f0f0f0;
|
border-right: 1px solid #f0f0f0;
|
||||||
float: left;
|
float: left;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
padding-top: 5px;
|
padding-top: 5px;
|
||||||
width: 40px;
|
width: 40px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
.layer_cart_product .message {
|
||||||
|
color: #6ac5bb;
|
||||||
|
display: block;
|
||||||
|
float: left;
|
||||||
|
font-size: 12px;
|
||||||
|
padding: 8px 0 0 10px;
|
||||||
|
}
|
||||||
|
.layer_cart_product .message.error { color: #e4535d }
|
||||||
|
|
||||||
#layer_cart .layer_cart_product .product-infos .prices,
|
#layer_cart .layer_cart_product .product-infos .prices,
|
||||||
#layer_cart_pack .layer_cart_product .product-infos .prices {
|
#layer_cart_pack .layer_cart_product .product-infos .prices {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
|
|
||||||
|
|
||||||
ajaxCart.overrideButtonsInThePage();
|
ajaxCart.overrideButtonsInThePage();
|
||||||
|
|
||||||
$(document).on('click', '.block_cart_collapse', function(e){
|
$(document).on('click', '.block_cart_collapse', function(e){
|
||||||
@ -72,6 +71,20 @@ $(document).ready(function(){
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('#columns #layer_cart, #columns .layer_cart_overlay').detach().prependTo('#columns');
|
$('#columns #layer_cart, #columns .layer_cart_overlay').detach().prependTo('#columns');
|
||||||
|
|
||||||
|
$('.update-qty .qty-up').on('click', function() {
|
||||||
|
qty = parseInt($('.layer_cart_product .nb_quantity').html()) + 1;
|
||||||
|
idProduct = $(".layer_cart_product .product-id").val();
|
||||||
|
|
||||||
|
ajaxCart.updateQty(qty, idProduct, null);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.update-qty .qty-down').on('click', function() {
|
||||||
|
qty = parseInt($('.product-infos .nb_quantity').html()) - 1;
|
||||||
|
idProduct = idProduct = $(".layer_cart_product .product-id").val();
|
||||||
|
|
||||||
|
ajaxCart.updateQty(qty, idProduct, null);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -270,22 +283,6 @@ var ajaxCart = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
lightboxQty: function() {
|
|
||||||
$('.update-qty .qty-up').on('click', function() {
|
|
||||||
qty = parseInt($('.layer_cart_product .nb_quantity').html()) + 1;
|
|
||||||
idProduct = $(".layer_cart_product .product-id").val();
|
|
||||||
|
|
||||||
ajaxCart.updateQty(qty, idProduct, null);
|
|
||||||
});
|
|
||||||
|
|
||||||
$('.update-qty .qty-down').on('click', function() {
|
|
||||||
qty = parseInt($('.product-infos .nb_quantity').html()) - 1;
|
|
||||||
idProduct = idProduct = $(".layer_cart_product .product-id").val();
|
|
||||||
|
|
||||||
ajaxCart.updateQty(qty, idProduct, null);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
updateQty: function(quantity, idProduct, idCombination) {
|
updateQty: function(quantity, idProduct, idCombination) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
@ -294,11 +291,17 @@ var ajaxCart = {
|
|||||||
async: true,
|
async: true,
|
||||||
cache: false,
|
cache: false,
|
||||||
dataType : "json",
|
dataType : "json",
|
||||||
data: 'controller=cart&add=1&fromLightbox=true&ajax=true&qty=' + ((quantity && quantity != null) ? quantity : '1') + '&id_product=' + idProduct + '&token=' + static_token + ( (parseInt(idCombination) && idCombination != null) ? '&ipa=' + parseInt(idCombination): ''),
|
data: 'controller=cart&add=1&fromLightbox=true&ajax=true&qty=' + quantity + '&id_product=' + idProduct + '&token=' + static_token + ( (parseInt(idCombination) && idCombination != null) ? '&ipa=' + parseInt(idCombination): ''),
|
||||||
success: function(jsonData,textStatus,jqXHR) {
|
success: function(jsonData,textStatus,jqXHR) {
|
||||||
if (!jsonData.hasError) {
|
if (!jsonData.hasError) {
|
||||||
ajaxCart.updateCart(jsonData);
|
ajaxCart.updateCart(jsonData);
|
||||||
$('.layer_cart_product .nb_quantity').html(quantity);
|
$('.layer_cart_product .nb_quantity').html(quantity);
|
||||||
|
|
||||||
|
$('.message.error').hide();
|
||||||
|
$('.message.success').html('Quantité mise à jour avec succés').show();
|
||||||
|
} else {
|
||||||
|
$('.message.success').hide();
|
||||||
|
$('.message.error').html(jsonData.errors[0]).show();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function(XMLHttpRequest, textStatus, errorThrown)
|
error: function(XMLHttpRequest, textStatus, errorThrown)
|
||||||
@ -819,8 +822,6 @@ var ajaxCart = {
|
|||||||
$('#layer_cart').addClass('open');
|
$('#layer_cart').addClass('open');
|
||||||
$('#layer_cart .panel-overlay').addClass('open');
|
$('#layer_cart .panel-overlay').addClass('open');
|
||||||
$('.layer_cart_overlay').fadeIn();
|
$('.layer_cart_overlay').fadeIn();
|
||||||
|
|
||||||
ajaxCart.lightboxQty();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
|
@ -14,10 +14,12 @@
|
|||||||
<p class="product-name"></p>
|
<p class="product-name"></p>
|
||||||
<p class="product-attributes">
|
<p class="product-attributes">
|
||||||
{l s='Quantité dans votre panier' mod='blockcart'}
|
{l s='Quantité dans votre panier' mod='blockcart'}
|
||||||
<span style="padding-left: 20px" class="update-qty clearfix">
|
<span class="update-qty clearfix">
|
||||||
<span class="qty-down">-</span>
|
<span class="qty-down">-</span>
|
||||||
<span class="nb_quantity"></span>
|
<span class="nb_quantity"></span>
|
||||||
<span class="qty-up">+</span>
|
<span class="qty-up">+</span>
|
||||||
|
<span class="message success"></span>
|
||||||
|
<span class="message error"></span>
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<div class="prices">
|
<div class="prices">
|
||||||
|
Loading…
Reference in New Issue
Block a user