Opencart如果产品可用按钮show else禁用该按钮
嗨,我正在使用Opencart创建一个应用程序。这是完全定制的,我对此表示怀疑Opencart如果产品可用按钮show else禁用该按钮,opencart,product,Opencart,Product,嗨,我正在使用Opencart创建一个应用程序。这是完全定制的,我对此表示怀疑 我有filter.tpl页面,在此页面中,我需要根据产品可用性显示和隐藏按钮 如: 如果有这样的产品展示 其他按钮显示像这样 我正在使用ajax filter.tpl $('input[name=\'filter_name\']').autocomplete({ 'source': function(request, response) { $.ajax({ url: 'index.php?
ajax
filter.tpl
$('input[name=\'filter_name\']').autocomplete({
'source': function(request, response) {
$.ajax({
url: 'index.php?route=catalog/product/getProductCheck' + encodeURIComponent(request),
dataType: 'json',
success: function(json) {
response($.map(json, function(item) {
return {
label: item['name'],
value: item['product_id']
}
}));
}
});
},
'select': function(item) {
$('input[name=\'filter_name\']').val(item['label']);
}
}))
内部控制器
product.php
public function getProductCheck()
{
/*Some code here*/
}
因此,您可以使用
if($product['quantity'])
语句,例如我使用javascript
以下代码
<div class="form-group">
<div style='display:none;' id='instock'>
<a class='instock-btn'>Product / Solution Available</a>
<input type='submit' class='btn-orng available' name='' value="Click here for more details" size='20' />
</div>
<div style='display:none;' id="outstock">
<input type='submit' class='outstock-btn' name='' value="Product / Solution Not Available" size='20' />
<input type='submit' class='btn-orng' name='' value="We will contact you at the earliest" size='20' />
</div>
</div>
产品/解决方案可用
脚本
$(document).ready(function(){
$('#dia1').on('change', function() {
//var value =
if (this.value <='320' )
{
$("#instock").show();
$("#outstock").hide();
}
else
{
$("#instock").hide();
$("#outstock").show();
}
});
$('#len1').on('change', function() {
//var value =
if (this.value <='310' )
{
$("#instock").show();
$("#outstock").hide();
}
else
{
$("#instock").hide();
$("#outstock").show();
}
});
});
$(文档).ready(函数(){
$('#dia1')。on('change',function(){
//var值=
例如,如果(this.value,您可以使用if($product['quantity'])语句,您是正确的Alex。谢谢您的replaynice:),那么我可以将注释作为答案发布在模板中,您可以在模板中看到每个($products)语句