There is an issue where if an item has 150 pcs left at the warehouse,you can still order 200 or more pieces through the online store. Can we make it so that people cannot add more pieces to their cart than what is actually available at the warehouse?
solution:
The solution to this issue is by setting the max value for the input field.The max value should be equal to the quantity available. So if the input value is greater than quantity available, then the input field is disabled.
code:
javascript code:
define(
'JJ.limitpurchase.customer'
, [
'JJ.limitpurchase.customer.View','ProductDetails.Quantity.View','Cart.Item.Summary.View','Product.Model','Cart.Lines.View','LiveOrder.Model'
]
, function (
customerView,ProductDetailsQuantityView,CartItemSummaryView,ProductModel,CartLInesView,LiveOrderModel
)
{
'use strict';
var maxquanty;
return {
mountToApp: function mountToApp (container)
{
var layout = container.getComponent('Layout');
var pdp = container.getComponent('PDP');
_.extend(ProductDetailsQuantityView.prototype, {
getContext: _.wrap(ProductDetailsQuantityView.prototype.getContext, function (fn) {
var context = fn.apply(this, _.toArray(arguments).slice(1));
try {
maxquanty=context.model.attributes.item.attributes.quantityavailable;
context.quantityvalue=maxquanty;
}catch(e){
console.log(e);
}
return context
})
});
}
};
});
template
