Need Help with Shopping Cart

Discussion in 'PHP' started by malnomany, May 30, 2009.

  1. #1
    Hello all,
    I asked someone to create an order form for me where customers can choose from the items I supply and e-mail me their orders. he did create this www dot clothesmanufacture dot com but I have a problem with this code. when you click remove which is beside each item, it does remove the entry but when I add another item it gives me an empty entry and it miss the calculation. I am going to post the code so you will have a look at it, and if someone can edit it to get it work correctly, I will be really gratefull to him. and if not, is it possible for someone to write another code from the begining to make an order form like the one on the website ? a better code I mean that allow customers to remove any item they choose from the list. will be waiting for answers with patience. thanks in advance for everyone.

    here's the current code:

    <? 
    if($_POST['AddToCart'] && $_POST["ProductName"] ||  $_SESSION['CustomerOrder']){ 
    if(  $_POST["ProductName"] ){ 
        $Order = array();     
        $ShoppingSession = array(); 
         
        $IdProduct         = $_POST['IdProduct']; 
        $ProductName     = $_POST['ProductName']; 
        $Size             = $_POST['Size']; 
        $Quantity         = $_POST['Quantity']; 
        $ProductPrice     = ($_POST['ProductPrice']) ; 
         
        $Totalprice = ( $Quantity * $ProductPrice) ; 
        $OrderPrice = ( $_SESSION['OrderPrice'] + $Totalprice); 
        $_SESSION['OrderPrice'] = $OrderPrice; 
        $CustomerOrder  = $_SESSION['CustomerOrder'].'--'.$IdProduct.'|'.$ProductName.'|'.$Size.'|'.$Quantity.'|'.$ProductPrice.'|'.$Totalprice.'|'.$OrderPr  ice; 
        $CustomerOrder = trim($CustomerOrder,'--'); 
        $_SESSION['CustomerOrder'] = $CustomerOrder; 
    //    echo $CustomerOrder; 
        $CustomerOrderArray = split('--',$CustomerOrder); 
    }else{ 
         $CustomerOrder  = $_SESSION['CustomerOrder'] ; 
        $CustomerOrder = trim($CustomerOrder,'--'); 
         
         $CustomerOrderArray = split('--',$CustomerOrder); 
    }  
     if($_REQUEST['r']) // this is the code of the remove button which doesn't work 
     $OrderPrice = ( $_SESSION['OrderPrice'] -$toRemove);s  
        $toRemove = ($_REQUEST['productPrice'])*($_REQUEST['quantity']);  
        $CustomerOrderArray = split('--',$CustomerOrder); 
        $CustomerOrderArray[$_REQUEST['IdShopping']]=''; 
        $CustomerOrder = ''; 
        foreach($CustomerOrderArray as $ke=>$val){ 
            $CustomerOrder .= '--'.$val; 
             
        } 
        $_SESSION['CustomerOrder']=$CustomerOrder  ; 
        $CustomerOrder = str_replace('----','',$CustomerOrder);  
        $CustomerOrder = trim($CustomerOrder,'--'); 
        $CustomerOrderArray = split('--',$CustomerOrder); 
    }  
    if ( $CustomerOrder){ 
    ?> 
    PHP:

     
    malnomany, May 30, 2009 IP
  2. Sudoku-Master

    Sudoku-Master Peon

    Messages:
    54
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    is that right? you use the var $toRemove before you set a value for it?

    
     if($_REQUEST['r']) // this is the code of the remove button which doesn't work 
     $OrderPrice = ( $_SESSION['OrderPrice'] -$toRemove);s  
        $toRemove = ($_REQUEST['productPrice'])*($_REQUEST['quantity']);
    PHP:
     
    Sudoku-Master, May 30, 2009 IP
  3. malnomany

    malnomany Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I don't know as I am not really a php programmer, this is why I am asking for someone to help me to get this code work
     
    malnomany, May 30, 2009 IP