From b3e3904098c81fbfa0b99ca9fb92bc037de8763f Mon Sep 17 00:00:00 2001 From: mDeflotte Date: Mon, 18 Jun 2012 13:32:51 +0000 Subject: [PATCH] [-] FO : #PSCFV-2840 - Fix bug with typewatch on the opc (qty change) and multishipping --- themes/default/js/cart-summary.js | 17 +++++++++++------ themes/default/js/order-opc.js | 2 ++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/themes/default/js/cart-summary.js b/themes/default/js/cart-summary.js index 463e9460a..77fd51ae1 100644 --- a/themes/default/js/cart-summary.js +++ b/themes/default/js/cart-summary.js @@ -32,7 +32,7 @@ $(document).ready(function() $('.cart_quantity_up').unbind('click').live('click', function(){ upQuantity($(this).attr('id').replace('cart_quantity_up_', '')); return false; }); $('.cart_quantity_down').unbind('click').live('click', function(){ downQuantity($(this).attr('id').replace('cart_quantity_down_', '')); return false; }); $('.cart_quantity_delete' ).unbind('click').live('click', function(){ deleteProductFromSummary($(this).attr('id')); return false; }); - $('.cart_quantity_input').typeWatch({ highlight: true, wait: 600, captureLength: 0, callback: updateQty }); + $('.cart_quantity_input').typeWatch({ highlight: true, wait: 600, captureLength: 0, callback: function(val) { updateQty(val, true, this.el) } }); } $('.cart_address_delivery').live('change', function(){ changeAddressDelivery($(this)); }); @@ -224,15 +224,20 @@ function updateAddressId(id_product, id_product_attribute, old_id_address_delive .attr('id', 'select_address_delivery_' + id_product+'_' + id_product_attribute + '_' + id_address_delivery); } -function updateQty(val) +function updateQty(val, cart, el) { - var id = $(this.el).attr('name'); + if (typeof(cart) == 'undefined' || cart) + var prefix = '#order-detail-content '; + else + var prefix = '#fancybox-content '; + + var id = $(el).attr('name'); var exp = new RegExp("^[0-9]+$"); if (exp.test(val) == true) { - var hidden = $('input[name='+ id +'_hidden]').val(); - var input = $('input[name='+ id +']').val(); + var hidden = $(prefix+'input[name='+ id +'_hidden]').val(); + var input = $(prefix+'input[name='+ id +']').val(); var QtyToUp = parseInt(input) - parseInt(hidden); if (parseInt(QtyToUp) > 0) @@ -241,7 +246,7 @@ function updateQty(val) downQuantity(id.replace('quantity_', ''), QtyToUp); } else - $('input[name='+ id +']').val($('input[name='+ id +'_hidden]').val()); + $(prefix+'input[name='+ id +']').val($(prefix+'input[name='+ id +'_hidden]').val()); if (typeof(getCarrierListAndUpdate) != 'undefined') getCarrierListAndUpdate(); diff --git a/themes/default/js/order-opc.js b/themes/default/js/order-opc.js index c96e94207..738d316bd 100644 --- a/themes/default/js/order-opc.js +++ b/themes/default/js/order-opc.js @@ -742,6 +742,7 @@ function multishippingMode(it) cache: false, success: function(data) { $('#cart_summary').replaceWith($(data).find('#cart_summary')); + $('.cart_quantity_input').typeWatch({ highlight: true, wait: 600, captureLength: 0, callback: function(val) { updateQty(val, true, this.el) } }); } }); updateCarrierSelectionAndGift(); @@ -756,6 +757,7 @@ function multishippingMode(it) }, 'onComplete': function() { + $('#fancybox-content .cart_quantity_input').typeWatch({ highlight: true, wait: 600, captureLength: 0, callback: function(val) { updateQty(val, false, this.el)} }); cleanSelectAddressDelivery(); $('#fancybox-content').append($('
' + CloseTxt + '
')); $('#multishipping-close').click(function() {