Skip to content

Commit

Permalink
[FIX] website_sale: Prevent updation of cart qty in edit mode
Browse files Browse the repository at this point in the history
Because of the mechanism to bind change / click event in current implementation,
when we are in edit mode of a product page, respected events are triggered on
change of cart qty input (responsible class : js_quantity) or on click of
+ / - buttons (responsible class : js_add_cart_json). And this is responsible
of triggering further events (calling update_product_image method, which
causes this issue).

After this commit, click / change event while updating cart qty will not be
effective in edit mode, preventing further unwanted events being triggered.

Related Task : 1825889
PR : #24211
  • Loading branch information
dharmrajsinh-jhala committed Aug 24, 2018
1 parent 81f975d commit 23f77ba
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions addons/website_sale/static/src/js/website_sale.js
Expand Up @@ -107,7 +107,7 @@ $('.oe_website_sale').each(function () {
var product_ids = [];
var product_dom = $(".js_product .js_add_cart_variants[data-attribute_value_ids]");
var qty = $(event.target).closest('form').find('input[name="add_qty"]').val();
if (!product_dom.length) {
if (!product_dom.length || $('body').hasClass('editor_enable')) {
return;
}
_.each(product_dom, function(prod) {
Expand Down Expand Up @@ -149,7 +149,7 @@ $('.oe_website_sale').each(function () {

$(oe_website_sale).on("change", ".oe_cart input.js_quantity[data-product-id]", function () {
var $input = $(this);
if ($input.data('update_change')) {
if ($input.data('update_change') || $('body').hasClass('editor_enable')) {
return;
}
var value = parseInt($input.val() || 0, 10);
Expand Down Expand Up @@ -219,8 +219,11 @@ $('.oe_website_sale').each(function () {
});


// hack to add and rome from cart with json
// hack to add / remove from cart with json
$(oe_website_sale).on('click', 'a.js_add_cart_json', function (ev) {
if ($('body').hasClass('editor_enable')) {
return;
}
ev.preventDefault();
var $link = $(ev.currentTarget);
var $input = $link.parent().find("input");
Expand Down

0 comments on commit 23f77ba

Please sign in to comment.