本文整理汇总了PHP中comquick2cartHelper::getcartidForuser方法的典型用法代码示例。如果您正苦于以下问题:PHP comquick2cartHelper::getcartidForuser方法的具体用法?PHP comquick2cartHelper::getcartidForuser怎么用?PHP comquick2cartHelper::getcartidForuser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类comquick2cartHelper
的用法示例。
在下文中一共展示了comquick2cartHelper::getcartidForuser方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onLoginUser
public function onLoginUser($user, $options)
{
$app = JFactory::getApplication();
if ($app->getName() != 'site') {
return;
}
if (!$this->_exits_q2c()) {
return;
}
$db = JFactory::getDBO();
$session = JFactory::getSession();
$path = JPATH_SITE . '/components/com_quick2cart/helper.php';
if (!class_exists('comquick2cartHelper')) {
JLoader::register('comquick2cartHelper', $path);
JLoader::load('comquick2cartHelper');
}
$comquick2cartHelper = new comquick2cartHelper();
$currentsession = $session->getId();
$old_sessionid = $session->get('old_sessionid');
$old_sessionid = $currentsession;
$user_id = intval(JUserHelper::getUserId($user['username']));
$oldcartid = $comquick2cartHelper->getcartidForuser($user_id);
//gives last cart id
$guestcart_id = $comquick2cartHelper->guestCartId($old_sessionid);
if ($oldcartid) {
if ($guestcart_id) {
/* condition no 11:: IF GUEST CART_id AND USER_CART_ID BOTH FOUND THEN delete rec with user_id*/
$query = "Select cart_id FROM #__kart_cart WHERE user_id='{$user_id}' ORDER BY last_updated DESC";
$db->setQuery($query);
$cart_ids = $db->loadColumn();
if (!empty($cart_ids)) {
$comquick2cartHelper->deleteCartItemRec($cart_ids);
}
$q = "DELETE FROM #__kart_cart WHERE user_id=" . $user_id;
//." And `session_id` !='".$old_sessionid."' ";
$db->setQuery($q);
$db->execute();
// update cartid from 0 to 1
$row = new stdClass();
$row->cart_id = $guestcart_id;
$row->session_id = $old_sessionid;
$row->user_id = $user_id;
//intval(JUserHelper::getUserId($user['username']));
$row->last_updated = date("Y-m-d H:i:s");
if (!$db->updateObject('#__kart_cart', $row, 'cart_id')) {
echo $db->stderr();
return false;
}
} else {
/* condition no 10::IF USER_CART_ID and GUST_CART_ID NOT FOUND THEN
delete all entry Except last*/
$query = "Select cart_id FROM #__kart_cart WHERE user_id='{$user_id}' ORDER BY last_updated DESC";
$db->setQuery($query);
$cart_ids = $db->loadColumn();
unset($cart_ids[0]);
if (!empty($cart_ids)) {
$comquick2cartHelper->deleteCartItemRec($cart_ids);
}
$q = "DELETE FROM #__kart_cart WHERE user_id=" . $user_id . " And `cart_id` !={$oldcartid} ";
// AND `session_id` !='".$old_sessionid."' ";
$db->setQuery($q);
$db->execute();
}
} else {
/* condition no 01:: IF USER_ID_CART NOT FOUND AND GUEST CART IS PRESENT THEN Update user id (0-> id)entry in cart table aginst oldsession*/
if ($guestcart_id) {
$row = new stdClass();
$row->cart_id = $guestcart_id;
$row->session_id = $old_sessionid;
$row->user_id = $user_id;
//intval(JUserHelper::getUserId($user['username']));
$row->last_updated = date("Y-m-d H:i:s");
//print"<pre>";print_r($row);
if (!$db->updateObject('#__kart_cart', $row, 'cart_id')) {
echo $db->stderr();
return false;
}
}
}
}