advice on placing items into cart and quantities

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

    #1

    advice on placing items into cart and quantities

    You have ordered one item and placed it into your cart. Let's say you
    ordered one small black t-shirt. Your cart will have the product_id,
    color_id and size_id for the small black t-shirt. The quantity of this item
    is, let's say 30. You have one in your cart, so how many are available:

    1) 29
    2) 30

    Now let's say that while I ordered one small black t-shirt, Sven ordered 1
    small black t-shirt, Anders ordered one black t-shirt, and Olov ordered one
    black t-shirt. If all four of us, at one time, are all ordering the same
    item and putting it into our carts, how many should there be available to
    us:

    1) 26
    2) 25
    3) 29
    4) 30

    This is where the contention comes in. The client wants it done "FIFO"
    (First In First Out) meaning that whoever gets it first will subtract the
    quantity - but I dispute that (coming from somewhat of a Java background)
    that since PHP doesn't so single-threading, that means that all four of us
    could order t-shirts, but the quantity has to reflect that all four of us
    are ordering (multi-threading).

    I dunno, help!

    Phil


  • RG

    #2
    Re: advice on placing items into cart and quantities


    "Phil Powell" <soazine@erols. com> wrote in message
    news:eF8eb.2567 2$sp2.7183@lake read04...[color=blue]
    > You have ordered one item and placed it into your cart. Let's say you
    > ordered one small black t-shirt. Your cart will have the product_id,
    > color_id and size_id for the small black t-shirt. The quantity of this[/color]
    item[color=blue]
    > is, let's say 30. You have one in your cart, so how many are available:
    >
    > 1) 29
    > 2) 30
    >
    > Now let's say that while I ordered one small black t-shirt, Sven ordered 1
    > small black t-shirt, Anders ordered one black t-shirt, and Olov ordered[/color]
    one[color=blue]
    > black t-shirt. If all four of us, at one time, are all ordering the same
    > item and putting it into our carts, how many should there be available to
    > us:
    >
    > 1) 26
    > 2) 25
    > 3) 29
    > 4) 30
    >
    > This is where the contention comes in. The client wants it done "FIFO"
    > (First In First Out) meaning that whoever gets it first will subtract the
    > quantity - but I dispute that (coming from somewhat of a Java background)
    > that since PHP doesn't so single-threading, that means that all four of us
    > could order t-shirts, but the quantity has to reflect that all four of us
    > are ordering (multi-threading).
    >
    > I dunno, help!
    >
    > Phil
    >
    >[/color]


    You gonna go round in circles here mate.
    What are the chances of multiple people buying the same item in a short
    period?
    WHat you should do is subtract from the qty when the trtansaction is
    complete.

    This is why you do not want to follow your current path:
    Scenario: I go to your shop and put your entire stock into my basket.
    This would stop any legit shopper from being able to put anythin in there
    basket.

    Just reduce qty when transaction is successful
    Hope this helps
    RG



    Comment

    • Andy Jeffries

      #3
      Re: advice on placing items into cart and quantities

      On Tue, 30 Sep 2003 01:37:25 -0400, Phil Powell wrote:[color=blue]
      > This is where the contention comes in. The client wants it done "FIFO"
      > (First In First Out) meaning that whoever gets it first will subtract the
      > quantity - but I dispute that (coming from somewhat of a Java background)
      > that since PHP doesn't so single-threading, that means that all four of us
      > could order t-shirts, but the quantity has to reflect that all four of us
      > are ordering (multi-threading).
      >
      > I dunno, help![/color]

      How about the quantity available is the stock quantity (in the product or
      stock table) minus the "in basket" quantity (from the basket table). That
      way the stock is available and allocated to people. When your baskets
      expire (as per your other post) the record that allocates them will be
      deleted and hence your stock will then be available for other people.

      This means that RG would have to keep doing this every time his basket
      expired. If you shorten your expiry time (I would say 24 hours is too
      long) it makes it very unfeasible to do what RG suggests (and if someone
      writes a script to hit your server every few hours you can block them).

      As some advice I would set baskets to expire after 1-2 hours of inactivity
      and have every page on your site update the basket time when hit. That
      way if the person is still actively looking around your site the basket
      expiry will be refreshed and if they leave it won't hang around for long.

      You could also give people the option to "Save my basket for later" which
      would then put the expiry date 10 years in the future. However, this
      opens you back up to RG's attack *.

      Most web customers are very quick to jump ship. If they find something
      they like they'll buy it. If they actually go to the effort to put it in
      their basket they will buy it there and then, unless something makes them
      leave the site - when they return virtually no customer would expect their
      basket to still be there (would you in a traditional shop?).

      And finally, in answer to your earlier post - yes I have "some" (<g>)
      experience of writing shopping basket systems.

      Cheers,


      Andy


      * Meaning the attack that RG suggested, not that RG will actually be
      attacking your server. :-)

      Comment

      • RG

        #4
        Re: advice on placing items into cart and quantities


        "Andy Jeffries" <news@andyjeffr ies.remove.co.u k> wrote in message
        news:pan.2003.0 9.30.09.02.42.5 79065@andyjeffr ies.remove.co.u k...[color=blue]
        > On Tue, 30 Sep 2003 01:37:25 -0400, Phil Powell wrote:[color=green]
        > > This is where the contention comes in. The client wants it done "FIFO"
        > > (First In First Out) meaning that whoever gets it first will subtract[/color][/color]
        the[color=blue][color=green]
        > > quantity - but I dispute that (coming from somewhat of a Java[/color][/color]
        background)[color=blue][color=green]
        > > that since PHP doesn't so single-threading, that means that all four of[/color][/color]
        us[color=blue][color=green]
        > > could order t-shirts, but the quantity has to reflect that all four of[/color][/color]
        us[color=blue][color=green]
        > > are ordering (multi-threading).
        > >
        > > I dunno, help![/color]
        >
        > How about the quantity available is the stock quantity (in the product or
        > stock table) minus the "in basket" quantity (from the basket table). That
        > way the stock is available and allocated to people. When your baskets
        > expire (as per your other post) the record that allocates them will be
        > deleted and hence your stock will then be available for other people.
        >
        > This means that RG would have to keep doing this every time his basket
        > expired. If you shorten your expiry time (I would say 24 hours is too
        > long) it makes it very unfeasible to do what RG suggests (and if someone
        > writes a script to hit your server every few hours you can block them).
        >
        > As some advice I would set baskets to expire after 1-2 hours of inactivity
        > and have every page on your site update the basket time when hit. That
        > way if the person is still actively looking around your site the basket
        > expiry will be refreshed and if they leave it won't hang around for long.
        >
        > You could also give people the option to "Save my basket for later" which
        > would then put the expiry date 10 years in the future. However, this
        > opens you back up to RG's attack *.
        >
        > Most web customers are very quick to jump ship. If they find something
        > they like they'll buy it. If they actually go to the effort to put it in
        > their basket they will buy it there and then, unless something makes them
        > leave the site - when they return virtually no customer would expect their
        > basket to still be there (would you in a traditional shop?).
        >
        > And finally, in answer to your earlier post - yes I have "some" (<g>)
        > experience of writing shopping basket systems.
        >
        > Cheers,
        >
        >
        > Andy
        >
        >
        > * Meaning the attack that RG suggested, not that RG will actually be
        > attacking your server. :-)[/color]

        You make me sound like a menace, I'm not, honestly ;P
        RG



        Comment

        • Andy Jeffries

          #5
          Re: advice on placing items into cart and quantities

          On Tue, 30 Sep 2003 10:25:17 +0100, RG wrote:[color=blue][color=green]
          >> * Meaning the attack that RG suggested, not that RG will actually be
          >> attacking your server. :-)[/color]
          >
          > You make me sound like a menace, I'm not, honestly ;P[/color]

          That's not what I heard over on alt.l33t.haxor2 ! :-)

          Cheers,


          Andy

          Comment

          • Phil Powell

            #6
            Re: advice on placing items into cart and quantities

            I go to the shop and put the entire stock into my basket, however, I might
            be doing this legitimately, meanwhile, I am going around in the shop buying
            other stuff. Another legit shopper goes in and purchases just ONE item.
            When I later on go to checkout with all 30 items, I of course will have a
            problem; I am purchasing 30 items but 29 are only in stock because someone
            else just bought one.

            That CAN actually happen, so then I would have to follow my current path. :(

            Phil

            "RG" <Me@NotTellingY a.com> wrote in message
            news:3f79401c$0 $65590$65c69314 @mercury.nildra m.net...[color=blue]
            >
            > "Phil Powell" <soazine@erols. com> wrote in message
            > news:eF8eb.2567 2$sp2.7183@lake read04...[color=green]
            > > You have ordered one item and placed it into your cart. Let's say you
            > > ordered one small black t-shirt. Your cart will have the product_id,
            > > color_id and size_id for the small black t-shirt. The quantity of this[/color]
            > item[color=green]
            > > is, let's say 30. You have one in your cart, so how many are available:
            > >
            > > 1) 29
            > > 2) 30
            > >
            > > Now let's say that while I ordered one small black t-shirt, Sven ordered[/color][/color]
            1[color=blue][color=green]
            > > small black t-shirt, Anders ordered one black t-shirt, and Olov ordered[/color]
            > one[color=green]
            > > black t-shirt. If all four of us, at one time, are all ordering the[/color][/color]
            same[color=blue][color=green]
            > > item and putting it into our carts, how many should there be available[/color][/color]
            to[color=blue][color=green]
            > > us:
            > >
            > > 1) 26
            > > 2) 25
            > > 3) 29
            > > 4) 30
            > >
            > > This is where the contention comes in. The client wants it done "FIFO"
            > > (First In First Out) meaning that whoever gets it first will subtract[/color][/color]
            the[color=blue][color=green]
            > > quantity - but I dispute that (coming from somewhat of a Java[/color][/color]
            background)[color=blue][color=green]
            > > that since PHP doesn't so single-threading, that means that all four of[/color][/color]
            us[color=blue][color=green]
            > > could order t-shirts, but the quantity has to reflect that all four of[/color][/color]
            us[color=blue][color=green]
            > > are ordering (multi-threading).
            > >
            > > I dunno, help!
            > >
            > > Phil
            > >
            > >[/color]
            >
            >
            > You gonna go round in circles here mate.
            > What are the chances of multiple people buying the same item in a short
            > period?
            > WHat you should do is subtract from the qty when the trtansaction is
            > complete.
            >
            > This is why you do not want to follow your current path:
            > Scenario: I go to your shop and put your entire stock into my basket.
            > This would stop any legit shopper from being able to put anythin in there
            > basket.
            >
            > Just reduce qty when transaction is successful
            > Hope this helps
            > RG
            >
            >
            >[/color]


            Comment

            • RG

              #7
              Re: advice on placing items into cart and quantities


              "Phil Powell" <soazine@erols. com> wrote in message
              news:WHdeb.2728 9$sp2.2015@lake read04...[color=blue]
              > I go to the shop and put the entire stock into my basket, however, I might
              > be doing this legitimately, meanwhile, I am going around in the shop[/color]
              buying[color=blue]
              > other stuff. Another legit shopper goes in and purchases just ONE item.
              > When I later on go to checkout with all 30 items, I of course will have a
              > problem; I am purchasing 30 items but 29 are only in stock because someone
              > else just bought one.
              >
              > That CAN actually happen, so then I would have to follow my current path.[/color]
              :([color=blue]
              >
              > Phil
              >[/color]

              What you need to do then is check that the qty ordered tallies up with the
              users basket at CHECKOUT.
              Tell the user that they can only have 29
              RG



              Comment

              • RG

                #8
                Re: advice on placing items into cart and quantities


                "RG" <Me@NotTellingY a.com> wrote in message
                news:3f798c32$0 $65594$65c69314 @mercury.nildra m.net...[color=blue]
                >
                > "Phil Powell" <soazine@erols. com> wrote in message
                > news:WHdeb.2728 9$sp2.2015@lake read04...[color=green]
                > > I go to the shop and put the entire stock into my basket, however, I[/color][/color]
                might[color=blue][color=green]
                > > be doing this legitimately, meanwhile, I am going around in the shop[/color]
                > buying[color=green]
                > > other stuff. Another legit shopper goes in and purchases just ONE item.
                > > When I later on go to checkout with all 30 items, I of course will have[/color][/color]
                a[color=blue][color=green]
                > > problem; I am purchasing 30 items but 29 are only in stock because[/color][/color]
                someone[color=blue][color=green]
                > > else just bought one.
                > >
                > > That CAN actually happen, so then I would have to follow my current[/color][/color]
                path.[color=blue]
                > :([color=green]
                > >
                > > Phil
                > >[/color][/color]


                Ignore previous post.

                At checkout, check that there is enough stock to cover the order. If there
                isn't tell the user.
                RG



                Comment

                Working...