<b id="jfjof"><tbody id="jfjof"></tbody></b>
<u id="jfjof"><bdo id="jfjof"></bdo></u>
<b id="jfjof"><tbody id="jfjof"><sup id="jfjof"></sup></tbody></b>
      <u id="jfjof"></u>

        <video id="jfjof"><ins id="jfjof"></ins></video>

      1. .CN 三亞資訊 生活散文
        用戶名:    密碼:   注冊
          工行 中行 建行 交行 農行 郵政銀行   百度翻譯        京東 微博 網易 新浪 百度        163郵箱 QQ郵箱     
        首頁> 電腦雜記
        PHP購物車類
        2023-03-12 13:21    1786次

        /*****************************************************************************/
        /*                                                                           */
        /* file type:      包含文件,建議后綴為.inc    */
        /*                                                                           */
        /* file name:      cart.inc                                   */
        /*                                                                           */
        /* Description:    定義一個購車類                  */
        /*                                                                           */
        /* Func list :     class cart                                 */
        /*                                                                           */
        /* author :        bigeagle                                   */
        /*                                                                           */
        /*                                                                           */
        /*****************************************************************************/
         
        //定義本文件常量
        define("_CART_INC_" , "exists") ;
         
        /*購物車類*/
        class TCart
        {
         
          var $SortCount;            //商品種類數
          var $TotalCost;            //商品總價值
         
          var $Id;                   //每類商品的ID(數組)
          var $Name;                 //每類商品的名稱(數組)
          var $Price;                //每類商品的價格(數組)
          var $Discount;             //商品的折扣(數組)
          var $GoodPrice ;           //商品的優惠價格(數組)
          var $Count;                //每類商品的件數(數組)
          var $MaxCount ;            //商品限量(數組)
         
          //******構造函數
          function TCart()
          {
           $this->SortCount=0;
         
           session_start(); //初始化一個session
           session_register('sId');
           session_register('sName');
           session_register('sPrice');
           session_register('sDiscount');
           session_register('sGoodPrice') ;
           session_register('sCount') ;
           session_register('sMaxCount') ;
         
           $this->Update();
           $this->Calculate();
          }
         
          //********私有,根據session的值更新類中相應數據
          function Update()
          {
            global $sId,$sName,$sPrice,$sCount,$sDiscount,$sMaxCount,$sGoodPrice;
         
           if(!isset($sId) or !isset($sName) or !isset($sPrice)
              or !isset($sDiscount) or !isset($sMaxCount)
              or !isset($sGoodPrice) or !isset($sCount)) return;
         
           $this->Id        =$sId;
           $this->Name      =$sName;
           $this->Price     =$sPrice;
           $this->Count     =$sCount;
           $this->Discount  = $sDiscount ;
           $this->GoodPrice = $sGoodPrice ;
           $this->MaxCount  = $sMaxCount ;
         
           //計算商品總數
           $this->SortCount=count($sId);
         
          }
         
          //********私有,根據新的數據計算每類商品的價值及全部商品的總價
          function Calculate()
          {
           for($i=0;$i<$this->SortCount;$i++)
           {
             /*計算每件商品的價值,如果折扣是0 ,則為優惠價格*/
             $GiftPrice = ($this->Discount[$i] == 0 ? $this->GoodPrice :
                           ceil($this->Price[$i] * $this->Discount[$i])/100 );
             $this->TotalCost += $GiftPrice * $this->Count[$i] ;
           }
          }
         
          //**************以下為接口函數
         
          //*** 加一件商品
          // 判斷是否藍中已有,如有,加count,否則加一個新商品
          //首先都是改session的值,然后再調用update() and calculate()來更新成員變量
          function Add($a_ID , $a_Name , $a_Price , $a_Discount ,
                       $a_GoodPrice , $a_MaxCount , $a_Count)
          {
           global $sId , $sName , $sCount , $sPrice , $sDiscount ,
                  $sGoodPrice , $sMaxCount ;
         
           $k=count($sId);
           for ($i=0; $i<$k; $i++)
           { //先找一下是否已經加入了這種商品
             if($sId[$i]==$a_ID)
             {
              $sCount[$i] += $a_Count ;
              break;
             }
           }
           if($i >= $k)
           { //沒有則加一個新商品種類
            $sId[]        = $a_ID;
            $sName[]      = $a_Name;
            $sPrice[]     = $a_Price;
            $sCount[]     = $a_Count;
            $sGoodPrice[] = $a_GoodPrice ;
            $sDiscount[]  = $a_Discount ;
            $sMaxCount[]  = $a_MaxCount ;
           }
         
           $this->Update(); //更新一下類的成員數據
           $this->Calculate();
          }
         
          //移去一件商品
          function Remove($a_ID)
          {
           global $sId , $sName , $sCount , $sPrice , $sDiscount ,
                  $sGoodPrice , $sMaxCount ;
         
           $k = count($sId);
           for($i=0; $i < $k; $i++)
           {
             if($sId[$i] == $a_ID)
             {
               $sCount[$i] = 0 ;
               break;
             }
           }
         
           $this->Update();
           $this->Calculate();
          }
         
          //改變商品的個數
          function ModifyCount($a_i,$a_Count)
          {
           global $sCount;
         
           $sCount[$a_i] = $a_Count ;
           $this->Update();
           $this->Calculate();
          }
         
          /***************************
          清空所有的商品
          *****************************/
          function RemoveAll()
          {
           session_unregister('sId');
           session_unregister('sName');
           session_unregister('sPrice');
           session_unregister('sDiscount');
           session_unregister('sGoodPrice') ;
           session_unregister('sCount') ;
           session_unregister('sMaxCount') ;
           $this->SortCount = 0 ;
           $this->TotalCost = 0 ;
          }
         
          //是否某件商品已在藍內,參數為此商品的ID
          function Exists($a_ID)
          {
           for($i=0; $i<$this->SortCount; $i++)
           {
             if($this->Id[$i]==$a_ID) return TRUE;
           }
           return FALSE;
          }
         
          //某件商品在藍內的位置
          function IndexOf($a_ID)
          {
           for($i=0; $i<$this->SortCount; $i++)
           {
            if($this->Id[$i]==$id) return $i;
           }
           return 0;
          }
         
          //取一件商品的信息,主要的工作函數
          //返回一個關聯數組,
          function Item($i)
          {
           $Result[id]        = $this->Id[$i];
           $Result[name]      = $this->Name[$i];
           $Result[price]     = $this->Price[$i];
           $Result[count]     = $this->Count[$i];
           $Result[discount]  = $this->Discount[$i] ;
           $Result[goodprice] = $this->GoodPrice[$i] ;
           $Result[maxcount]  = $this->MaxCount[i] ;
           return $Result;
          }
         
          //取總的商品種類數
          function CartCount()
          {
           return $this->SortCount;
          }
         
          //取總的商品價值
          function GetTotalCost()
          {
           return $this->TotalCost;
          }

        ?>

      2. 網友評論僅供網友表達個人看法,并不表明三亞資訊同意其觀點或證實其描述:
      3. 驗證碼:
      4. Thank you
        大稠頂
        c++ 練習源碼,均測試通過
        常用C++學習網站
        爛頭嶺
        臺風“潭美”前的海邊
        八排山
        拉胡線
        玄碧湖
        黑白線稿“漂浮”在漁村的海天
        湛江北部灣農旅產業園
        山欽灣燕子洞
        大隆水庫
        肇慶冷翁頂
        有種邪惡:它不教人去愛,而是
        北京龍門澗
        惠州東莞兩頂
        林芝
        五郎嶂
        美麗沙海景
        椰味…
        蓋蒂博物館,私人收藏家的藏品
        三亞梅聯角頭灣星空
        國際奧運會視覺系統手冊欣賞
        Failed to load
        centos 7.9 gl
        海南最美海灣攝影
        __FILE__和$_SER
        CSS rem 和 em
        input 透明背景
         三亞便民
        ?? 賀師傅開鎖配汽車鑰匙店服
        ?? 海南省小客車保有量調控管
        ?? 三亞車輛年檢
        ?? 維修家庭普通電路,電話1
        ?? 對中醫推拿有多年工作經驗
        ?? 海南遷禧搬家貨運
        ?? 中國南方電網天涯供電所桶
        ?? 三亞中法供水有限公司
        ?? 電腦桌,保密柜,辦公家具
        ?? 泉源康體養生
         三亞新聞
        ?? 2023極光三亞露營節
        ?? 來,帶你去看不一樣的崖州
        ?? 三亞擬增設一條新公交線路
        ?? 三亞市新建商品房購房問答
        ?? 海南省住房和城鄉建設廳:
        ?? 崖州灣科技城一年一度“嗨
        ?? 海南省漁業監察總隊原政委
        ?? 全球最大潛水培訓機構PA
        ?? 習近平總書記重要講話思維
        ?? 黨的二十大報告全文
         三亞美食
        ?? 湖南老湘味(黃流店)20
        ?? 麻辣甲魚,香辣小龍蝦
        ?? 朋友相聚商務接待,江伴月
        ?? 【春余燒烤涮】主打綠色自
        ?? 大糖糖小吃明天正式推出正
        ??  祖傳秘制私房
        ?? 海掌柜海鮮
        ?? 漢密欣語(商品街店)
        ?? 小湖南家常菜館
        ?? 【牛太郎】 大型無煙
         三亞旅游
        ?? 三亞千古情景區
        ?? 三亞宋城旅游區5月推雙重
        ?? “永樂號”5月20日開啟
        ?? 海南最美的八個灣
        ?? 關于三亞
        ?? 紅藝人歌舞表演
        ?? 大小洞天
        ?? 美麗之冠
        ?? 三亞灣
        ?? 南田溫泉
         三亞酒店
        ?? 2023年三亞知名酒店推
        ?? 三亞浪漫海景公寓蘭?;▓@
        ?? 三亞灣HelloKitt
        ?? 三亞鳳凰島空中花園酒店
        ?? 三亞明申高爾夫度假酒店
        ?? 【臨春河路】三亞沐藍灣酒
        ?? 【三亞灣路】三亞海貝貝沙
        ?? 【河西路】東升快捷商務酒
        ?? 【團結路】一路向南旅行客
        ?? 【三亞灣路】椰林灘大酒店
        信息發布
        瓊粹美好
        遷禧搬家
        天涯家居
        林控軟件
        三亞資訊公眾號
        關于我們      版權聲明      服務條款      聯系我們      站點地圖      sitemaps    瓊ICP備05002060號       ©Copyright 2003 - 2024  www.pruningplants.com  三亞資訊
        Powered by 霄榮廣告 傳遞美好
        av天堂国产对白_国产91高潮操逼视频流白浆_超高清无码亚洲色图_国产在线无码免费播放视频