I am using a quick view plugin, (https://es.wordpress.org/plugins/woocommerce-lightbox/) and I am looking for a way to add products to my cart without redirecting or showing the loading icon when adding products to the cart in the quick view. In the following website it's working on the variation product in the shop page: http://dev-ak.com/woocommerce-dev/temp/shop/ But I would also like to have it work for the simple products in my quick view window.

I know how to change the redirect link to link back to the shop page, but that is not what I am looking for, it needs to be without reloading. I also tried a code that removes the redirect after adding a product to the cart but that didn't work.

For the example website the following codes were used:

 * Customise variable add to cart button for loop.
 * Remove qty selector and simplify.
  function iconic_loop_variation_add_to_cart_button()
    global $product;

    <div class="woocommerce-variation-add-to-cart variations_button">
        <button   type="submit" class="custom_add_to_cart single_add_to_cart_button button"><?php echo esc_html($product->single_add_to_cart_text()); ?></button>
        <input type="hidden" name="add-to-cart" value="<?php echo absint($product->get_id()); ?>" />
        <input type="hidden" name="product_id" value="<?php echo absint($product->get_id()); ?>" />
        <input type="hidden" name="variation_id" class="variation_id" value="0" />

Ajax code:

 jQuery(document).ready(function ($) {
  "use strict";

  $('.custom_add_to_cart').click(function (e) {
    var id = $(this).next().next().attr('value');
    var data = {
      product_id: id,
      quantity: 1
                   $.post(wc_add_to_cart_params.wc_ajax_url.toString().replace('%%endpoint     %%', 'add_to_cart'), data, function (response) {

      if (!response) {
      if (response.error) {
        alert("Custom Massage ");
      if (response) {

        var url = woocommerce_params.wc_ajax_url;
        url = url.replace("%%endpoint%%", "get_refreshed_fragments");
        $.post(url, function (data, status) {
          if (data.fragments) {
            jQuery.each(data.fragments, function (key, value) {





0 Answers