Cupara
Well-known member
I'm not so good with session stuff so if anyone can give me some advice for using session to have a cart then adding items to that cart without inserting to a table in the database.
So far I have this:
Thanks in advance
So far I have this:
PHP:
public function actionCart()
{
$this->canonicalizeRequestUrl(
XenForo_Link::buildPublicLink('myshop/cart')
);
$cart_cached = XenForo_Model::create('XenForo_Model_DataRegistry')->get('cart');
$item = $this->_input->filterSingle('item_id', XenForo_Input::STRING);
$session = XenForo_Session::startPublicSession();
$cart = $cart_cached;
if (!$cart) {
$cartMessage = 'You have no items in your shopping cart.';
} else {
$items = explode(',',$cart);
$s = (count($items) > 1) ? 's':'';
$cartMessage = 'You have <a href="cart.php">'.count($items).' item'.$s.' in your shopping cart</a>';
}
$viewParams = array(
'onlineUsers' => $this->_getSessionActivityList(),
'cartMessage' => $cartMessage
);
return $this->responseView('MyShop_ViewPublic_Cart', 'myshop_cart', $viewParams);
}
Thanks in advance