Who here has done PHP shopping carts before?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Phil Powell

    Who here has done PHP shopping carts before?

    I need a back-to-basics shopping cart tutorial in PHP/mySQL. I thought I
    had it down and I failed, as usual. Here is what I mapped out as a spec:

    3) initial work on bestilling.php to contain the following plan:

    1) Cookie: 'nordicnet_best illing' to contain unique, random 16-char string
    2) Table: nnet_produkt_be stilling to contain ordering information bundled
    by
    unique bestilling_id (16-char string)
    a) produkt_id
    b) farge_id
    c) storrelse_id
    d) quantity ordered
    e) bestilling_id
    f) nordicnet_regis tration_number
    3) *PROPOSAL* To make cookie a timed cookie - if user does not check out in
    X hours
    the cookie will be deleted
    4) *PROPOSAL* CRON-based PHP script to systemically wipe out any stray rows
    in
    nnet_produkt_be stilling that have not yet been checked out
    5) Idea plan for bestilling:
    a) User will order produkt in vis_varegruppen .php
    b) bestilling.php will do server-side checking of produkt, farge,
    storrelse
    and quantity based upon entry in nnet_produkt_fa rge_storrelse_a ssoc
    c) bestilling.php will then check if $_COOKIE['nordicnet_best illing']
    already exists (meaning you have an order # - or, a cart ('bestill')
    d) If you have a cart then check if there is already a row in
    nnet_produkt_be stilling with same produkt_id/farge_id/storrelse_id with
    your
    matching bestilling_id
    e) If so then increase quantity ordered by the quantity you ordered and
    check
    quantity totals against nnet_produkt_fa rge_storrelse_a ssoc
    f) If NOT then add new row with produkt_id, farge_id, storrelse_id and
    quantity with your bestilling_id and registration number
    g) -- If you do NOT have a cart (no cookie) then generate a new cart
    (bestilling)
    id into a cookie
    h) If other people ordered the same item be sure to check their quantities
    ordered against yours and what is in stock before proceeding

    So far this is what happens:

    1) I enter products into the cart
    2) If I delete items from the cart, they can be deleted; if I delete all
    items from my cart, the cart cookie is deleted, I think.
    3) I try to re-enter the same item into the cart, it inserts into the db w/
    a NULL value for 'nnet_user_best illing_id' which is
    the cart id (which it's not supposed to do) and browser-side logic
    fails, you get the wrong screen and all kinds of garbage I cannot even go
    into because it's in Norwegian

    I have tried for nearly 24 hours to build a cart and I can't seem to get it
    done. I really need some help.

    Phil


  • RG

    #2
    Re: Who here has done PHP shopping carts before?


    "Phil Powell" <soazine@erols. com> wrote in message
    news:tuQdb.2344 1$sp2.13791@lak eread04...[color=blue]
    > I need a back-to-basics shopping cart tutorial in PHP/mySQL. I thought I
    > had it down and I failed, as usual. Here is what I mapped out as a spec:
    >
    > 3) initial work on bestilling.php to contain the following plan:
    >
    > 1) Cookie: 'nordicnet_best illing' to contain unique, random 16-char[/color]
    string[color=blue]
    > 2) Table: nnet_produkt_be stilling to contain ordering information bundled
    > by
    > unique bestilling_id (16-char string)
    > a) produkt_id
    > b) farge_id
    > c) storrelse_id
    > d) quantity ordered
    > e) bestilling_id
    > f) nordicnet_regis tration_number
    > 3) *PROPOSAL* To make cookie a timed cookie - if user does not check out[/color]
    in[color=blue]
    > X hours
    > the cookie will be deleted
    > 4) *PROPOSAL* CRON-based PHP script to systemically wipe out any stray[/color]
    rows[color=blue]
    > in
    > nnet_produkt_be stilling that have not yet been checked out
    > 5) Idea plan for bestilling:
    > a) User will order produkt in vis_varegruppen .php
    > b) bestilling.php will do server-side checking of produkt, farge,
    > storrelse
    > and quantity based upon entry in nnet_produkt_fa rge_storrelse_a ssoc
    > c) bestilling.php will then check if $_COOKIE['nordicnet_best illing']
    > already exists (meaning you have an order # - or, a cart ('bestill')
    > d) If you have a cart then check if there is already a row in
    > nnet_produkt_be stilling with same produkt_id/farge_id/storrelse_id[/color]
    with[color=blue]
    > your
    > matching bestilling_id
    > e) If so then increase quantity ordered by the quantity you ordered and
    > check
    > quantity totals against nnet_produkt_fa rge_storrelse_a ssoc
    > f) If NOT then add new row with produkt_id, farge_id, storrelse_id and
    > quantity with your bestilling_id and registration number
    > g) -- If you do NOT have a cart (no cookie) then generate a new cart
    > (bestilling)
    > id into a cookie
    > h) If other people ordered the same item be sure to check their[/color]
    quantities[color=blue]
    > ordered against yours and what is in stock before proceeding
    >
    > So far this is what happens:
    >
    > 1) I enter products into the cart
    > 2) If I delete items from the cart, they can be deleted; if I delete all
    > items from my cart, the cart cookie is deleted, I think.
    > 3) I try to re-enter the same item into the cart, it inserts into the db[/color]
    w/[color=blue]
    > a NULL value for 'nnet_user_best illing_id' which is
    > the cart id (which it's not supposed to do) and browser-side logic
    > fails, you get the wrong screen and all kinds of garbage I cannot even go
    > into because it's in Norwegian
    >
    > I have tried for nearly 24 hours to build a cart and I can't seem to get[/color]
    it[color=blue]
    > done. I really need some help.
    >
    > Phil
    >
    >[/color]



    RG


    Comment

    • Phester

      #3
      Re: Who here has done PHP shopping carts before?

      Phil Powell wrote:
      [color=blue]
      > I need a back-to-basics shopping cart tutorial in PHP/mySQL. I thought I
      > had it down and I failed, as usual. Here is what I mapped out as a spec:
      >[/color]
      ....[color=blue]
      >
      > I have tried for nearly 24 hours to build a cart and I can't seem to get it
      > done. I really need some help.
      >
      > Phil
      >[/color]

      The book PHP and MySQL Web Development by Luke Welling and Laura Thomson
      contains a shopping cart example.

      There are two editions. I have the first edition and it's pretty good. I
      haven't built a shopping cart. I used the book for other things. I've
      found that the code has a few errors and there were application design
      decisions I wouldn't have chosen. So the learning experience will likely
      include finding and fixing some errors, and I wouldn't uncritically
      accept all of their architecture advice.

      That said, it's a popular and well-written book.

      Also, there have got to be some Free shopping cart implementations out
      there. Have you tried sourceforge and stuff?

      Phester

      Comment

      • Ed Clarke

        #4
        Re: Who here has done PHP shopping carts before?

        In article <FM4eb.25941$dk 4.803234@typhoo n.sonic.net>, Phester wrote:[color=blue]
        > Phil Powell wrote:
        >[color=green]
        >> I need a back-to-basics shopping cart tutorial in PHP/mySQL. I thought I
        >> had it down and I failed, as usual. Here is what I mapped out as a spec:[/color][/color]
        [color=blue]
        >
        > Also, there have got to be some Free shopping cart implementations out
        > there. Have you tried sourceforge and stuff?[/color]

        osCommerce works very well.

        Comment

        Working...