本文整理汇总了PHP中order::setCartCookie方法的典型用法代码示例。如果您正苦于以下问题:PHP order::setCartCookie方法的具体用法?PHP order::setCartCookie怎么用?PHP order::setCartCookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类order
的用法示例。
在下文中一共展示了order::setCartCookie方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUserCart
static function getUserCart()
{
global $db, $user, $router;
$sessAr = expSession::get('verify_shopper');
// initialize this users cart if they have ecomm installed.
$active = $db->selectValue('modstate', 'active', 'module="storeController"');
if (!expModules::controllerExists('cart') || empty($active)) {
// if ecomm is turned off, no cart.
return null;
} else {
if (isset($router->params['controller']) && $router->params['controller'] == 'order' && ($router->params['action'] == 'verifyReturnShopper' || $router->params['action'] == 'verifyAndRestoreCart' || $router->params['action'] == 'clearCart') && (!isset($sessAr['validated']) || $sessAr['validated'] != true)) {
return new order();
} else {
// if ecomm is turned off, no cart.
//$active = ;
if (empty($active)) {
return null;
}
$order = new order();
//initialize a new order object to use the find function from.
$ticket = expSession::getTicketString();
//get this users session ticket. this is how we track anonymous users.
// grab the origional referrer from the session table so that we can transfer it into the cart where it will be used for reporting purposes
// sessions are temporary so we can't report on the referrer in the session table itsef because it may not be there
// and we can't just get the referrer ar this point becaues the user likely navigated the site a bit and we want the origional referring site
$orig_referrer = $db->selectValue('sessionticket', 'referrer', "`ticket`='" . $ticket . "'");
//see if we have a LIVE and ACTIVE session w/ cart and grab it if so
$sessioncart = $order->find('first', "invoice_id='' AND sessionticket_ticket='" . $ticket . "'");
//check to see if the user is logged in, and if so grab their existing cart
if (!empty($user) && $user->isLoggedIn()) {
$usercart = $order->find('first', "invoice_id='' AND user_id=" . $user->id);
}
//eDebug($sessioncart);
//eDebug($usercart);
//enter here if we have NO ACTIVE SESSION CART -OR- We're awaiting a potential cart retore
if (empty($sessioncart->id) || $sessAr['awaiting_choice'] == true) {
if (empty($usercart->id)) {
// no SESSION cart was found and user is not logged in...
//let's see if they have a cart_id cookie set and we'll snag that if so
//they won't have any user data, since they are "logged in" once they get to
//checkout, so all we're really doing here is populating a cart for return
//shoppers
$cookie_cart_id = isset($_COOKIE['cid']) ? $_COOKIE['cid'] : 0;
//eDebug($cookie_cart_id,true);
if ($cookie_cart_id) {
$tmpCart = new order($cookie_cart_id);
if ($tmpCart->id != $cookie_cart_id) {
//cookie set, but we gots no cart in the DB so act as if we had no cookie
$cart = new order();
$cart->update(array("sessionticket_ticket" => $ticket, 'user_id' => $user->id, 'orig_referrer' => $orig_referrer, 'return_count' => $cart->setReturnCount($orig_referrer)));
order::setCartCookie($cart);
} else {
$u = new user($tmpCart->user_id);
//1) Was Not logged in
if (empty($tmpCart->user_id)) {
$cart = new order($cookie_cart_id);
//update the session ticket and return count
$cart->update(array('sessionticket_ticket' => $ticket, 'return_count' => $cart->setReturnCount($orig_referrer)));
order::setCartCookie($cart);
flash('message', gt('Welcome back'));
} else {
if (!empty($tmpCart->user_id)) {
//check for is admin first
if ($u->isActingAdmin() || $u->isAdmin()) {
//no need to restore anything.
$cart = new order();
$cart->update(array("sessionticket_ticket" => $ticket, 'user_id' => $user->id, 'orig_referrer' => $orig_referrer));
order::setCartCookie($cart);
} else {
if (!empty($tmpCart->user_id) && count($tmpCart->orderitem) == 0) {
//silently copy tracking data from old order and continue on
$cart = new order();
$cart->update(array("sessionticket_ticket" => $ticket, 'user_id' => $user->id, 'orig_referrer' => $orig_referrer, 'return_count' => $tmpCart->setReturnCount($orig_referrer)));
order::setCartCookie($cart);
flash('message', gt('Welcome back'));
} else {
if (!empty($tmpCart->user_id) && count($tmpCart->orderitem) > 0) {
//3) Was Logged in w/ NON-?real user? account
//eDebug(expUtil::right($u->username,10),true);
if ($u->isTempUser()) {
if (isset($sessAr['validated']) && $sessAr['validated']) {
//already went through validation and we're good to go
$cart = new order($sessAr['cid']);
//update the session ticket and return count
$cart->update(array('sessionticket_ticket' => $ticket, 'return_count' => $cart->mergeReturnCount($sessioncart->return_count), 'orig_referrer' => $sessioncart->orig_referrer));
order::setCartCookie($cart);
expSession::un_set('verify_shopper');
$user = new user($cart->user_id);
expSession::login($user);
//Update the last login timestamp for this user.
$user->updateLastLogin();
flash('message', gt('Welcome back') . ' ' . $sessAr['firstname'] . '! ' . gt('Your shopping cart has been restored - you may continue shopping or') . ' <a href="' . makelink(array("controller" => "cart", "action" => "checkout")) . '">checkout</a> ' . gt('at your convenience.'));
} else {
//send to verification? If user has elected to restore their cart
//eDebug($_SESSION);
if (isset($sessAr['awaiting_choice']) && $sessAr['awaiting_choice'] == true) {
/*expSession::set('verify_shopper',array('au'=>1,'orig_path'=>$router->current_url, 'firstname'=>$u->firstname, 'cid'=>$cookie_cart_id));
redirect_to(array("controller"=>"order",'action'=>'verifyReturnShopper'));
orderController::verifyReturnShopper();*/
//just give em the sessioncart
//.........这里部分代码省略.........
示例2: clearCart
public function clearCart()
{
global $order;
$sessAr = expSession::get('verify_shopper');
if (isset($sessAr)) {
order::setCartCookie($order);
$orig_path = $sessAr['orig_path'];
expSession::un_set('verify_shopper');
redirect_to($orig_path);
} else {
expHistory::back();
}
}