COMPUTERS by KRISS on 18 september 2015

ADDING A BASKET TO YOUR WEBSITE The proper phrasing I believe should be implementing a basket but I am not very good at this so I'll just skip the proper formula and go straight to the point.

This is not as hard as it looks! For those of you who are not already fluent in HTML, CSS, PHP and MySQL, no offense but the rest of this post is just going to be a mumble jumble of words.

Sure it is one big development in a website but you can rationalize it in the following categories :

1 - Displaying the catalog. 2- Adding items to the basket. 3- Identifying your customer. 4- Finalizing your order.

I will not speak about handling customer accounts because that is another kettle of fish and not necessary to having a working online shop.
If you are reading this, there is a good chance you are not Amazon or other giant web seller so keeping an online track of everything your customers did for the last few months might not be a priority.
Though I must admit a complete solution can always be useful.

In any case, you will have to work with php SESSIONS so you want to declare that at the top of every page of your website, and most likely, get the unique sessid variable for your customer. 1-Displaying the catalog

Well, simple as that, you need a MySQL table that lists your items, with a unique ID.
If you have several versions for an item, you can work with a second table linked by the item ID where you list for example, sizes or colors.Then you need a php script to display this table the way you want.
Again if your items have versions, javascript will help you refresh your page with the event OnChange that will ask php to grab the correct price change or color change inside the tables.

2-Adding items to the basket.

Again, nothing too complicated, a table that will contain the unique session ID of the person adding the items, everything you need regarding the item (this includes how many of them) and that's it.
A php script in form of a post that will add the item to the basket.
On the page that will get the variables you can script in a way that will discriminate wether the item already exist and then only add quantity or add the item if it's not in the table for the unique user's ID.

3-Identifying your customer

Once your customer has finished adding items to their basket, hopefully after many many items, they have to pay ! So you need to give them easy access to their basket wherever they are on your website.
For that reason, on most websites, there is a basket sign displaying the number of items in the cart for example (displaying the price might prevent your customer from adding too many items along the way - as a comparison, picture yourself in a supermarket with an automatic cart that displays the total price on the go in real time.
You would probably buy half as much goods in this supermarket).

So you need to have them log in but that implies a system of recognition by email and password (and in that case if the customer has lost their password, you're good to have another system to send them their lost password).
In one word, this is a bummer, more complicated and there is a way to avoid that !

Simply ask your customers to register with their email and postcode ! They will always remember their postcode even if they have moved since.
And besides, by simply giving them the option to update their contact details, they can change everything, including their first and last name if they want to and keep the same account as long as the email remains the same !

4-Finalizing your order

At last, finalizing the order is about having a last table that will summarize the content of the basket so that you can empty your basket table.
You then need to send them an email to recapitulate everything and direct them to your payment option.

If you need any help figuring out how to implement a cart solution for your business, don't hesitate to send me an email.



Be the first one to comment this post

Comment the general thread (or click another comment)

If you are made of flesh leave this the way it is


• web development
• writing
• translations
• proofreading
• illustrations
• photo edition




Prefered language





Prefered language