我是 opencart 的新手。我需要帮助来解决与 Opencart 产品页面上的“选项必需警报”相关的问题。
如果客户错过从产品页面选择任何所需选项,我希望出现一个 JavaScript 警告框。
请帮我解决这个问题!
最佳答案
Opencart 1.5.6.3
Replace this line in htdocs\opencart1563\catalog\view\theme\default\template\product\product.tpl line no 394 approx.
if (json['error']) {
if (json['error']['option']) {
for (i in json['error']['option']) {
$('#option-' + i).after('<span class="error">' + json['error']['option'][i] + '</span>');
}
}
if (json['error']['profile'])
{$('select[name="profile_id"]').after('<span class="error">' + json['error']['profile'] + '</span>'); }
}
With
if (json['error']) {
if (json['error']['option']) {
var abc = ' ';
for (i in json['error']['option']) {
$('#option-' + i).after('<span class="error">' + json['error']['option'][i] + '</span>');
abc += ' ' + json['error']['option'][i] + ' ';
}
alert('->' + abc + '<-');
}
if (json['error']['profile'])
{$('select[name="profile_id"]').after('<span class="error">' + json['error']['profile'] + '</span>'); }
}
Opencart 2.0
Replace this line in htdocs\opencart2\catalog\view\theme\default\template\product\product.tpl line no 460 apprx.
if (json['error']) {
if (json['error']['option']) {
for (i in json['error']['option']) {
var element = $('#input-option' + i.replace('_', '-'));
if (element.parent().hasClass('input-group')) {
element.parent().after('<div clas="text-danger">' + json['error']['option'][i] + '</div>');
} else {
element.after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
}
}
}
With
if (json['error']) {
if (json['error']['option']) {
var abc = ' ';
for (i in json['error']['option']) {
var element = $('#input-option' + i.replace('_', '-'));
if (element.parent().hasClass('input-group')) {
element.parent().after('<div clas="text-danger">' + json['error']['option'][i] + '</div>');
abc += ' ' + json['error']['option'][i] + ' ';
} else {
element.after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
abc += ' ' + json['error']['option'][i] + ' ';
}
}
alert('->' + abc + '<-');
}
询问您是否需要其他功能。或者你不明白
关于javascript - Opencart Javascript 弹出必需选项警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29338194/