Prestashop v1.6.1.13 default-bootstrap主題。更改屬性的產品增量值
當我在product.js
// The button to increment the product value
$(document).on('click', '.product_quantity_up', function(e){
e.preventDefault();
fieldName = $(this).data('field-qty');
var currentVal = parseInt($('input[name='+fieldName+']').val());
if (!allowBuyWhenOutOfStock && quantityAvailable > 0)
quantityAvailableT = quantityAvailable;
else
quantityAvailableT = 100000000;
if (!isNaN(currentVal) && currentVal < quantityAvailableT)
$('input[name='+fieldName+']').val(currentVal + 1).trigger('keyup');
else
$('input[name='+fieldName+']').val(quantityAvailableT);
$('#quantity_wanted').change();
});
更改此設置:
// The button to increment the product value
$(document).on('click', '.product_quantity_up', function(e){
e.preventDefault();
fieldName = $(this).data('field-qty');
var currentVal = parseInt($('input[name='+fieldName+']').val());
if (!allowBuyWhenOutOfStock && quantityAvailable > 0)
quantityAvailableT = quantityAvailable;
else
quantityAvailableT = 100000000;
if (!isNaN(currentVal) && currentVal < quantityAvailableT)
$('input[name='+fieldName+']').val(currentVal + 2).trigger('keyup'); //this line changed
else
$('input[name='+fieldName+']').val(quantityAvailableT);
$('#quantity_wanted').change();
});
我能2 qauntity輸入改變值高達每一次,當我按下增加按鈕時,但是當我把代碼minimalQuantity
和代碼看起來像這樣:$('input[name='+fieldName+']').val(currentVal + minimalQuantity).trigger('keyup');
這隻適用於產品witout屬性。如果產品具有屬性,這是行不通的,似乎minimalQuantity
沒有屬性的產品給出了正確的值,但對於具有屬性的產品值始終是1.我該如何解決它?
在哪裏宣佈你的** minimalQuantity **變量?你如何定義一個有/沒有屬性的產品? – Mils
在產品的屬性組合是選項爲'minimalQuantity'設置爲低於從product.js主題這個代碼值爲'如果(typeof運算minimalQuantity = '未定義' && minimalQuantity!) \t { \t \t checkMinimalQuantity(); \t \t $(文件)。在( 'KEYUP', '輸入[名稱=數量]',函數(E){ \t \t \t checkMinimalQuantity(minimalQuantity); \t \t}); \t}' –
我仍然困惑,你可以在這裏添加一個jsfiddle或一個片段? – Mils