Reputation: 45
I'm writing a new customized e-commerce plugin. I want to publish it on WordPress plugins directory too. I've created a new custom post type for "Products" as long as a new CPT for "Orders". I have a "Shop Settings" page that contains some options too. I'v also created shortcodes to use in "Cart" and "Checkout" pages.
Now I'm in the middle of codding for "Add to Cart" section. I have a question, could you please help me? For processing Cart contents, I have three solutions:
Do you have a solution or help for me? If your answer is to choose DB solution, what about to define Cart as a CPT and keeping it's contents as meta?
Upvotes: 2
Views: 1507
Reputation: 3965
Database : By using the DB method, you will save the cart against a particular user id, but what about the users who are not logged in.
Session : By using sessions, cart will be empty after browser closed.
Cookie + Session : In my point of view, you need to use session+cookies. Save data in cookie and populate that data into session for further use. Also by using cookie, it will remain persists after the browser closed.
Upvotes: 2