Skip to main content

khushipataki.in

Contact Us

Working hours

09:00 am - 08:30 pm

Call us on

(+1) 234 56 789

You can email here

ex@domain.com

Address

633, Northwest , Ecuador

Get in Touch

Ask Question

View Frequently Asked Questions

I am text block. Click edit button to change this text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.
jQuery(function ($) { /* * ========================================== * CUSTOM ALL PRODUCTS CART * ========================================== */ function getExistingCartProductIDs() { let ids = []; $('.woocommerce-cart-form__cart-item').each(function () { let id = $(this).find('.product-remove a').attr('data-product_id'); if (id) { ids.push(parseInt(id)); } /* * Fallback: * WooCommerce cart item sometimes doesn't expose product ID */ let variationID = $(this).find('.product-remove a').attr('data-product_id'); if (variationID) { ids.push(parseInt(variationID)); } }); return [...new Set(ids)]; } /* * Get product ID from existing cart row */ function getCartProductIDs() { let ids = []; $('.woocommerce-cart-form__cart-item').each(function () { let row = $(this); let id = row.attr('data-product_id') || row.find('.product-remove a').attr('data-product_id') || row.find('.product-remove a').data('product_id'); if (id) { ids.push(parseInt(id)); } }); return [...new Set(ids)]; } /* * Add zero quantity products */ function addZeroQuantityProducts() { if ( typeof window.AllSimpleProducts === 'undefined' || !window.AllSimpleProducts.length ) { return; } let tableBody = $('.woocommerce-cart-form__contents tbody'); if (!tableBody.length) { return; } /* * Existing products */ let existingIDs = []; tableBody .find('.woocommerce-cart-form__cart-item') .each(function () { let row = $(this); let productID = row.attr('data-product_id') || row.find('.product-remove a').attr('data-product_id'); if (productID) { existingIDs.push(parseInt(productID)); } }); /* * Add only products not already in cart */ window.AllSimpleProducts.forEach(function (product) { if ( existingIDs.includes(parseInt(product.id)) ) { return; } /* * Don't add duplicate custom rows */ if ( tableBody.find( '[data-zero-product-id="' + product.id + '"]' ).length ) { return; } let disabled = ''; if ( !product.purchasable || !product.in_stock ) { disabled = 'disabled'; } let stockText = ''; if (product.backorder) { stockText = '' + 'Available on backorder' + ''; } else if (!product.in_stock) { stockText = '' + 'Out of stock' + ''; } let imageHTML = ''; if (product.image) { imageHTML = '' +
                    escapeHTML(product.name) +
                    ''; } let rowHTML = '' + /* * PRODUCT */ '' + '
' + '
' + '' + imageHTML + '' + '
' + '
' + '' + escapeHTML(product.name) + '' + stockText + '
' + '
' + '' + /* * PRICE */ '' + product.price_html + '' + /* * QUANTITY */ '' + '
' + '' + '' + '' + '
' + '' + /* * SUBTOTAL */ '' + '' + wc_price_custom(0) + '' + '' + ''; tableBody.append(rowHTML); }); /* * Remove the original X icons */ $('.product-remove').remove(); } /* * Escape HTML */ function escapeHTML(text) { return $('
') .text(text) .html(); } /* * Currency * * Change ₹ if your WooCommerce * currency is different. */ function wc_price_custom(amount) { return '$' + Number(amount).toLocaleString( 'en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 } ); } /* * ========================================== * PLUS BUTTON * ========================================== */ $(document).on( 'click', '.custom-zero-plus', function () { let button = $(this); if (button.prop('disabled')) { return; } let row = button.closest( '.custom-zero-cart-item' ); let input = row.find( '.custom-zero-input' ); let current = parseInt(input.val()) || 0; /* * First quantity */ if (current === 0) { let productID = row.attr( 'data-zero-product-id' ); button.prop('disabled', true); input.val(1); /* * Add to WooCommerce cart */ $.ajax({ url: window.CustomCartAjax, type: 'POST', data: { action: 'custom_cart_add_product', product_id: productID, quantity: 1 }, success: function (response) { if ( response.success ) { /* * Reload cart * so WooCommerce * handles totals, * coupons and checkout. */ window.location.reload(); } else { input.val(0); button.prop( 'disabled', false ); } }, error: function () { input.val(0); button.prop( 'disabled', false ); } }); } } ); /* * ========================================== * MINUS BUTTON * ========================================== */ $(document).on( 'click', '.custom-zero-minus', function () { let input = $(this) .siblings( '.custom-zero-input' ); let value = parseInt(input.val()) || 0; if (value > 0) { value--; } input.val(value); } ); /* * ========================================== * INITIAL LOAD * ========================================== */ setTimeout(function () { addZeroQuantityProducts(); }, 300); /* * ========================================== * WOOCOMMERCE AJAX UPDATE * ========================================== */ $(document.body).on( 'updated_wc_div', function () { setTimeout(function () { addZeroQuantityProducts(); }, 300); } ); /* * ========================================== * REMOVE X ICON * ========================================== */ $(document).on( 'updated_wc_div', function () { $('.product-remove').remove(); } ); });