Add to cart product with ajax in woocommerce (Without Refresh page). <script> jQuery(document).ready(function($) { $('.wishlist_add_to_cart').on('click', function(e){ e.preventDefault(); $('.wishlist_preloader').css('visibility','visible'); $thisbutton = $(this), $form = $thisbutton.closest('form.cart'), id = $thisbutton.val(), product_qty = $form.find('input[name=quantity]').val() || 1, product_id = $(this).data('product-id'); variation_id = $form.find('input[name=variation_id]').val() || 0; var data = { action: 'ql_woocommerce_ajax_add_to_cart', product_id: product_id, product_sku: '', quantity: product_qty, variation_id: variation_id, }; $.ajax({ type: 'post', url: wc_add_to_cart_params.ajax
We provide knowledgeable blogs related to php, jQuery, html, css, wordpress, woocommerce, cordova app with examples in 2021.