• I’m using the code bellow to add a product with quantity to cart via ajax

    function addToCart(p_id,q_td) {
                jQuery.ajax({
                  type: 'POST',
                  url: '?post_type=product&add-to-cart='+p_id,
                  data: { 'product_id':  p_id,
                                'quantity': q_td},
                  success: function(response, textStatus, jqXHR){
    
                        console.log("Product added");
                    }
                  //dataType: 'JSON'
                });
            }
            jQuery('#buybtn').click(function(e) {
              e.preventDefault();
              addToCart(<?php echo $post->ID;?>,jQuery("#qtd").val());
              return false;
            });

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    What I need is to update minicart on sucess

    How can do it? The link bellow gives a clue, but how can I put “add_to_cart_fragments” to work on ajax?

    https://wcdocs.woothemes.com/snippets/show-cart-contents-total/

    https://www.ads-software.com/extend/plugins/woocommerce/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Update minicart after adding product with ajax button’ is closed to new replies.