本文整理汇总了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;
}