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;
|
||||
$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)
|
||||
{
|
||||
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))
|
||||
$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'));
|
||||
}
|
||||
|
||||
// If no errors, process product addition
|
||||
if (!$this->errors && $mode == 'add')
|
||||
|
@ -4622,6 +4622,14 @@ main#categorycms { margin-bottom: 30px }
|
||||
width: 40px;
|
||||
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_pack .layer_cart_product .product-infos .prices {
|
||||
|
@ -1,6 +1,5 @@
|
||||
$(document).ready(function(){
|
||||
|
||||
|
||||
ajaxCart.overrideButtonsInThePage();
|
||||
|
||||
$(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');
|
||||
|
||||
$('.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) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
@ -294,11 +291,17 @@ var ajaxCart = {
|
||||
async: true,
|
||||
cache: false,
|
||||
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) {
|
||||
if (!jsonData.hasError) {
|
||||
ajaxCart.updateCart(jsonData);
|
||||
$('.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)
|
||||
@ -819,8 +822,6 @@ var ajaxCart = {
|
||||
$('#layer_cart').addClass('open');
|
||||
$('#layer_cart .panel-overlay').addClass('open');
|
||||
$('.layer_cart_overlay').fadeIn();
|
||||
|
||||
ajaxCart.lightboxQty();
|
||||
}
|
||||
} else {
|
||||
window.location.reload();
|
||||
|
@ -14,10 +14,12 @@
|
||||
<p class="product-name"></p>
|
||||
<p class="product-attributes">
|
||||
{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="nb_quantity"></span>
|
||||
<span class="qty-up">+</span>
|
||||
<span class="message success"></span>
|
||||
<span class="message error"></span>
|
||||
</span>
|
||||
</p>
|
||||
<div class="prices">
|
||||
|
Loading…
Reference in New Issue
Block a user