diff --git a/modules/cms_pack/controllers/admin/AdminCmsPackController.php b/modules/cms_pack/controllers/admin/AdminCmsPackController.php index 179a9d1b..41861641 100644 --- a/modules/cms_pack/controllers/admin/AdminCmsPackController.php +++ b/modules/cms_pack/controllers/admin/AdminCmsPackController.php @@ -111,8 +111,10 @@ class AdminCmsPackController extends ModuleAdminController public function getPercentageReduction() { - if (Validate::isLoadedObject($obj = $this->loadObject())) { - return $obj->getPercentageReduction(); + if(Tools::getIsset('id_pack')) { + if (Validate::isLoadedObject($obj = $this->loadObject())) { + return $obj->getPercentageReduction(); + } } } diff --git a/modules/cms_pack/pack.js b/modules/cms_pack/pack.js index ed82253d..06ff5820 100644 --- a/modules/cms_pack/pack.js +++ b/modules/cms_pack/pack.js @@ -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 = ""; diff --git a/modules/cms_pack/views/templates/hook/pack_bottom.tpl b/modules/cms_pack/views/templates/hook/pack_bottom.tpl index 78147a9b..3655e8e9 100644 --- a/modules/cms_pack/views/templates/hook/pack_bottom.tpl +++ b/modules/cms_pack/views/templates/hook/pack_bottom.tpl @@ -24,7 +24,7 @@
- - + +
@@ -92,6 +92,7 @@ } } $(input).val(new_value); + updateInfo(".checkbox_add_bottom", ".pack_bottom"); }); }); diff --git a/modules/cms_pack/views/templates/hook/pack_left.tpl b/modules/cms_pack/views/templates/hook/pack_left.tpl index def1d24a..20a79148 100644 --- a/modules/cms_pack/views/templates/hook/pack_left.tpl +++ b/modules/cms_pack/views/templates/hook/pack_left.tpl @@ -19,7 +19,7 @@

{$product->name}

- +
x {displayPrice price=$product->price}