/** * Return the total price of the cart for the current visitor formatted as currency * * @return string */ public static function cart_subtotal() { $subtotal = ''; $cart_key = CC_Cart::get_cart_key(false); $cart = new CC_Cloud_Cart(); if ($cart_key) { $summary = $cart->summary($cart_key); $subtotal = $summary->subtotal; } return $subtotal; }
/** * 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; }
/** * Return the cart id from self, cookie, or create a new one * * If force is false, a new cart will not be created and false will be returned * if a cart_key is not in the cookie * * @return mixed string or false */ public function get_cart_key($create_if_empty = true) { $cart_key = false; if (isset(self::$cart_key)) { $cart_key = self::$cart_key; // CC_Log::write( "got cart key from myself: $cart_key" ); } elseif (isset($_COOKIE['cc_cart_key'])) { $cart_key = $_COOKIE['cc_cart_key']; // CC_Log::write( "got cart key from cookie: $cart_key" ); } if ($cart_key == false && $create_if_empty !== false) { $cart_key = $this->create(); // CC_Log::write( "created cart key in the cloud: $cart_key" ); } self::$cart_key = $cart_key; return $cart_key; }
public function add_to_cart($cart_key, $post_data) { $cart = new CC_Cloud_Cart(); return $cart->add_to_cart($cart_key, $post_data); }
public static function cc_cart_subtotal($args, $content) { $cart = new CC_Cloud_Cart(); return $cart->subtotal(); }
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; }