[FIX] website_sale: quick add in the cart

If the product to quick add in the cart has several variants, the button cart
redirects the user to the page of this product. If "attribute_value_ids" is not
in the DOM when clicking on the button cart, the product is immediately added in
the cart.

Closes #6714

opw:639897
This commit is contained in:
Goffin Simon 2015-05-22 11:33:38 +02:00
parent 04ef9d991b
commit 0ff26cf7cd
2 changed files with 9 additions and 1 deletions

View File

@ -116,7 +116,12 @@
<template id="products_add_to_cart" inherit_id="website_sale.products_item" active="False" customize_show="True" name="Add to Cart">
<xpath expr="//div[@class='product_price']" position="inside">
<input name="product_id" t-att-value="product.product_variant_ids[0].id" type="hidden"/>
<a class="btn btn-default btn-xs fa fa-shopping-cart a-submit"/>
<t t-if="len(product.product_variant_ids) == 1">
<a class="btn btn-default btn-xs fa fa-shopping-cart a-submit"/>
</t>
<t t-if="len(product.product_variant_ids) &gt; 1">
<a class="btn btn-default btn-xs fa fa-shopping-cart" t-att-href="keep('/shop/product/%s' % slug(product), page=(pager['page']['num'] if pager['page']['num']>1 else None))"/>
</t>
</xpath>
</template>

View File

@ -1,4 +1,7 @@
$(document).ready(function () {
if(! $("ul.js_add_cart_variants[data-attribute_value_ids]").length){
return;
}
$('.oe_website_sale #add_to_cart, .oe_website_sale #products_grid .a-submit')
.off('click')
.removeClass('a-submit')