问题:我想在magento中将产品添加到购物车之前增加数量,以下代码适用于除IE9之外的所有浏览器。我不是开发人员,因此我寻求帮助。
预期:在IE9中将产品添加到购物车之前,允许添加数量。
调试时出错:“AmQtyObj.increment()”错误'AmQtyObj'未定义。
//增加产品数量的类
AmQty = Class.create();
AmQty.prototype =
{
initialize : function(min) {
this.min = min;
this.input = $('am-input');
},
increment: function() {
this.input.value++;
this.paint();
},
decrement: function() {
if(this.input.value > this.min) {
this.input.value--;
this.paint();
}
},
update: function() {
postData = "update_cart_action=update_qty&" + this.input.name + '=' + this.input.value;
new Ajax.Request(AmAjaxObj.updateUrl, {
method: 'post',
postBody : postData,
onCreate: function()
{
AmAjaxObj.showAnimation();
}.bind(this),
onComplete: function()
{
AmAjaxObj.hideAnimation();
}.bind(this),
onSuccess: function(transport) {
var url = AmAjaxObj.url.replace(AmAjaxObj.url.substring(AmAjaxObj.url.length-6, AmAjaxObj.url.length), 'data');// replace ajax to count
new Ajax.Request(url, {
method: 'post',
onSuccess: function(transport) {
if (transport.responseText.isJSON()) {
var response = transport.responseText.evalJSON();
if($('amcart-count') && response.count) $('amcart-count').innerHTML = response.count;
var price = $$('#messageBox span.am_price')[0];
if(price && response.price) price.innerHTML = response.price;
}
}.bind(this),
onComplete: function() {
AmAjaxObj.updateLinc(" (" + $$('#amcart-count a')[0].text + ")");
}
});
AmAjaxObj.updateCart();
AmAjaxObj.hideAnimation();
new Effect.Highlight(this.input, { startcolor: '#ffff99', endcolor: '#a4e9ac', restorecolor : '#a4e9ac'});
$('am-qty-button-update').hide();
this.input.removeClassName('focus');
}.bind(this),
onFailure: function()
{
AmAjaxObj.hideAnimation();
}.bind(this)
});
},
paint: function() {
new Effect.Highlight('am-input', { endcolor: '#ffff99', restorecolor : '#ffff99'});
$('am-input').addClassName('focus');
$('am-qty-button-update').show();
this.clearTimer();
},
clearTimer: function() {
jQuery(function($) {
var elem= $('#confirmButtons .button:last-child');
var value = elem.text();
var sec = parseInt(value.replace(/\D+/g,""));
if(sec) {
value = value.replace('(' + sec + ')', '');
elem.text(value);
clearInterval(document.timer);
}
});
}
}