[FIX] website_sale: "Add to Cart" button with inactive variants

When clicking on "Add to Cart" button(a link in fact) with an
inactive variant in the Shop, the button must be disabled.

opw:657967
This commit is contained in:
Goffin Simon
2015-12-02 17:13:05 +01:00
parent 16e4cd15f0
commit 8af539b202
@@ -132,8 +132,10 @@ $('.oe_website_sale').each(function () {
return false;
});
$('.oe_website_sale .a-submit, #comment .a-submit').off('click').on('click', function () {
$(this).closest('form').submit();
$('.oe_website_sale .a-submit, #comment .a-submit').off('click').on('click', function (event) {
if (!event.isDefaultPrevented() && !$(this).is(".disabled")) {
$(this).closest('form').submit();
}
});
$('form.js_attributes input, form.js_attributes select', oe_website_sale).on('change', function () {
$(this).closest("form").submit();
@@ -226,11 +228,11 @@ $('.oe_website_sale').each(function () {
if (product_id) {
$parent.removeClass("css_not_available");
$product_id.val(product_id);
$parent.find(".js_check_product").removeAttr("disabled");
$parent.find("#add_to_cart").removeClass("disabled");
} else {
$parent.addClass("css_not_available");
$product_id.val(0);
$parent.find(".js_check_product").attr("disabled", "disabled");
$parent.find("#add_to_cart").addClass("disabled");
}
});