File: example.php

Recommend this page to a friend!
  Classes of Dirk Herling  >  sCart  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: An example use of the sCart class
Class: sCart
Shopping basket class
Author: By
Last change:
Date: 19 years ago
Size: 844 bytes
 

Contents

Class file image Download
<?php
     
include("sCart.php");
     
$cart = new sCart();

     
// register cart to session (optional)
      // session_start();
      // session_register("cart");

      // add a new product into the cart
     
$cart->add_item(123, "Productname", 1, 6.95, 16, array("other descriptions"));

     
// show all products from the cart
     
if($cart->show())
      {
          while(
$values = $cart->show_next_item())
          {
             
print_r($values);
          }
      }

     
// show sum of all products from the cart
     
if($values = $cart->sum())
      {
         
print_r($values);
      }

     
// update an product of the cart
     
$cart->update_item(123, 10);

     
// remove an product of the cart
     
$cart->remove_item(123);

     
// clear complete cart
     
$cart->clear();
?>

For more information send a message to info at phpclasses dot org.