Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var __isp_options = {
- isp_dropdown_callback: function(jquery_li_element, item) {
- var product_id = jquery_li_element.attr('isp_id');
- var product_sku = item.sku;
- if (!item.id || item.category || !item.product_url) { return jquery_li_element; }
- var addtocart_html = "<form style='position: absolute; right: 0; top: 50%; transform: translateY(-50%); z-index: 2147483647;' name='form_" + product_id + "' id='form_" + product_id + "' class='isp_add_to_cart_form' enctype='multipart/form data' method='post'>";
- addtocart_html += "<input name='product_id' type='hidden' value=" + product_id + ">";
- addtocart_html += "<input name='action' type='hidden' value='add'>";
- addtocart_html += "<input name='product_sku' type='hidden' value=" + product_sku + ">";
- addtocart_html += "<input type='hidden' id='quantity_" + product_id + "' name='qty[]' value='1' min='1' autocomplete='off' type='number'>";
- addtocart_html += "<input style='background-color: #f95113; padding: 0; width: 60px; height: 60px; background-image: url(https://www.vivamart.no/wp-content/themes/onesocial-child/images/cart-hover.png); background-size: 50px; background-position: center; background-repeat: no-repeat;' id='btn_" + product_id + "' onclick='isp_add_to_cart(event, " + product_id + ")' type='submit' value='' class='isp_add_to_cart_btn'>";
- addtocart_html += "</form>";
- return jquery_li_element.prepend(addtocart_html);
- }
- }
- 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_isp(window).width() > 480) {
- $jquery_isp('.header-wrapper .cart-button b').html("<img src='https://storagehub.vmware.com/static/images/vmware/loading.gif' style='width: 15px; height: 15px;'>");
- } else {
- $jquery_isp('#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_isp(window).width() > 480) {
- $jquery_isp('.header-wrapper .cart-button b').load(document.URL + '.header-wrapper .header-total', function() {
- var seen = {};
- $jquery_isp('.header-wrapper .header-total').each(function() {
- var txt = $jquery_isp(this).text();
- if (seen[txt]) { $jquery_isp(this).remove(); }
- else { seen[txt] = true; }
- });
- });
- } else {
- $jquery_isp('#mobile-header .cart-button b').load(document.URL + '#mobile-header .header-total', function() {
- var seen = {};
- $jquery_isp('#mobile-header .header-total').each(function() {
- var txt = $jquery_isp(this).text();
- if (seen[txt]) { $jquery_isp(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