WC_Cart::get_cart
Returns the contents of the cart in an array.
Method of the class: WC_Cart{}
No Hooks.
Returns
Array. contents of the cart
Usage
$WC_Cart = new WC_Cart(); $WC_Cart->get_cart();
WC_Cart::get_cart() WC Cart::get cart code WC 10.7.0
public function get_cart() {
if ( ! did_action( 'wp_loaded' ) ) {
wc_doing_it_wrong( __FUNCTION__, __( 'Get cart should not be called before the wp_loaded action.', 'woocommerce' ), '2.3' );
}
if ( ! did_action( 'woocommerce_load_cart_from_session' ) ) {
$this->session->get_cart_from_session();
}
return array_filter( $this->get_cart_contents() );
}