本文整理汇总了PHP中VirtueMartCart::emptyCartValues方法的典型用法代码示例。如果您正苦于以下问题:PHP VirtueMartCart::emptyCartValues方法的具体用法?PHP VirtueMartCart::emptyCartValues怎么用?PHP VirtueMartCart::emptyCartValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VirtueMartCart
的用法示例。
在下文中一共展示了VirtueMartCart::emptyCartValues方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: emptyCartFromStorageSession
function emptyCartFromStorageSession ($session_id, $order_number) {
$conf = JFactory::getConfig ();
$handler = $conf->get ('session_handler', 'none');
$config['session_name'] = 'site';
$name = Japplication::getHash ($config['session_name']);
$options['name'] = $name;
$sessionStorage = JSessionStorage::getInstance ($handler, $options);
// The session store MUST be registered.
$sessionStorage->register ();
// reads directly the session from the storage
$sessionStored = $sessionStorage->read ($session_id);
if (empty($sessionStored)) {
return;
}
$sessionStorageDecoded = self::session_decode ($sessionStored);
$vm_namespace = '__vm';
$cart_name = 'vmcart';
if (array_key_exists ($vm_namespace, $sessionStorageDecoded)) { // vm session is there
$vm_sessionStorage = $sessionStorageDecoded[$vm_namespace];
if (array_key_exists ($cart_name, $vm_sessionStorage)) { // vm cart session is there
$sessionStorageCart = unserialize ($vm_sessionStorage[$cart_name]);
// only empty the cart if the order number is still there. If not there, it means that the cart has already been emptied.
if ($sessionStorageCart->order_number == $order_number) {
if (!class_exists ('VirtueMartCart')) {
require(VMPATH_SITE . DS . 'helpers' . DS . 'cart.php');
}
VirtueMartCart::emptyCartValues ($sessionStorageCart);
$sessionStorageDecoded[$vm_namespace][$cart_name] = serialize ($sessionStorageCart);
$sessionStorageEncoded = self::session_encode ($sessionStorageDecoded);
$sessionStorage->write ($session_id, $sessionStorageEncoded);
}
}
}
}