示例#1
0
 /**
  * Return stdClass summary of cart state
  *
  * If the cart is empty, the subtotal and item count will both be null.
  *
  * $summary->subtotal = '$125.00';
  * $summary->item_count = 3;
  *
  * @return stdClass
  */
 protected static function load_summary()
 {
     $summary = new stdClass();
     $summary->subtotal = null;
     $summary->item_count = null;
     $summary->api_ok = true;
     $cloud_cart = new CC_Cloud_Cart();
     if ($cart_key = $cloud_cart->get_cart_key(false)) {
         try {
             $summary = $cloud_cart->summary($cart_key);
             if (is_object($summary)) {
                 $summary->api_ok = true;
                 self::$cart_summary = $summary;
             }
         } catch (CC_Exception_API_CartNotFound $e) {
             CC_Log::write("The cart key could not be found. Dropping the cart cookie: {$cart_key}");
             $summary->api_ok = false;
             self::drop_cart();
         } catch (CC_Exception_API $e) {
             CC_Log::write("Unable to retrieve cart from Cart66 Cloud due to API failure: {$cart_key}");
             $summary->api_ok = false;
         }
     }
     return $summary;
 }
示例#2
0
 /**
  * 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;
 }
 /**
  * Returns summary information for the given shopping cart
  *
  * subtotal: the sum of the totals of all the items (not including shipping, taxes, or discounts)
  * item_count: the number of items in the cart
  *
  * @return stdClass object
  */
 public function cart_summary($cart_key)
 {
     $cart = new CC_Cloud_Cart();
     return $cart->summary($cart_key);
 }