Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function isp_add_to_cart(event, product_id) {
- $jquery.ajax({
- url: "/cart/?add-to-cart=" + product_id + "&quantity=1",
- type: "POST",
- beforeSend: function(result) {
- $("#btn_" + product_id).css("background-image", "url(https://storagehub.vmware.com/static/images/vmware/loading.gif)");
- $("#btn_" + product_id).css("background-size", "25px");
- if ($jquery(window).width() > 480) {
- $jquery('.header-wrapper .cart-button b').html("<img src='https://storagehub.vmware.com/static/images/vmware/loading.gif' style='width: 15px; height: 15px;'>");
- } else {
- $jquery('#mobile-header .cart-button b').html("<img src='https://storagehub.vmware.com/static/images/vmware/loading.gif' style='width: 15px; height: 15px;'>");
- }
- },
- success: function(result) {
- $("#btn_" + product_id).css("background-image", "url(https://www.vivamart.no/wp-content/themes/onesocial-child/images/cart-hover.png)");
- $("#btn_" + product_id).css("background-size", "50px");
- if ($jquery(window).width() > 480) {
- $jquery('.header-wrapper .cart-button b').load(document.URL + '.header-wrapper .header-total', function() {
- var seen = {};
- $jquery('.header-wrapper .header-total').each(function() {
- var txt = $jquery(this).text();
- if (seen[txt]) { $jquery(this).remove(); }
- else { seen[txt] = true; }
- });
- });
- } else {
- $jquery('#mobile-header .cart-button b').load(document.URL + '#mobile-header .header-total', function() {
- var seen = {};
- $jquery('#mobile-header .header-total').each(function() {
- var txt = $jquery(this).text();
- if (seen[txt]) { $jquery(this).remove(); }
- else { seen[txt] = true; }
- });
- });
- }
- },
- error: function(result) {
- console.log("error");
- }
- });
- event.preventDefault();
- event.stopPropagation();
- event.stopImmediatePropagation();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement