• Resolved yotamdahan

    (@yotamdahan)


    I’m trying to trigger the cart on click of custom “buy now” button I have created.

    Right now I’m using woocommerce default $_POST, but I wonder how can I trigger your ajax to update the current product.

    /* Create Buy Now Button dynamically after Add To Cart button */
        function add_content_after_addtocart() {
        global $wp;
            // get the current post/product ID
            $current_product_id = get_the_ID();
        
            // get the product based on the ID
            $product = wc_get_product( $current_product_id );
        
            // get the "Checkout Page" URL
            $url = home_url( $wp->request );
        
            // run only on simple products
            if( $product->is_type( 'simple' ) ){
                echo '<a style="display: block; text-align: center;" href="'. $url .'/?add-to-cart='.$current_product_id.'" class="buy-now button">??? ?????</a>';
            }
        }
        add_action( 'woocommerce_after_shop_loop_item', 'add_content_after_addtocart', 40 );

    How can I update cart using your plugin ajax on click of “buy now” button?

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Trigger ajax cart’ is closed to new replies.