[IMP] website_sale: optional quantity in product form
This commit is contained in:
parent
1e9c72f308
commit
d8516bcfd8
|
@ -38,8 +38,11 @@ $(document).ready(function () {
|
|||
ev.preventDefault();
|
||||
var $link = $(ev.currentTarget);
|
||||
var $input = $link.parent().parent().find("input");
|
||||
var min = parseFloat($input.data("min") || 0);
|
||||
var max = parseFloat($input.data("max") || Infinity);
|
||||
var quantity = ($link.has(".fa-minus").length ? -1 : 1) + parseFloat($input.val(),10);
|
||||
$input.val(quantity > 0 ? quantity : 0);
|
||||
$input.val(quantity > min ? (quantity < max ? quantity : max) : min);
|
||||
$('input[name="'+$input.attr("name")+'"]').val(quantity > min ? (quantity < max ? quantity : max) : min);
|
||||
$input.change();
|
||||
return false;
|
||||
});
|
||||
|
@ -134,7 +137,7 @@ $(document).ready(function () {
|
|||
event.preventDefault();
|
||||
var $link = $(this);
|
||||
var $form = $link.parents("form:first");
|
||||
var quantity = parseInt($('input[name="add_qty"]').val() || 1, 10);
|
||||
var quantity = parseInt($('input[name="add_qty"]:last').val() || 1, 10);
|
||||
var defs = [];
|
||||
$link.attr('disabled', 'disabled');
|
||||
$('.js_product', $form).each(function () {
|
||||
|
|
|
@ -533,12 +533,14 @@
|
|||
</t>
|
||||
</template>
|
||||
|
||||
<template id="product_confirmation" inherit_id="website_sale.product" optional="enabled" name="Confirm: Add To Cart">
|
||||
<template id="product_confirmation" inherit_id="website_sale.product" optional="disabled" name="Confirm: Add To Cart">
|
||||
<xpath expr="//div[@id='modal_optional_products']" position="attributes">
|
||||
<attribute name="t-if">True</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//t[@t-placeholder='button']" position="replace">
|
||||
<a class="btn btn-primary btn-lg mt8 js_check_product" href="#" data-toggle="modal" data-target="#modal_optional_products">Add to Cart</a>
|
||||
<t t-placeholder="button">
|
||||
<a class="btn btn-primary btn-lg mt8 js_check_product" href="#" data-toggle="modal" data-target="#modal_optional_products">Add to Cart</a>
|
||||
</t>
|
||||
</xpath>
|
||||
<xpath expr="//t[@t-set='option_inc'][@t-value='0']" position="before">
|
||||
<tr>
|
||||
|
@ -572,7 +574,7 @@
|
|||
<i class="fa fa-minus"></i>
|
||||
</a>
|
||||
</span>
|
||||
<input type="text" class="js_quantity form-control" name="add_qty" value="1"/>
|
||||
<input type="text" class="js_quantity form-control" data-min="1" name="add_qty" value="1"/>
|
||||
<span class="input-group-addon">
|
||||
<a t-attf-href="#" class="mb8 float_left js_add_cart_json">
|
||||
<i class="fa fa-plus"></i>
|
||||
|
@ -584,6 +586,24 @@
|
|||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="product_quantity" inherit_id="website_sale.product" optional="enabled" name="Select Quantity">
|
||||
<xpath expr="//t[@t-placeholder='button']" position="before">
|
||||
<div class="input-group" style="width: 108px;">
|
||||
<span class="input-group-addon">
|
||||
<a t-attf-href="#" class="mb8 js_add_cart_json">
|
||||
<i class="fa fa-minus"></i>
|
||||
</a>
|
||||
</span>
|
||||
<input type="text" class="js_quantity form-control" data-min="1" name="add_qty" value="1"/>
|
||||
<span class="input-group-addon">
|
||||
<a t-attf-href="#" class="mb8 float_left js_add_cart_json">
|
||||
<i class="fa fa-plus"></i>
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="product_price">
|
||||
<div itemprop="offers" itemscope="itemscope" itemtype="http://schema.org/Offer" class="product_price mt16">
|
||||
<h4 class="oe_price_h4">
|
||||
|
|
Loading…
Reference in New Issue