add update price on realtime
This commit is contained in:
parent
07181377ae
commit
4f432d9c65
@ -111,10 +111,12 @@ class AdminCmsPackController extends ModuleAdminController
|
||||
|
||||
public function getPercentageReduction()
|
||||
{
|
||||
if(Tools::getIsset('id_pack')) {
|
||||
if (Validate::isLoadedObject($obj = $this->loadObject())) {
|
||||
return $obj->getPercentageReduction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function processSave() {
|
||||
parent::processSave();
|
||||
|
@ -7,6 +7,24 @@ $(document).ready(function() {
|
||||
addCmsPackToCart(".checkbox_add_bottom", ".pack_bottom");
|
||||
});
|
||||
|
||||
updateInfo(".checkbox_add_right", ".pack_left");
|
||||
$('.checkbox_add_right').on('click', function(e) {
|
||||
updateInfo(".checkbox_add_right", ".pack_left");
|
||||
});
|
||||
$('.quantity_right').on('focusout', function(e) {
|
||||
updateInfo(".checkbox_add_right", ".pack_left");
|
||||
});
|
||||
|
||||
|
||||
updateInfo(".checkbox_add_bottom", ".pack_bottom");
|
||||
$('.checkbox_add_bottom').on('click', function(e) {
|
||||
updateInfo(".checkbox_add_bottom", ".pack_bottom");
|
||||
});
|
||||
$('.quantity_bottom').on('focusout', function(e) {
|
||||
updateInfo(".checkbox_add_bottom", ".pack_bottom");
|
||||
});
|
||||
|
||||
|
||||
$('#layer_cart_pack .cross, .layer_cart_overlay_pack, #layer_cart_pack .continue.link').on('click',function(){
|
||||
if($('#layer_cart_pack').hasClass('open') == true)
|
||||
$('#layer_cart_pack').removeClass('open');
|
||||
@ -15,6 +33,20 @@ $(document).ready(function() {
|
||||
|
||||
});
|
||||
|
||||
|
||||
function updateInfo(checkboxes, pack) {
|
||||
var total = 0;
|
||||
$(checkboxes).each(function( index ) {
|
||||
if ($(this).is(':checked')) {
|
||||
var idProduct = $(this).attr('name');
|
||||
var quantity = $(pack+' input[name="quantity_'+idProduct+'"]').val();
|
||||
var price = $(pack+' input[name="quantity_'+idProduct+'"]').data('product-price-nf');
|
||||
total += (parseFloat(quantity)*parseFloat(price));
|
||||
}
|
||||
});
|
||||
$(pack).find('.price_info').children('.price').html(parseFloat(total).toFixed(2) + " €");
|
||||
}
|
||||
|
||||
function addCmsPackToCart(checkboxes, pack) {
|
||||
var addProducts = [];
|
||||
var html = "";
|
||||
|
@ -24,7 +24,7 @@
|
||||
<div class="col-md-2 col-sm-3 col-xs-4">
|
||||
<div class="quantity quantity_box">
|
||||
<span class="change_quantity" data-action="down">-</span>
|
||||
<input type="text" value="1" size="3" data-product-id="{$product->id}" data-product-price="{displayPrice price=$product->price}" data-product-name="{$product->name}" data-product-img="{$link->getImageLink($product->link_rewrite, $id_image.id_image, 'cart_default')|escape:'html':'UTF-8'}" name="quantity_{$product->id}" name="quantity_{$product->id}" class="product_add_{$product->id} quantity_bottom">
|
||||
<input type="text" value="1" size="3" data-product-id="{$product->id}" data-product-price="{displayPrice price=$product->price}" data-product-price-nf="{$product->price}" data-product-name="{$product->name}" data-product-img="{$link->getImageLink($product->link_rewrite, $id_image.id_image, 'cart_default')|escape:'html':'UTF-8'}" name="quantity_{$product->id}" name="quantity_{$product->id}" class="product_add_{$product->id} quantity_bottom">
|
||||
<span class="change_quantity" data-action="up">+</span>
|
||||
</div>
|
||||
</div>
|
||||
@ -92,6 +92,7 @@
|
||||
}
|
||||
}
|
||||
$(input).val(new_value);
|
||||
updateInfo(".checkbox_add_bottom", ".pack_bottom");
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
@ -19,7 +19,7 @@
|
||||
<p class="name">{$product->name}</p>
|
||||
<div class="price">
|
||||
<div class="quantity">
|
||||
<input type="text" value="1" size="3" data-product-id="{$product->id}" data-product-price="{displayPrice price=$product->price}" data-product-name="{$product->name}" data-product-img="{$link->getImageLink($product->link_rewrite, $id_image.id_image, 'cart_default')|escape:'html':'UTF-8'}" name="quantity_{$product->id}" class="product_add_{$product->id} quantity_right">
|
||||
<input type="text" value="1" size="3" data-product-id="{$product->id}" data-product-price="{displayPrice price=$product->price}" data-product-price-nf="{$product->price}" data-product-name="{$product->name}" data-product-img="{$link->getImageLink($product->link_rewrite, $id_image.id_image, 'cart_default')|escape:'html':'UTF-8'}" name="quantity_{$product->id}" class="product_add_{$product->id} quantity_right">
|
||||
</div>
|
||||
<span> <span class="min">x</span> {displayPrice price=$product->price}</span>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user