Shopping cart using array no database. and use of MVC model

Hello guys I’m a newbie in PHP and have an assignment due in the afternoon.
Actually i have to create a store that use a session array to retrieve data input in a form, and display it . But the shopping cart has to be built with MVC.
So here is a little details of the assignement:
in the first place we have only a navbar that appears where there is two link ( both are dropdowns menu): Order and Product
When you click on ORDER the dropdown menu appears and you can read “Create” and “List” .
When you click on PRODUCT the dropdown menu appears and you can read “Create”.

When you click on " Create" from the PRODUCT 's DROPDOWN you are redirect to a new page. On this new page there is a form where you can input the reference, name, price and quantity of the product you want to add and there is a save button too.
When you click on save the informations are save in a array stored in data.php. Naturally before they get stored the information input have to check if they are valid first.

When you click on " Create" from theORDER 's DROPDOWN, there is a form with two buttons that appears in the same page where you can input information about your order. And when you click on “ADD”, a table appear in which you can read the order you entered . when you click on “Save”, the informations are save in a array “product” stored in data.php.

When you click on " List" from the ORDER 's DROPDOWN you are redirect to a new page. On this new page there is a table where you can see the list of your order the reference, name, price and quantity of the product you want to add and there is a save button too.
And in each row there is a Details button. When you click on it an other table appears where you can see the elements ordered in that day and the Total

And i need help to know how to start this MVC model in the best way possible. All help appreciated and thanks for everything.

This bit doesn’t make a lot of sense to me - any array that you create and populate inside any of these PHP modules will be lost the moment the PHP module finishes execution. As you briefly touched on, surely you’ll need to then commit the data either to a database, or to some other kind of persistent storage such as session variables.

None of it sounds terribly onerous, just time-consuming. I would probably say you should first handle storing products, and once you have that cracked, the order / shopping cart will be relatively simple.

Can’t help with MVC stuff I’m afraid, it’s not something I’ve ever read up on though I do keep meaning to. And, of course, someone with knowledge of MVC might well negate everything I’ve said above.

That may or may not be possible, depending on which afternoon it is due. :slight_smile:

my bad it will be stored in session variable

1 Like

Your deadline has probably passed but maybe you could do us a favor and copy/paste in your instructor’s definition of MVC? The thing is, there are several dozen (perhaps hundreds) of different definitions of MVC. Be curious to see what is being taught.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.