当前位置: 首页>>代码示例>>PHP>>正文


PHP comquick2cartHelper::guestCartId方法代码示例

本文整理汇总了PHP中comquick2cartHelper::guestCartId方法的典型用法代码示例。如果您正苦于以下问题:PHP comquick2cartHelper::guestCartId方法的具体用法?PHP comquick2cartHelper::guestCartId怎么用?PHP comquick2cartHelper::guestCartId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在comquick2cartHelper的用法示例。


在下文中一共展示了comquick2cartHelper::guestCartId方法的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;
             }
         }
     }
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:80,代码来源:qtc_sys.php


注:本文中的comquick2cartHelper::guestCartId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。