SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help creating a purchase count code

    I am currently trying to figure out if there is a way to create a code that will show on my website a purchase countdown. I would like to start with something like "100 small heart patches left" and then, as the patches are bought, for the number to automatically count down. I am using foxycart to make the transactions. Is it possible to come up with this coding?

  2. #2
    SitePoint Member
    Join Date
    Jul 2010
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey dsellers,

    I'm not familiar with foxycart, so I'm not sure how far it goes for an ecommerce site (from their site, they say they handle only the cart and checkout). Most ecommerce platforms have an "Inventory" or "Stock tracking" module where you can key your remaining stock level. You can try searching foxycart's documentation to see if they have something like that.

    If not, probably the only way you are going to have this stock remaining displayed is to

    (1) store this quantity in a database
    (2) read from db when you are displaying the item
    (3) verify that the stock is still available at various points in your checkout pages (not only adding to cart, but also before payment, etc - because the last one might be in 10 ppl's carts at one time.)
    (4) after a successful checkout and payment, do a callback function to update your inventory

    I'm sure there are other, more complex models for "locking up" the stock when its added to a cart and releasing it after a timeout period (more robust, and more work too)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •