/** * Return the number of items in the current visitor's shopping cart * * @return int */ public static function cart_item_count() { $count = 0; $cart = new CC_Cloud_Cart(); $cart_key = $cart->get_cart_key(false); if ($cart_key) { $summary = $cart->summary($cart_key); $count = $summary->item_count; } return $count; }
/** * Return the URL to the checkout page on the cloud * * @return string */ public function checkout($force_create_cart = false) { $url = null; $force_create_cart = is_bool($force_create_cart) ? $force_create_cart : false; // A non-boolean may be passed in from CC_Library $cloud_cart = new CC_Cloud_Cart(); $cart_key = $cloud_cart->get_cart_key($force_create_cart); $subdomain_url = self::$cloud->subdomain_url(); if ($cart_key && $subdomain_url) { $url = $subdomain_url . 'checkout/' . $cart_key; } return $url; }
public static function add_to_cart($post_data) { $post_data = cc_strip_slashes($post_data); $cloud_cart = new CC_Cloud_Cart(); $cart_key = $cloud_cart->get_cart_key(); $response = $cloud_cart->add_to_cart($cart_key, $post_data); if (is_wp_error($response)) { $response_code = $response->get_error_code(); $response = array('response' => array('code' => $response_code)); } return $response; }