title: Remove product in the cart using ajax in woocommerce
body: <p>I would like to remove the product in the woocommerce cart using ajax without click the  link. </p>
  
  <p>If you have encounter this kind of functionality, please help us.</p>
  
  <pre><code>add_action( 'wp_footer', 'add_js_to_wp_wcommerce');
  
  function add_js_to_wp_wcommerce(){ ?&gt;
      &lt;script type="text/javascript"&gt;
      jQuery('.remove-product').click(function(){
          var product_id = jQuery(this).attr("data-product_id");
          jQuery.ajax({
              type: 'POST',
              dataType: 'json',
              url: "/wp-admin/admin-ajax.php",
              data: { action: "product_remove", 
                      product_id: product_id
              },success: function(data){
                  console.log(data);
              }
          });
          return false;
      });
      &lt;/script&gt;
  &lt;?php }
  
  add_action( 'wp_ajax_product_remove', 'product_remove' );
  add_action( 'wp_ajax_nopriv_product_remove', 'product_remove' );
  function product_remove() {
      global $wpdb, $woocommerce;
      session_start();
      foreach ($woocommerce-&gt;cart-&gt;get_cart() as $cart_item_key =&gt; $cart_item){
          if($cart_item['product_id'] == $_POST['product_id'] ){
              // Remove product in the cart using  cart_item_key.
              $woocommerce-&gt;cart-&gt;get_remove_url($cart_item_key);
          }
      }
      print_r($woocommerce-&gt;cart-&gt;get_cart());
      //echo json_encode(array('status' =&gt; 0));
      exit();
  }
  </code></pre>