Somebody could help me with this script for shopping?

Discussion in 'Programming/Scripts' started by rutame, Sep 30, 2008.

  1. rutame

    rutame Member

    hello,
    I need make a script for online store. I have this, but i need that add the prices of items and subtotal.
    PHP:
    <?php

    session_start
    ();

    session_register('itemsEnCesta');

    $item=$_POST['item'];

    $cantidad=$_POST['cantidad'];

    $itemsEnCesta=$_SESSION['itemsEnCesta'];



    if (
    $item){

       if (!isset(
    $itemsEnCesta)){

          
    $itemsEnCesta[$item]=$cantidad;

       }else{

          foreach(
    $itemsEnCesta as $k => $v){

             if (
    $item==$k){

             
    $itemsEnCesta[$k]+=$cantidad;

             
    $encontrado=1;

             }

          }

          if (!
    $encontrado$itemsEnCesta[$item]=$cantidad;

       }

    }

    $_SESSION['itemsEnCesta']=$itemsEnCesta;

    ?>

    <!--

    <html>

    <body>

    <tt>

    <form action="<?=$PHP_SELF."?".$SID?>" method="post">

    Dime el producto <input type="text" name="item" size="20"><br>

    Cuantas unidades <input type="text" name="cantidad" size="20"><br>

    <input type="submit" value="Añadir a la cesta"><br>

    </form> 

    -->

    <?

    if (isset($itemsEnCesta)){

       echo
    'El contenido de la cesta de la compra es:<br>';

       foreach(
    $itemsEnCesta as $k => $v){

          echo 
    'Artículo: '.$k.' ud: '.$v.'<br>';

       }

    }

    ?>
    Or if somebody know some tutorial for make a good shopping basket i will be so much gratefull.

    Thank you

    (sorry for my bad english ;-)
     
    Last edited: Sep 30, 2008
  2. falko

    falko Super Moderator ISPConfig Developer

  3. rutame

    rutame Member

    Thank you very much Falko
     

Share This Page