Location: PHPKode > scripts > IBK Cart > doc.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>IBK - Cart Class</title>
<style type="text/css">
<!--
body {
	font-family: Tahoma, Verdana, "Lucida Console";
	font-size: 12px;
}
body {
}
a:link {
	color: #333333;
	text-decoration: none;
}
a:visited {
	text-decoration: none;
	color: #333333;
}
a:hover {
	text-decoration: none;
	color: #333333;
}
a:active {
	text-decoration: none;
	color: #333333;
}
.style1 {font-size: 24px}

.btn {
	background-color:#CCCCCC;
	padding:3px 5px 3px 5px;
}
body,td,th {
	color: #333333;
}
.block{
	padding:5px;
	border:1px solid #333333;
	background:#E6EDD2;
	height:30px;
}
.style3 {padding: 5px; border: 1px solid #333333; background: #E6EDD2; height: 30px; font-weight: bold; }
.style4 {color: #0000FF}
.boderBot {
	border-bottom: 1px dotted rgb(102, 102, 102);
	}
-->
</style>
</head>

<body>
<table width="689" border="0" align="center" cellpadding="2" cellspacing="0" style="border:1px dotted #666666;">
  <tr>
    <td width="731"><div align="center"><span class="style1">ShopOnline.com </span></div></td>
  </tr>
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="30"><div align="center"><span class="block"><a href="index.php">Home</a></span> <span class="block"><a href="about.html">About</a></span> <span class="style3"><a href="#">Documentation</a></span></div></td>
      </tr>
      <tr>
        <td  style="border-bottom:1px dotted #666666;">&nbsp;</td>
      </tr>
      <tr>
        <td style="padding:5px;"><p align="center"><br />
		<strong><a href="#" class="block">INSTALLATION and USAGE</a></strong></p>
          <p>Unzip the pack  and copy the <strong>_IBKCart Folder</strong> to your server. This copy of the <strong>IBK-Class</strong> that you have has been packed with a demo Shop, which is run by the<strong> IBK-Cart</strong> class.<br />
            <br />
            After you have copied the folder to your server, open the file in the Config Directory, ie, <strong>Config_IBKCart/Config.php</strong> and edit it to siut your server settings, including your database username, hostname, the table that contains your product informatio and other settings.<br />
            <br />
            In your files, include the following lines in your between the head tag </p>
          <p>//This at the top of your page.. </p>
          <p><span class="style4"><strong>&lt;?php<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//Start the seeion.... <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!session_start()){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;session_start();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
                <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//Include the necessart files. <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;include('path-to-IBK-Cart/Config_IBKCart/Config.php');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;include('path-to-IBK-Cart/class_IBKCart/class.shoping.php');<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//Initialize the Cart..<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;	$Cart = new ShoppingCart();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$Cart-&gt;initCart($Config, $_SESSION['MyCart']);<br />
<br />
<br />
?&gt;</strong><br />
            <br />
              //These between your head tag..<br />
              <strong>&lt;head&gt;<br />
..<br />
.<br />
.<br />
&lt;script type=&quot;text/javascript&quot; src=&quot;path-to-IBK-Cart/js_IBKCart/ShoppingCart.js&quot;&gt;&lt;/script&gt;<br />
&lt;link href=&quot;path-to-IBK-Cart/CSS_IBKCart/Cart.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;<br />
.<br />
.&lt;/head&gt;</strong></span><strong><br />
              </strong><br />
            When you are done with this, then you are ready to start using <strong>IBK-Cart Class</strong>. <br />
          </p>
          <p>&nbsp;</p>
          <p align="center"><strong><a href="#" class="block">DEMO SHOP</a></strong></p>
          <p>To use the demo Shop packed with <strong>IBK-Cart</strong>, you must have edited the <strong>Config file</strong> in the <strong>Config directory, </strong>and uploaded the demo product table. <br />
            <br />
            In the db folder, you will find an sql file called tblprod.sql. You have to upload this file to to your database specified in the Config file, e.g through your database interface, e.g phpmyadmin, mysql console, e.t.c. <br />
            <br />
              Now, point your browser to <strong>http://www.yoursite.com/_IBKCart/index.php</strong> and you are good to go.  <br />
          Browse</p>
          <p>&nbsp;</p>
          <p align="center"><strong><a href="#" class="block">FUNCTIONS and METHODS</a> </strong></p>
          <p>&nbsp;</p>
          <p>1. Display <strong>IBK MiniCart.</strong><br />
            <br />  
            <br />  
            <img src="CSS_IBKCart/imgs/cartEmpty.gif" alt="" width="249" height="277" border="1" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="CSS_IBKCart/imgs/cartProd.gif" alt="" width="258" height="279" border="1" /><br />
          </p>
          <p>Include the following line exactly where you want to display the cart.. <br />
            <br />
              <strong>&nbsp;<span class="style4">&nbsp;&nbsp;&lt;div align=&quot;center&quot; id=&quot;IBKCart_Container&quot;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php if ($Cart-&gt;getCartItems() == 0){ <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;            $Cart-&gt;DisplayEmptyCart($a) ;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else{ <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo $Cart-&gt;ShowCartWtPrd();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ?&gt;<br />
&nbsp;&nbsp;&nbsp;&lt;/div&gt;</span></strong><br />
              <br />
            The Cart will automatically adjust itself from <strong>Empty</strong> to <strong>Non-Empty</strong>, as you add more product to your shopping cart. </p>
          <p>2. Display the IBK-CheckOut Cart.. </p>
          <p>&nbsp;</p>
          <p align="center"><img src="CSS_IBKCart/imgs/cartChkOut.gif" width="612" height="612" alt="" /></p>
          <p>Include the following line exactly where you want to display the cart.. <br />
            <br />
            <strong>&nbsp;<span class="style4">&nbsp;&nbsp;&lt;div align=&quot;center&quot; id=&quot;IBKCart_Container&quot;&gt;</span></strong><span class="style4"><br />
            <strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php if ($Cart-&gt;getCartItems() == 0){ <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $Cart-&gt;DisplayEmptyCart('ChkOut') ;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else{ <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo $Cart-&gt;DisplayCheckOut();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ?&gt;<br />
&lt;/div&gt;</strong></span></p>
          <table width="100%" border="0" cellspacing="3" cellpadding="3" style="border:1px dotted #666666;">
            <tr>
              <td width="35%"><strong>METHODS AND VALUES </strong></td>
              <td width="50%"><strong>USAGE.. </strong></td>
              <td width="15%"><strong>LANGUAGE.</strong></td>
            </tr>
            <tr valign="top">
              <td class="style4">$Cart-&gt;getCartItems()</td>
              <td>Return the total number of distinct items in your cart. </td>
              <td>PHP</td>
            </tr>
            <tr valign="top">
              <td colspan="3" class="boderBot">&nbsp;</td>
              </tr>
            <tr valign="top">
              <td class="style4">$Cart-&gt;cart</td>
              <td>This is your cart array. It is of the form<br />
                <strong>ItemId =&gt; ItemCount</strong> <br />
                <br />
                Please note that the Item id is the id of your individual products from your database that you have added to the cart. To view a detailed content, you should try to run <span class="style4"><strong>print_r($Cart-&gt;cart)</strong></span><strong>; </strong></td>
              <td>PHP</td>
            </tr>
            <tr valign="top">
              <td colspan="3" class="boderBot">&nbsp;</td>
              </tr>
            <tr valign="top">
              <td class="style4"> $Cart-&gt;toMoney($Amt])</td>
              <td>Formats the $Amt value in the currency format.. </td>
              <td>PHP</td>
            </tr>
            <tr valign="top">
              <td colspan="3" class="boderBot">&nbsp;</td>
              </tr>
            <tr valign="top">
              <td class="style4">$Cart-&gt;ShowCurSymbol()</td>
              <td>Displays the currency based on the value of <span class="style4">$Config['Cur']</span>.The default value, currency symbol is NGN Naira (<del>N</del>) </td>
              <td>PHP</td>
            </tr>
            <tr valign="top">
              <td colspan="3" class="boderBot">&nbsp;</td>
              </tr>
            <tr valign="top">
              <td class="style4">$Cart-&gt;EmptyCart()</td>
              <td>Empty the cart item.. </td>
              <td>PHP</td>
            </tr>
            <tr valign="top">
              <td class="style4">$Cart-&gt;initCart($Config, $CartArr)</td>
              <td>Initialize the Cart Object wit two variables.<br />
                $Config is an array of your configuration values from the Config file, and $CartArr is your SESSION Cart Array holder..e.g mine was<span class="style4"> $_SESSION['MyCart']</span>. </td>
              <td>PHP</td>
            </tr>
            <tr valign="top">
              <td colspan="3" class="boderBot">&nbsp;</td>
              </tr>
            <tr valign="top">
              <td class="style4">$Cart-&gt;totAmt</td>
              <td>This holds the total amount of money from all the items in your cart items.<br />
                Echo this property at any time to dsiplay the total amount of money the customer has to pay..</td>
              <td>PHP</td>
            </tr>
            <tr valign="top">
              <td colspan="3" class="boderBot">&nbsp;</td>
              </tr>
            <tr valign="top">
              <td class="style4">doCart('AddItem', '&lt;?php echo $PhnArr[$i][$Config['prodId']]; ?&gt;', 1, 'Small');&quot;</td>
              <td>Use this function to add item to the IBKCart. Usually added <span class="style4">onClick=&quot;doCart('toDo', 'ItemId', 'Qty', 'PageFrom'); </span><br />
                <br />
                toDo =&gt; <span class="style4">'AddItem', 'DelItem', 
 'EmptyCart','UpdCart'</span><br />
 <br />
 ItemId =&gt; <span class="style4">Pass the Id of the Item to add to the Cart.</span>.<br />
 <br />
 Qty =&gt; The Qty to add, by default is what you specified. In the demo, defaault is 1. If you add an item that has been added already, then the item qty will be increased by the default that you specified..<br />
 <br />
 PageFrom =&gt; <span class="style4">This is to identify where the function was called from.. Possible values are 'ChkOut', ''SomethingElse</span>'.<br />
 <br />
 Id thevalue is <span class="style4">'ChkOut'</span>, The system senses that the function was called from the Checkout page and display a detailed cart with update action possible for the cart items. Any other value will result in displaying the<strong> IBK MiniCart. </strong><br /></td>
              <td>JAVASCRIPT</td>
            </tr>
          </table>          
          <p><br />
            <br />
          </p></td>
        </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>
Return current item: IBK Cart