The construction of a webshop in a modern web programming language

A webshop is an online store where visitors to a page can add products to a cart from a virtual shop and then order them.

A modern webshop is built on two parts, a database like MySQL containing data about the products offered on the shop and a webshop built with a web scripting language for example PHP or ASP.

Let’s begin with the database. In this simple example we only have a couple of tables.

Products is the table containing the different products offered in the store. Each product has its own row in the table. Customers is the table containing information about the customer that is needed to be filled in before ordering is possible.

The shop consists of a single page listing the products from the database. When a customer click on one of the products he is forwarded to a page showing the content of his cart and at the same time he added the product he clicked on to the cart.

What happened here is that each product from the database is listed with its unique ID on the shop page. When a product is clicked, the ID of the clicked product is sent to the page showing the content of the cart. The ID of the product that was clicked is then added to a session variable.

It is possible to send values to another page by hidden forms, however a session can also hold multiple values if defined as an array. So if the visitor to the webshop decides to add another product to his cart the session variable holding the previous product will grow and hold two ID numbers, the numbers of the products the visitor clicked on.

By listing every value that the session array contains it is possible to build a database query that can fetch data from the database about the chosen products, and that is how the cart page is built. If the session array is empty we simply inform the visitor that his shopping cart has no products in it.

So what happens then?

When the customer is happy with the products chosen he can then decide to register details about him in a simple form and then he submits his order by clicking on a submit button. Usually an email is directly sent out to the customer containing information about what products where ordered, how much the total sum of purchased products are and contact information.

There are off course many other possible solutions to designing a webshop and this is only a simple tutorial to give ideas of how a webshop could be built.

I should also mention that there is quite a lot of open-source webshop projects around that are very capable and updated constantly so generally it is not needed to invest time in creating a personal webshop system.

Leave a Reply