I tend to keep the basket in the session then, when it comes to sending the order to the payment gateway I serialise the basket object and store it in a temp orders table. Upon return from the payment gateway, whether it's a positive or negative result, the data is pulled out of the temp orders table and deleted from there. If the order is approved, I store the order details in the db and serialize the transaction details into one field within the order table and serialised the basket into another column. I used to use WDDX but now use JSON.
By doing this, I only have one record that is stored permanently per order which is an "order record" which contains a full copy of the original basket and the transaction information as sent back from the payment gateway. The basket stores tax rates and costs of each item etc. so that when a basket is de-serialized, it shows the rate of tax as it was when the order was made. This is great in the UK as in the last couple of years, our VAT rate has gone from 17.5% to 15% to 17.5% and in January it's going up to 20% so for online e-commerce stores that have been going for a while, being able to store this sort of data for tax reasons is very important. Paul > -----Original Message----- > From: [email protected] [mailto:[email protected]] On > Behalf Of Peter Bell > Sent: Thursday, December 09, 2010 2:30 PM > To: [email protected] > Subject: Re: [CFCDEV] Order / Basket relationship > > I've been doing this ever since I started writing e-comm systems in the > 90's. I'm still not convinced I love the approach as for high volume > sites sharing the table between often updated carts and historic orders > isn't ideal. I think going forwards I'm gonna look at using a key-value > store for the baskets and a relational db for orders, but it's gonna > have to wait for a client with some kind of scaling requirements - or > maybe I'll write a sample as a demo for NoSQL presentations . . . > > On Dec 9, 2010, at 9:26 AM, Bob Silverberg wrote: > > > In the most recent system that I wrote that uses ORM and requires > > baskets/orders I just have one entity: order. It also serves as the > > basket. If there are properties that I only need for the basket, but > > I don't need to persist for the order then I make them non-persistent > > properties. > > > > This worked well for me, > > Bob > > > > On Thu, Dec 9, 2010 at 7:56 AM, John Whish > <[email protected]> wrote: > >> Hi, > >> > >> I've built an shopping cart using ORM and currently the user has a > >> basket which is persisted, when the user starts the checkout > process, > >> then an Order object is created and the Basket is associated to the > >> Order. This all works fine. > >> > >> The problem I have is that when the order completes, I clear the > >> Basket (which maps to the Baskets table) when the order completes > and > >> store the ordered items in a OrderLine object (which maps to the > >> Orderlines table). I do this because I want to keep the Basket table > >> nice and light and not concerned with historic data (passed orders). > >> The trouble with this is that I then have a 1 to 1 relationship > >> between an Order and a Basket (until the order completes) and also a > 1 > >> to 1 relationship to the OrderLine object (for completed orders). > >> > >> Is there a more elegant solution to this that I'm missing? > >> > >> Thanks. > >> > >> - John > >> > >> -- > >> You received this message because you are subscribed to the Google > Groups "CFCDev" group. > >> To post to this group, send email to [email protected]. > >> To unsubscribe from this group, send email to > [email protected]. > >> For more options, visit this group at > http://groups.google.com/group/cfcdev?hl=en. > >> > >> > > > > > > > > -- > > Bob Silverberg > > www.silverwareconsulting.com > > > > -- > > You received this message because you are subscribed to the Google > Groups "CFCDev" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > [email protected]. > > For more options, visit this group at > http://groups.google.com/group/cfcdev?hl=en. > > > > -- > You received this message because you are subscribed to the Google > Groups "CFCDev" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/cfcdev?hl=en. -- You received this message because you are subscribed to the Google Groups "CFCDev" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/cfcdev?hl=en.
