keepercop Posted March 12, 2015 Share Posted March 12, 2015 Hello One week ago I am trying to correct the code of the template ajax-cart.js SHINE. someone could help guide me. The error does not allow me to add, remove and check the cart. I leave the web. www.keepercop.com Uncaught ReferenceError: baseUri is not definedajax-cart.js:378 ajaxCart.removeajax-cart.js:181 (anonymous function)jquery.min.js:5 x.event.dispatchjquery.min.js:5 v.handle ajax-cart.js:290 Uncaught ReferenceError: emptyCustomizations is not definedajax-cart.js:290 ajaxCart.addajax-cart.js:133 (anonymous function)jquery.min.js:5 x.event.dispatchjquery.min.js:5 v.handle Many Thanks! Link to comment Share on other sites More sharing options...
tuk66 Posted March 12, 2015 Share Posted March 12, 2015 It looks like a theme issue. My Console says this: TypeError: $(...).autocomplete is not a function $("#search_query_top") /en/ (line 659) ReferenceError: emptyCustomizations is not defined emptyCustomizations(); ajax-cart.js (line 290, col 2) Link to comment Share on other sites More sharing options...
keepercop Posted March 12, 2015 Author Share Posted March 12, 2015 It looks like a theme issue. My Console says this: TypeError: $(...).autocomplete is not a function $("#search_query_top") /en/ (line 659) ReferenceError: emptyCustomizations is not defined emptyCustomizations(); ajax-cart.js (line 290, col 2) Yes, and several errors when you click to add or delete a product appear. Any solution? many Thanks Link to comment Share on other sites More sharing options...
keepercop Posted March 12, 2015 Author Share Posted March 12, 2015 Please Help!! SCRIPT5009: 'emptyCustomizations' no está definido ajax-cart.js, Línea 302 Carácter 3 LINE return; } emptyCustomizations(); //disabled the button when adding to not double add if user double click if (addedFromProductPage) { $('#add_to_cart button').prop('disabled', 'disabled').addClass('disabled'); $('.filled').removeClass('filled'); } else $(callerElement).prop('disabled', 'disabled'); if ($('.cart_block_list').hasClass('collapsed')) this.expand(); //send the ajax request to the server $.ajax({ type: 'POST', headers: { "cache-control": "no-cache" }, url: baseUri + '?rand=' + new Date().getTime(), async: true, cache: false, dataType : "json", data: 'controller=cart&add=1&ajax=true&qty=' + ((quantity && quantity != null) ? quantity : '1') + '&id_product=' + idProduct + '&token=' + static_token + ( (parseInt(idCombination) && idCombination != null) ? '&ipa=' + parseInt(idCombination): ''), success: function(jsonData,textStatus,jqXHR) { // add appliance to whishlist module if (whishlist && !jsonData.errors) WishlistAddProductCart(whishlist[0], idProduct, idCombination, whishlist[1]); if (!jsonData.hasError) { if (contentOnly) window.parent.ajaxCart.updateCartInformation(jsonData, addedFromProductPage); else ajaxCart.updateCartInformation(jsonData, addedFromProductPage); if (jsonData.crossSelling) $('.crossseling').html(jsonData.crossSelling); if (idCombination) $(jsonData.products).each(function(){ if (this.id != undefined && this.id == parseInt(idProduct) && this.idCombination == parseInt(idCombination)) if (contentOnly) window.parent.ajaxCart.updateLayer(this); else ajaxCart.updateLayer(this); }); else $(jsonData.products).each(function(){ if (this.id != undefined && this.id == parseInt(idProduct)) if (contentOnly) window.parent.ajaxCart.updateLayer(this); else ajaxCart.updateLayer(this); }); if (contentOnly) parent.$.fancybox.close(); } else { if (contentOnly) window.parent.ajaxCart.updateCart(jsonData); else ajaxCart.updateCart(jsonData); if (addedFromProductPage) $('#add_to_cart button').removeProp('disabled').removeClass('disabled'); else $(callerElement).removeProp('disabled'); } }, error: function(XMLHttpRequest, textStatus, errorThrown) { var error = "Impossible to add the product to the cart.<br/>textStatus: '" + textStatus + "'<br/>errorThrown: '" + errorThrown + "'<br/>responseText:<br/>" + XMLHttpRequest.responseText; if (!!$.prototype.fancybox) $.fancybox.open([ { type: 'inline', autoScale: true, minHeight: 30, content: '<p class="fancybox-error">' + error + '</p>' }], { padding: 0 }); else alert(error); //reactive the button when adding has finished if (addedFromProductPage) $('#add_to_cart button').removeProp('disabled').removeClass('disabled'); else $(callerElement).removeProp('disabled'); } }); }, //remove a product from the cart via ajax remove : function(idProduct, idCombination, customizationId, idAddressDelivery){ //send the ajax request to the server $.ajax({ type: 'POST', headers: { "cache-control": "no-cache" }, url: baseUri + '?rand=' + new Date().getTime(), async: true, cache: false, dataType : "json", data: 'controller=cart&delete=1&id_product=' + idProduct + '&ipa=' + ((idCombination != null && parseInt(idCombination)) ? idCombination : '') + ((customizationId && customizationId != null) ? '&id_customization=' + customizationId : '') + '&id_address_delivery=' + idAddressDelivery + '&token=' + static_token + '&ajax=true', success: function(jsonData) { ajaxCart.updateCart(jsonData); if ($('body').attr('id') == 'order' || $('body').attr('id') == 'order-opc') deleteProductFromSummary(idProduct+'_'+idCombination+'_'+customizationId+'_'+idAddressDelivery); }, error: function() { var error = 'ERROR: unable to delete the product'; if (!!$.prototype.fancybox) { $.fancybox.open([ { type: 'inline', autoScale: true, minHeight: 30, content: error } ], { padding: 0 }); } else alert(error); } }); }, //hide the products displayed in the page but no more in the json data hideOldProducts : function(jsonData){ //delete an eventually removed product of the displayed cart (only if cart is not empty!) if ($('.cart_block_list:first dl.products').length > 0) { var removedProductId = null; var removedProductData = null; var removedProductDomId = null; //look for a product to delete... $('.cart_block_list:first dl.products dt').each(function(){ //retrieve idProduct and idCombination from the displayed product in the block cart var domIdProduct = $(this).data('id'); var firstCut = domIdProduct.replace('cart_block_product_', ''); var ids = firstCut.split('_'); //try to know if the current product is still in the new list var stayInTheCart = false; for (aProduct in jsonData.products) { //we've called the variable aProduct because IE6 bug if this variable is called product //if product has attributes if (jsonData.products[aProduct]['id'] == ids[0] && (!ids[1] || jsonData.products[aProduct]['idCombination'] == ids[1])) { stayInTheCart = true; // update the product customization display (when the product is still in the cart) ajaxCart.hideOldProductCustomizations(jsonData.products[aProduct], domIdProduct); } } //remove product if it's no more in the cart if (!stayInTheCart) { removedProductId = $(this).data('id'); if (removedProductId != null) { var firstCut = removedProductId.replace('cart_block_product_', ''); var ids = firstCut.split('_'); $('dt[data-id="' + removedProductId + '"]').addClass('strike').fadeTo('slow', 0, function(){ $(this).slideUp('slow', function(){ $(this).remove(); // If the cart is now empty, show the 'no product in the cart' message and close detail if($('.cart_block:first dl.products dt').length == 0) { $('.ajax_cart_quantity').html('0'); $("#header .cart_block").stop(true, true).slideUp(200); $('.cart_block_no_products:hidden').slideDown(450); $('.cart_block dl.products').remove(); } }); }); $('dd[data-id="cart_block_combination_of_' + ids[0] + (ids[1] ? '_'+ids[1] : '') + (ids[2] ? '_'+ids[2] : '') + '"]').fadeTo('fast', 0, function(){ $(this).slideUp('fast', function(){ $(this).remove(); }); }); } } }); } }, hideOldProductCustomizations : function (product, domIdProduct){ var customizationList = $('ul[data-id="customization_' + product['id'] + '_' + product['idCombination'] + '"]'); if(customizationList.length > 0) { $(customizationList).find("li").each(function(){ $(this).find("div").each(function(){ var customizationDiv = $(this).data('id'); var tmp = customizationDiv.replace('deleteCustomizableProduct_', ''); var ids = tmp.split('_'); if ((parseInt(product.idCombination) == parseInt(ids[2])) && !ajaxCart.doesCustomizationStillExist(product, ids[0])) $('div[data-id="' + customizationDiv + '"]').parent().addClass('strike').fadeTo('slow', 0, function(){ $(this).slideUp('slow'); $(this).remove(); }); }); }); } var removeLinks = $('.deleteCustomizableProduct[data-id="' + domIdProduct + '"]').find('.ajax_cart_block_remove_link'); if (!product.hasCustomizedDatas && !removeLinks.length) $('div[data-id="' + domIdProduct + '"]' + ' span.remove_link').html('<a class="ajax_cart_block_remove_link" rel="nofollow" href="' + baseUri + '?controller=cart&delete=1&id_product=' + product['id'] + '&ipa=' + product['idCombination'] + '&token=' + static_token + '"> </a>'); if (product.is_gift) $('div[data-id="' + domIdProduct + '"]' + ' span.remove_link').html(''); }, doesCustomizationStillExist : function (product, customizationId){ var exists = false; $(product.customizedDatas).each(function(){ if (this.customizationId == customizationId) { exists = true; // This return does not mean that we found nothing but simply break the loop return false; } }); return (exists); }, Link to comment Share on other sites More sharing options...
keepercop Posted March 13, 2015 Author Share Posted March 13, 2015 (edited) This Correct? href='http://keepercop.com/ag/cart?add=1&id_product=20&token=cee29a0af7805906250c78d5d54c7fa3' or this href='http://24webgroup.com/ps/Shine/demo-1/index.php?controller=cart&add=1&id_product=2&token=0fa4690a0113aacdde34820dadd8ba49' Edited March 13, 2015 by keepercop (see edit history) Link to comment Share on other sites More sharing options...
keepercop Posted March 13, 2015 Author Share Posted March 13, 2015 can anyone help me? Link to comment Share on other sites More sharing options...
keepercop Posted March 16, 2015 Author Share Posted March 16, 2015 No me redirecciona el ajax. Alguna solucion? $.ajax({ type: 'POST', headers: { "cache-control": "no-cache" }, url: baseUri + '?rand=' + new Date().getTime(), async: true, cache: false, dataType : "json", data: 'controller=cart&add=1&ajax=true&qty=' + ((quantity && quantity != null) ? quantity : '1') + '&id_product=' + idProduct + '&token=' + static_token + ( (parseInt(idCombination) && idCombination != null) ? '&ipa=' + parseInt(idCombination): ''), success: function(jsonData,textStatus,jqXHR) { Link to comment Share on other sites More sharing options...
keepercop Posted March 17, 2015 Author Share Posted March 17, 2015 (edited) Despues de unas semanas encontre la solucion al problema que tenia cuando hacia click en ADD TO CART y en consola tiraba el error BaseUri is not defined. La solucion esta en los archivos global.tpl y global.js En global.js deben cambiar: esto closeBtn : '<a title="' + FancyboxboxI18nClose + '" class="fancybox-item fancybox-close" href="javascript:;"></a>', por closeBtn : '<a title="' + FancyboxI18nClose + '" class="fancybox-item fancybox-close" href="javascript:;"></a>', En global.tpl Esto {addJsDefL name=FancyboxboxI18nClose}{l s='Close'}{/addJsDefL} Por {addJsDefL name=FancyboxI18nClose}{l s='Close'}{/addJsDefL} Espero le sea de ayuda para aquellos que no encuentran la solución y que tampoco en el foro los ayudan o no consiguen respuesta. Por tal motivo dejo la solución. Tambien deben colocar en el header.tpl y antes del {$HOOK_HEADER} esto {if isset($js_defer) && !$js_defer && isset($js_files) && isset($js_def)} {$js_def} {foreach from=$js_files item=js_uri} <script type="text/javascript" src="{$js_uri|escape:'html':'UTF-8'}"></script> {/foreach} {/if} Quedando asi: {if isset($js_defer) && !$js_defer && isset($js_files) && isset($js_def)} {$js_def} {foreach from=$js_files item=js_uri} <script type="text/javascript" src="{$js_uri|escape:'html':'UTF-8'}"></script> {/foreach} {/if} <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script type="text/javascript" src="{$js_dir}shine/slider-banner.js"></script> <script type="text/javascript" src="{$js_dir}shine/jquery.bxslider.min.js"></script> <script type="text/javascript" src="{$js_dir}shine/jquery.accordion.source.js"></script> <script type="text/javascript" src="{$js_dir}shine/jquery.flexslider.js"></script> <script type="text/javascript" src="{$js_dir}shine/jquery.jcarousel.min.js"></script> <script type="text/javascript" src="{$js_dir}shine/custom.js"></script> <script type="text/javascript" src="{$js_dir}shine/superfish.js"></script> <script type="text/javascript" src="{$js_dir}shine/jquery.fancybox.js"></script> <script type="text/javascript" src="/themes/shine/js/modules/blockcart/ajax-cart.js"></script> Saludos. Edited March 17, 2015 by keepercop (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts