WordPress Woocommerce ajax submit through plugin on cart page

Created plugin, which showing form on shopping cart page after submit i am sending value to third party server.

jQuery.ajax({ 
    type: 'POST',  
    url: 'http://www.yoursitename.com/wp-content/plugin/my-ajax.php',

How can i call woocommerce data on ‘my-ajax.php’?

Read More
$subtotal = $woocommerce->cart->subtotal;
$shipping = $woocommerce->cart->shipping_total;
$orderTotal = $woocommerce->cart->total;

Above value i want to first call on my.ajax.php and then redirect page to shopping cart with some message etc.

Please help me i am really stuck here.

Related posts

Leave a Reply

1 comment

  1. You’ll need to start by using the $woocommerce global! You’re on the right track.

    function () {
    global $woocommerce;
    
        $subtotal = $woocommerce->cart->subtotal;
        $shipping = $woocommerce->cart->shipping_total;
        $orderTotal = $woocommerce->cart->total;
    }