Skip to content

Instantly share code, notes, and snippets.

@nielslange
Last active February 18, 2017 14:13
Show Gist options
  • Save nielslange/fb9799f37927fbd655e5d444353afec7 to your computer and use it in GitHub Desktop.
Save nielslange/fb9799f37927fbd655e5d444353afec7 to your computer and use it in GitHub Desktop.
Access WC variables
<?php
//* Get global WC object
global $woocommerce;
//* Access various WooCommerce cart variables, see also https://docs.woothemes.com/wc-apidocs/class-WC_Cart.html
$woocommerce->cart->get_cart_subtotal();
$woocommerce->cart->get_cart_tax();
$woocommerce->cart->get_cart_total();
//* Access various WooCommerce customer variables, see also @see https://docs.woothemes.com/wc-apidocs/class-WC_Customer.html
$woocommerce->customer->get_country();
$woocommerce->customer->get_default_country();
$woocommerce->customer->get_shipping_country();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment