function addToCart2(id, productName, qty, options) { Jumpseller.addProductToCart(id, qty, options, { callback: function(data, status) { toastr.options = { closeButton: true, debug: false, newestOnTop: false, progressBar: true, positionClass: 'toast-top-right', preventDuplicates: false, onclick: null, showDuration: '500', hideDuration: '1000', timeOut: '5000', extendedTimeOut: '1000', showEasing: 'swing', hideEasing: 'linear', showMethod: 'fadeIn', hideMethod: 'fadeOut', }; if (data.status == 404) { toastr.error(data.responseJSON.message); } else { if (parseInt(qty) == 1) { toastr.success( qty + ' ' + productName + ' ' + singleProductMessage + ' ' + shoppingCartMessage + '' ); } else { toastr.success( qty + ' ' + productName + ' ' + multiProductMessage + ' ' + shoppingCartMessage + '' ); } // update cart in page mobile_element = $('.fa-shopping-cart') .parent() .find('span'); desktop_element = $('.fa-shopping-cart:eq(1)').parent()[0] .childNodes[1]; cart_number = parseInt(mobile_element.text()); cart_total = cart_number + parseInt(qty); mobile_element.text(cart_number + parseInt(qty)); desktop_text = desktop_element.nodeValue.replace(/[0-9]/g, '').slice(0, -2) + '(' + cart_total + ')'; desktop_element.nodeValue = desktop_text; } }, }); }