當前位置: 首頁>>代碼示例>>PHP>>正文


PHP comquick2cartHelper::deleteCartItemRec方法代碼示例

本文整理匯總了PHP中comquick2cartHelper::deleteCartItemRec方法的典型用法代碼示例。如果您正苦於以下問題:PHP comquick2cartHelper::deleteCartItemRec方法的具體用法?PHP comquick2cartHelper::deleteCartItemRec怎麽用?PHP comquick2cartHelper::deleteCartItemRec使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在comquick2cartHelper的用法示例。


在下文中一共展示了comquick2cartHelper::deleteCartItemRec方法的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::deleteCartItemRec方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。