Mam gotowy skrypt ale nie umiem go wykorzystać. Nie znam się na php dobrze, jestem bardzo początkujący.
Chce zrobic koszyk sklepu internetowego, znalazłem darmowy skrypt ale nie umiem go "ożywić".
Czy ktoś może napisać jak się go używa ? przykladowo jak dodac coś do koszyka, jak go wyświetlić itd.
<?php
/*
Basket class for e-commerce purpose
Version : 0.5
Type:Class
Category:Shopping Carts
License: GNU General Public License
Description: This class provides methods for add, remove, update and remove all
items
from a basket. The basket works with a session cookie, saving the product ID
and quantity in an array for simple accesing it.
There's an example in this category... called "Basket example using basket class"
*/
class basket {
var $items;
var $empty;
function basket()
{
{
if ( gettype($this->items) == "array" ) {
$this->empty=false;
}
else
$this->empty=true;
}
else
$this->empty=true;
}
function additem($id, $name, $count, $prix)
{
if ($this->items[$id][1] > 0 )
{
$this->items[$id][1]+=$count;
}
else
{
$this->items[$id][0]=$name;
$this->items[$id][1]=$count;
$this->items[$id][2]=$prix;
}
$this->empty=false;
}
function removeitem($id) {
$tmp=""; // Don't forget to initialize !
if(!$this->empty) {
while(list
($x,$y)=each($this->items)){ if($x!=$id) $tmp[$x]=$y;
};
};
$this->items=$tmp; // Or this will have no effect !
if(count($this->items)==0
) $this->empty=true; }
function resetArray($basket)
{
}
function countItems($basket)
{
if(!$basket->empty)
{
while ( list
($x,$y,) = each($basket->items) ) {
$ant++;
}
}
return $ant;
}
function sumItems($basket)
{
if(!$basket->empty)
{
while ( list
($x,$y,) = each($basket->items) ) {
$ant = $ant + $y[1];
}
}
return $ant;
}
function printItems($b)
{
if(!$b->empty)
{
while ( list
($x,$y,) = each($b->items) ) {
echo "$x ".$y[0]." ".$y[1]." <a href="$PHP_SELF?action
=R
&id
=$x">Remove</a><br>"; }
}
}
function updateitem($id,$count){
$this->items[$id][1]=$count;
}
function removeall(){
$this->empty=true;
}
}
?>
</body>
</html>
z góry dziękuje. Jeśli ktoś wie gdzie można sciągnać bardziej opisowy koszyk, wraż z plikami prosze o linka.
Ten post edytował jebus_maksimus 9.11.2005, 12:30:31