You can move the shopping cart to the database. Unless you have a very fast buying process or an extremely redundant environment, the session or cache probably will not be strong enough. Since they are not saved, you will also not have a direct method for analyzing purchase decisions, depletion, etc.
Depending on how often your inventory changes, you may only need to verify that the cart item is available at checkout. As a user, it would be very strange for me to see that the item simply βmagicallyβ disappeared from my cart or that the price changed. In my opinion, it would be better to directly call it.
Once again, the database would be an excellent solution, since you could track the state of an item when it was added to the cart against the current product definition.
If you must use the Session or Cache solution, then the proposed @VMAtm solution is valid.
Tim medora
source share