javascript - "Add to cart" button doesn't work because of ReferenceError -
i have "add cart" button in magento theme, haven't edited stopped working. defenitely worked time ago , unfortunately didn't catch moment when things went wrong. when i'm pressing button nothing happens in frontend , see error "uncaught referenceerror: productaddtocartform not defined" in console.
here button html:
<button class="button btn-cart" title="Добавить в корзину" type="button" onclick="productaddtocartform.submit(this)"><i class="icon-basket"></i>Добавить в корзину</button>
however, when @ page source, script in page:
<script type="text/javascript"> //<![cdata[ var productaddtocartform = new varienform('product_addtocart_form'); <?php if(mage::getstoreconfig('buyshopconfig/options/ajax_add_to_cart')){?> productaddtocartform.submit = function(button, url) { if (this.validator.validate()) { var form = this.form; var oldurl = form.action; if (url) { form.action = url; } var e = null; // start of our new ajax code if (!url) { url = jquery('#product_addtocart_form').attr('action'); } url = url.replace("checkout/cart","ajax/index"); // new code var data = jquery('#product_addtocart_form').serialize(); data += '&isajax=1'; jquery('#preloader .loader').fadein(300); try { jquery.ajax( { url : url, datatype : 'json', type : 'post', data : data, success : function(data) { jquery('#ajax_loader').hide(); if(data.status == 'error'){ alert(data.message); }else{ jquery('#preloader .loader').hide(); if(jquery('.ul_wrapper.toplinks')){ jquery('.shoppingcart').replacewith(data.sidebar); } jquery(".shoppingcart .fadelink").bind({ mouseenter: function(e) { jquery(this).find(".shopping_cart_mini").stop(true, true).fadein(300, "linear"); }, mouseleave: function(e) { jquery(this).find(".shopping_cart_mini").stop(true, true).fadeout(300, "linear"); } }); if(jquery('#topline .links')){ jquery('#topline .links').replacewith(data.toplink); } jquery('#preloader .inside').html('Товар "'data.name+'" был добавлен в вашу корзину'); jquery('#preloader .message').fadein(300); settimeout(function(){ jquery('#preloader .message').fadeout(); },1500) } } }); } catch (e) { } // end of our new ajax code this.form.action = oldurl; if (e) { throw e; } } }.bind(productaddtocartform); <?php }else { ?> productaddtocartform.submit = function(button, url) { if (this.validator.validate()) { var form = this.form; var oldurl = form.action; if (url) { form.action = url; } var e = null; try { this.form.submit(); } catch (e) { } this.form.action = oldurl; if (e) { throw e; } if (button && button != 'undefined') { button.disabled = true; } } }.bind(productaddtocartform); <?php } ?> productaddtocartform.submitlight = function(button, url){ if(this.validator) { var nv = validation.methods; delete validation.methods['required-entry']; delete validation.methods['validate-one-required']; delete validation.methods['validate-one-required-by-name']; // remove custom datetime validators (var methodname in validation.methods) { if (methodname.match(/^validate-datetime-.*/i)) { delete validation.methods[methodname]; } } if (this.validator.validate()) { if (url) { this.form.action = url; } this.form.submit(); } object.extend(validation.methods, nv); } }.bind(productaddtocartform); <?php if(!mage::helper('lightboxes')->isactive()):?> jquery("a.video").click(function() { jquery.fancybox({ 'padding' : 0, 'autoscale' : false, 'transitionin' : 'none', 'transitionout' : 'none', 'title' : this.title, 'width' : 680, 'height' : 495, 'href' : this.href.replace(new regexp("watch\\?v=", "i"), 'v/'), 'type' : 'swf', 'swf' : { 'wmode' : 'transparent', 'allowfullscreen' : 'true' } }); return false; }); <?php endif;?> //]]>
could give answer problem function?
on line (688)
jquery('#preloader .inside').html('Товар "'data.name+'" был добавлен в вашу корзину');
you're missing +
jquery('#preloader .inside').html('Товар "' + data.name + '" был добавлен в вашу корзину');
Comments
Post a Comment