
Originally Posted by
mc12345678
Whatever you choose. Let me say this with a little "tough love"... To insert a new order, you *DO NOT* need to know the order_id that is to be inserted when creating a new order...
You insert the data (without it including an order_id) and *then* ask what the order_id has become...
Session data... doesn't matter where you are in the system, having that session data variable set allows use/reuse of existing code that handles everything you need.
Building/rebuilding a cart? Of COURSE! You're incorporating the act of making a purchase on your Zen Cart store...
As far as locking all the tables or whatever, the only order table that really matters and the only time it matters for the most part is the orders table at the point of making an insert to that one table... Once the unnumbered data is inserted which then gets a number assigned, all other related orders tables get similar additions to reference that order_id.
Personally, I think it would be more work, time and effort to "take the short-cut" than it would to do a simple search through the order class perhaps on '$_SESSION', identify all of the unique parameters and really should only need to concern oneself with the create-like methods... then considering that data, compare to the data that you are receiving from your other direction and line the two up... the order class can handle not receiving something, but also need to be sure that as a user of the store that you are going to get out of this process what you want/need... for example, the shipping, payment, and normal home address information... right now, there doesn't appear to be a consideration of ensuring that the data is "uniquely" captured in the database. Meaning if person X places their first order, on their next order if they use the same addresses will the addresses be looked up and referenced or will they just be added to the person's account.
Are these purchasers gaining access to your Zen Cart store by making a purchase through the route you are implementing? Do they already have an account? If they do have an account, what verification is being done to ensure that the purchase they are making elsewhere (to be tracked here) should be associated with the data they have in the store? E.g. What authentication has been performed to relate the purchase made at this other shopping location with the person(s) in the shopping cart?
Again, you can choose what information you're not going to store in the database about an order, but you'll want to also understand what impact that has on order/data retrieval for you and for the customer(s).
And again whatever you do... stop trying to determine the value of something that automatically determines its value on its own... Let me see if I can think of an example...
Ok, perhaps obscure, but think of it this way, the order_id is the position in a race or marathon. Whoever appears at the end of the race is given a number associated to "how they did" in the race. Once they pass the finish line that number is assigned, but they had a lot to do to get to that finish line. Some may have taken easy paths, some harder, but in the end, they were given the number at which they finished (along with their time) rather than them "appearing" out of the blue and claiming a number... the process of performing the insert to the database is what assigns that number associated with finishing the race... that's also why you'll see in some places in the forum where it is said the first one to checkout wins... if you have limited quantity of a product, you don't want to oversell (taken care of in a way in the process)...
Anyways, hope you get the point..
Bookmarks