Building a shopping cart
E-commerce is a huge business on the web. An integral part of most e-commerce sites is the use of a shopping cart system. This recipe will walk through how to use Laravel sessions to store items for sales and build a shopping cart.
Getting ready
For this recipe, we need a standard installation of Laravel, as well as a properly set up and configured MySQL database.
How to do it...
To complete this recipe, follow these given steps:
In our database, create a table and add some data with this SQL code:
CREATE TABLE items ( id int(10) unsigned NOT NULL AUTO_INCREMENT, name varchar(255) DEFAULT NULL, description text, price int(11) DEFAULT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB; INSERT INTO items VALUES ('1', 'Lamp', 'This is a Lamp.','14'); INSERT INTO items VALUES ('2', 'Desk', 'This is a Desk.','75'); INSERT INTO items VALUES ('3', 'Chair', 'This is a Chair.', '22'); INSERT INTO items VALUES ('4', 'Sofa', 'This is a Sofa/Couch.', ...