From d8e67d647f6779984c241b71728904d223d09415 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Mon, 29 Sep 2014 16:12:57 +0200 Subject: [PATCH] [FIX] website_sale_options: only one optional product is added to the cart and the quantity of the optional product don't change in the cart when we click on more or less. Fix the number of items displayed in the modal options. --- addons/website_sale/static/src/js/website_sale.js | 4 ++-- .../static/src/js/website_sale.js | 13 +++++++++++-- addons/website_sale_options/views/templates.xml | 1 + 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/addons/website_sale/static/src/js/website_sale.js b/addons/website_sale/static/src/js/website_sale.js index 34cf1fce863..dda494aac7e 100644 --- a/addons/website_sale/static/src/js/website_sale.js +++ b/addons/website_sale/static/src/js/website_sale.js @@ -95,7 +95,7 @@ $('.oe_website_sale').each(function () { $parent.find(".oe_default_price:first .oe_currency_value").html( price_to_str(+$(this).data('lst_price')) ); $parent.find(".oe_price:first .oe_currency_value").html(price_to_str(+$(this).data('price')) ); - var $img = $(this).closest('tr.js_product, .oe_website_sale').find('span[data-oe-model^="product."][data-oe-type="image"] img, img.product_detail_img'); + var $img = $(this).closest('tr.js_product, .oe_website_sale').find('span[data-oe-model^="product."][data-oe-type="image"] img:first, img.product_detail_img'); $img.attr("src", "/website/image/product.product/" + $(this).val() + "/image"); }); @@ -129,7 +129,7 @@ $('.oe_website_sale').each(function () { } if (product_id) { - var $img = $(this).closest('tr.js_product, .oe_website_sale').find('span[data-oe-model^="product."][data-oe-type="image"] img, img.product_detail_img'); + var $img = $(this).closest('tr.js_product, .oe_website_sale').find('span[data-oe-model^="product."][data-oe-type="image"] img:first, img.product_detail_img'); $img.attr("src", "/website/image/product.product/" + product_id + "/image"); $img.parent().attr('data-oe-model', 'product.product').attr('data-oe-id', product_id) .data('oe-model', 'product.product').data('oe-id', product_id); diff --git a/addons/website_sale_options/static/src/js/website_sale.js b/addons/website_sale_options/static/src/js/website_sale.js index 72a45139b83..3d8ecee4ebb 100644 --- a/addons/website_sale_options/static/src/js/website_sale.js +++ b/addons/website_sale_options/static/src/js/website_sale.js @@ -53,7 +53,7 @@ $(document).ready(function () { $(".js_remove .js_items").addClass("hidden"); $(".js_remove .js_item").removeClass("hidden"); } else { - $(".js_remove .js_items").removeClass("hidden").text($(".js_remove .js_items").text().replace(/[0-9.,]+/, qty)); + $(".js_remove .js_items").removeClass("hidden").text($(".js_remove .js_items:first").text().replace(/[0-9.,]+/, qty)); $(".js_remove .js_item").addClass("hidden"); } }); @@ -65,5 +65,14 @@ $(document).ready(function () { }); return false; }); - + + + $('#cart_products input.js_quantity').change(function () { + var value = $(this).val(); + var $next = $(this).closest('tr').next('.optional_product'); + while($next.length) { + $next.find('.js_quantity').text(value); + $next = $next.next('.optional_product'); + } + }); }); diff --git a/addons/website_sale_options/views/templates.xml b/addons/website_sale_options/views/templates.xml index 1f0a4303e61..2963666cc8c 100644 --- a/addons/website_sale_options/views/templates.xml +++ b/addons/website_sale_options/views/templates.xml @@ -131,6 +131,7 @@ Remove from cart +