help with this

Discussion in 'Coding Help' started by louie, Feb 23, 2006.

  1. louie

    louie New Member

    trying to compare 2 arrays and based on that increment the qty in the shopping cart or add a new product.

    the first one is sc_pid which is equal to the productid querystring

    the second one is sc_pdid = to productdetailsid if the product has attributes as color, size, etc.

    It adds to the cart (based on session array), but i can not get it to incremetn the qty once is already in the cart.
     
  2. 9barJoe

    9barJoe New Member

    whats this function add_item_to_cart()
     
  3. louie

    louie New Member

    is the function tha actually add the item to the session
     
  4. louie

    louie New Member

    after more then 24 hours of work i managed to do it.
     
  5. 9barJoe

    9barJoe New Member

    well, thats what its all about.

    sorry pal, I would have liked to have had a look, but you know its murder looking into someone elses head , & pretty well snowed under at the mo' too.

    rock on.
     
  6. louie

    louie New Member

    If i had to do that in ASP, i could have it done in 30 min, but being new to PHP, it took me 24 hours after reading and more reading and Google, and php forums and lots of cigarettes + coffee, and ....

    I managed in the end which is the joy of the job anyway. I love challenge.
     
  7. evilhomer

    evilhomer New Member

    So are you going to share the solution with us Louie ?? :)
     
  8. louie

    louie New Member

    the solution was to create the

    function add_item_to_cart($id,$pdid,$quantity) {
    $cart_id = $id.$pdid; //this the line that got me mixed up - was looking into the wrong direction
    //echo $cart_id;
    //die();
    // set cookie and store value in session
    setstp();
    session_regenerate_id(TRUE);
    $_SESSION["cart"][$cart_id][0] = $id; //$item["productid"];
    $_SESSION["cart"][$cart_id][1] = $quantity;//$quantity
    $_SESSION["cart"][$cart_id][2] = $pdid; //$productdetailid
    header ("location:viewcart.php");//redirect after product added to cart
    //}
    }
     

Share This Page