本文整理匯總了PHP中ShoppingCart::singletoncart方法的典型用法代碼示例。如果您正苦於以下問題:PHP ShoppingCart::singletoncart方法的具體用法?PHP ShoppingCart::singletoncart怎麽用?PHP ShoppingCart::singletoncart使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ShoppingCart
的用法示例。
在下文中一共展示了ShoppingCart::singletoncart方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: singleton
/**
* Allows access to the cart from anywhere in code.
* @return ShoppingCart Object
*/
public static function singleton()
{
if (!self::$singletoncart) {
self::$singletoncart = new ShoppingCart();
}
return self::$singletoncart;
}
示例2: clear
/**
* Clears the cart contents completely by removing the orderID from session, and
* thus creating a new cart on next request.
* @return Boolean
*/
public function clear()
{
//we keep this here so that a flush can be added...
set_time_limit(1200);
self::$singletoncart = null;
$this->order = null;
$this->messages = array();
foreach (self::$session_variable_names as $name) {
$sessionVariableName = $this->sessionVariableName($name);
Session::set($sessionVariableName, null);
Session::clear($sessionVariableName);
Session::save();
}
$memberID = Intval(Member::currentUserID());
if ($memberID) {
$orders = Order::get()->filter(array("MemberID" => $memberID));
if ($orders && $orders->count()) {
foreach ($orders as $order) {
if (!$order->IsSubmitted()) {
$order->delete();
}
}
}
}
return true;
}