In this post, I’m going to show you how to add a new button into the shopping cart page that will allow your customers to remove all items from their shopping cart in just one click…
In standard osCommerce, each product has it’s own individual “remove” link – which is fine and works well. My idea is to remove the whole lot in one go…
It looks like this:
Step 1 – add the new button to the shopping cart page
All we need to do here is add a new button just like the existing “checkout” button in shopping_cart.php – but we make it different by using different parameters;
Explanation of parameters;
text – the text that the button shows, see step 2.
icon – the tiny icon that shows in the button, I’ll cover this in a future post, but you can see the available icons at the bottom of this page.
action – what the button does, see step 3
Step 2 – add the language define to the english language file
Should be completely self explanatory…
Step 3 – making the “action”
This is where we delve a little bit into the “engine” of osCommerce. Open up the file includes/application_top.php and find this line of code;
switch ($HTTP_GET_VARS[‘action’]) {
This is where we can set up the new action called “clear_cart”. Without going into too much depth, the action needs to do the following;
1. Clear the Cart
2. Redirect back to the shopping_cart.php page
3. Stop the script continuing by “breaking” it
To clear the cart, we can use the inbuilt function “remove_all” from the shopping cart class. To use it, we need a line of code like this; $cart->remove_all();
To redirect, we can use the inbuilt redirect function called “tep_redirect” – we just need to tell it where to redirect to.
To stop the script continuing to process, we use the php break command.
So the portion of new code looks like this;
And here it is in action;
Allowing customers to delete all their shopping cart is not good for business, what would be better would be the ability to change their quantities and have a single update button after all putting a 0 in the quantity is the same as removing but involves more action than just to remove.
Remember we are in the business of selling therefore we should make it easier to buy – one click checkout – less easy to not buy extra message when the customer empties their cart before checkout:
“You have just emptied your cart, did you really mean to miss out on a great product at our very special prices?”
Make sure that hitting return on their keyboard returns them to their original purchases…
“Allowing customers to delete all their shopping cart is not good for business”
I can not say I agree with this. After all, the customer must want, desire to buy whatever he spend money for. No way to force him.
Let’s take, as an example, an extreme situation, where it is impossible to remove anything from the cart again. Would this lead to more sales? I don’ think so
Also, having a series of pop up or inline warning messages, the type of you mention, does not add value to the shopping experience, I think it would be considered as annoying by many buyers, at least by me personally, but that’s maybe just my taste
There is always the red X on the top left of the browser window that empties automatically everything, leaving the store owner alone with a full cart maybe, but no money in the pocket
Have a nice Sunday all
Juls –
echo tep_draw_button(IMAGE_BUTTON_UPDATE, ‘refresh’);
Easy as 123.
I have to say that I am more with George on this – it’s all about giving the customer more choice and ease of use..
You should never give a customer a chance to say no, nor give them an option – laws of selling successfully (I didn’t write them (don’t particularly follow them either)).
It strikes me that if a customer has spent time browsing your store and ordering, they want to buy not get to the checkout and inadvertently click a link or button that empties their cart for them…
This is why I say a multi-update of the cart is more preferable
BTW your spam protection is beginning to get taxing – it’s getting into double figures π
I also have to go with let the user do what they want to…
I often have left a shopping procedure, either because i felt it was too complicated, or useless…
If you sell products that the user can find somewhere else, and the user finds your site troublesome, they will leave in search of a place that has the same products, but where they feel respected..
Why not let them choose.. If a user has added too many products int the shopping cart but only want to buy one of them, the you have lost the sale of that one product because you have made it too difficult to erase the rest..
“Why not let them choose.. If a user has added too many products int the shopping cart but only want to buy one of them, the you have lost the sale of that one product because you have made it too difficult to erase the rest..”
This is what I am saying Steph, the current 2.3 method enforces your customer to delete products one by one, Gary’s method allows them to delete the whole cart at once.
My method allows them to choose which product they want to delete and which product they want more of and one click to do everything at once…
Surely that is the best and easiest?
Oh… and if they should click the button by mistake then the cart stays as it is
Juls – the code I posted in my reply gives a button that does that…
“Juls β the code I posted in my reply gives a button that does that⦔
Just defending my case π