Raza
Raza

Reputation: 11

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'?

$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.

Upvotes: 1

Views: 941

Answers (1)

Andy
Andy

Reputation: 995

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;
}

Upvotes: 1

Related Questions