title: Enable Ajax add to cart button on products custom loop in Woocommerce
body: <p>This is the code which I have written for the custom loop code for the product-archive page. I want to use ajax for adding products to the cart. How should I do it?<br>
  I would also like to know which woocommerce function show woocommerce notices to the customer. Like when I click add to cart Notice should be shown to the client that product has been added.</p>
  
  <pre><code>$args = array(
      'post_type' =&gt; 'product',
      'posts_per_page' =&gt; 12,
  );
  $loop = new WP_Query($args);
  if ($loop-&gt;have_posts()) {
      while ($loop-&gt;have_posts()): $loop-&gt;the_post();
        ?&gt;
          &lt;!-- tab product --&gt;
          &lt;li class="col-sx-12 col-sm-4"&gt;
            &lt;div class="product-container"&gt;
              &lt;div class="left-block"&gt;
                &lt;a href="&lt;?php echo get_permalink(); ?&gt;" target="_blank"&gt;
                  &lt;?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($loop-&gt;post-&gt;ID), 'single-post-thumbnail');?&gt;
                  &lt;img height="300px" width="300px" class="img-responsive" alt="product" src="&lt;?php echo $image[0]; ?&gt;"&gt;
                &lt;/a&gt;
                &lt;div class="quick-view"&gt;
  
                &lt;/div&gt;
                &lt;div class="add-to-cart "&gt;
                  &lt;a href="&lt;?php echo $product-&gt;add_to_cart_url(); ?&gt;" class="cart"&gt;
                    &lt;span&gt;
                      &lt;span class="add-to-cart-content"&gt;Add To Cart
                      &lt;/span&gt;
                    &lt;/span&gt;
                  &lt;/a&gt;
                &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="right-block"&gt;
                &lt;h5 class="product-name"&gt;
                  &lt;a href="&lt;?php echo get_permalink(); ?&gt;" target="_blank" class="product-block-click"&gt;
                    &lt;?php echo $product-&gt;get_title(); ?&gt;
                  &lt;/a&gt;
                &lt;/h5&gt;
                &lt;div class="content_price"&gt;
                  &lt;span class="price product-price"&gt;
                    &lt;i class="fa fa-inr" aria-hidden="true"&gt;
                    &lt;/i&gt;
                    &lt;?php echo $product-&gt;get_regular_price(); ?&gt;
                  &lt;/span&gt;
                  &lt;span class="price old-price"&gt;
                    &lt;i class="fa fa-inr" aria-hidden="true"&gt;
                    &lt;/i&gt;
                    &lt;?php echo $product-&gt;get_sale_price(); ?&gt;
                  &lt;/span&gt;
                  &lt;span class="discount-block"&gt;50 % OFF
                  &lt;/span&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;
          &lt;/li&gt;
        &lt;?php
      endwhile;
  }
  echo "&lt;/ul&gt;";
  wp_reset_postdata();
  ?&gt;
  </code></pre>