s.elettronew Posted March 3, 2022 Share Posted March 3, 2022 Hi Guys, I have a little JS function, that delete the stored carts. That work nice with all the language, but with the italian he do just a refresh of page. What could be the problem ? It s like he can't find the function... Here the funcition: function deleteCart(id, name) { if (confirm('{l s='Delete cart' mod='addtocartfromurl'}' + ' ' + name + '. {l s='Are you sure?' mod='addtocartfromurl'}') === true) { //$('button#submitDeleteSavedCart').attr('disabled','disabled').addClass('disabled').removeClass('active'); $('button#submitDeleteSavedCart').attr('disabled','disabled'); $.ajax({ type: 'POST', url: '{$cart_controller|escape:"quotes":"UTF-8"}', async: true, cache: false, dataType: "json", data: 'method=delete&id=' + id + '&token=' + '{$token|escape:'htmlall':'UTF-8'}', success: function (jsonData) { //$('button#submitDeleteSavedCart').removeAttr('disabled').removeClass('disabled'); $('button#submitDeleteSavedCart').removeAttr('disabled'); if (jsonData.response.result === 'OK') { $('div.addtocartfromurl_' + id).hide('slow', function(){ $('div.addtocartfromurl_' + id).remove(); }); $('div.addtocartfromurl-saved-cart-messages').addClass('addtocartfromurl-saved-cart-messages-alert alert alert-success').text('{l s='Cart deleted successfully.' mod='addtocartfromurl'}'); } else if (jsonData.response.result === 'NOK') { $('div.addtocartfromurl-saved-cart-messages').addClass('addtocartfromurl-saved-cart-messages-alert alert alert-warning').text('{l s='There was a problem deleting the cart. Please, try again.' mod='addtocartfromurl'}'); } }, error: function (XMLHttpRequest, textStatus, errorThrown) { //$('button#submitDeleteSavedCart').removeAttr('disabled').removeClass('disabled'); $('button#submitDeleteSavedCart').removeAttr('disabled'); console.log(XMLHttpRequest); if (textStatus !== 'abort') { alert("TECHNICAL ERROR: unable to delete cart " + card_number + " \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus); } } }); } else { $('button#submitDeleteSavedCart').each(function(){ $(this).removeClass('active'); }); } } Link to comment Share on other sites More sharing options...
Ress Posted March 5, 2022 Share Posted March 5, 2022 Can you put the shop link so we can see exactly? Link to comment Share on other sites More sharing options...
s.elettronew Posted March 7, 2022 Author Share Posted March 7, 2022 Hi Ress, Here the shop : https://www.elettronew.com/en/ Link to comment Share on other sites More sharing options...
Ress Posted March 7, 2022 Share Posted March 7, 2022 Hi, The problem is from here: $('div.addtocartfromurl-saved-cart-messages').addClass('addtocartfromurl-saved-cart-messages-alert alert alert-warning').text('Si è verificato un problema durante l' eliminazione del carrello. Ti invitiamo a riprovare più tardi.'); Exactly from here: 'Si è verificato un problema durante l' eliminazione del carrello. Ti invitiamo a riprovare più tardi.' Replace with 'Si è verificato un problema durante l\' eliminazione del carrello. Ti invitiamo a riprovare più tardi.' Because of that quotation mark, the javascript code is no longer ok, because of it, it closes the string. You can add \ or replace it with ". Link to comment Share on other sites More sharing options...
s.elettronew Posted March 7, 2022 Author Share Posted March 7, 2022 That's is already set like that in the file of the translation in modules/addtocartfromurl/translation/it .. is so weird Link to comment Share on other sites More sharing options...
Ress Posted March 7, 2022 Share Posted March 7, 2022 Did you remove the quotation mark? Does it work now? 1 Link to comment Share on other sites More sharing options...
s.elettronew Posted March 7, 2022 Author Share Posted March 7, 2022 Yes that's work ! Thank you Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now