Get Order Status without logging in…

A nice idea by a client of mine is to have the ability for a customer to insert their order number and email address into a form, which then shows their “order status”;

And the information is presented, without a new page load;

This idea is something that I have not seen done before. It took a fair bit of coding effort, but the end result is quite good. The client in question has quite a modified site which allows “guest checkout”, where an account is not set up for a customer, this means that there is no way for the customer to see the status of the order (which is normally done by logging into the account and viewing the order history).

With this modification, all customers (whether they have an account or not) can view the status of their order…

In action;

A new look

I decided to open up the blog to carts other than osCommerce. I work quite a bit with other osCommerce forks such as Zen Cart and particularly osC Max – so why not be a bit more responsive to users of those. The main emphasis will still be osCommerce.

As I am opening up the blog for other carts, I thought I might as well give it a new look. My attempt is to make a move away from a blog and more into a blog/site hybrid. That’s why the front page is now more of a call to action page – over the coming days there might be more changes to the look/theme.

My idea is to keep on blogging as I have been, but also to put up some informational pages about the services I offer, the products I sell, client testimonials and so on. It’s time to get a bit more organised and time to make clubOSC a bit more professional!

Guest posts

I also want to start a series of guest posts from shopowners – who can talk about any aspect of their shop. And obviously link to their shop. If you run an ecommerce shop and you would like to make a guest post, please email me and we can go from there.

Got ideas, comments, suggestions

Feel free to let me know, by commenting here, or by emailing me. I’m open to any and all suggestions for the site.

Add Math Protection to contact_us.php

This morning I was contacted to see about adding a question to osCommerce just like I have on this blog – where I ask a math question…I was going to suggest using Google recaptcha service, but the client did not want that.

And so…

Adding a question such as “what is 3+5” cuts down on automated bots spamming the heck out of you. A good place to implement this in contact_us.php, and the code changes are very simple.

The basis of the change is to create two random numbers, and ask the person contacting you to insert the total into an input field. The field is then checked to see if the answer is correct. If it is correct, then the contact email is sent to the shop owner. If the answer is incorrect, a “fail” message appears.

Step 1. Add the language defines to the language file.

We need two new defines, one for the “question” and one for the response if the question is incorrect.

/includes/languages/english.php
(and any other languages you operate in your shop)

http://pastebin.com/Wz5LmjJ9

Step 2. Add the logic to the contact file.

Here we need to create two numbers, add them up and ask the question to the user. http://pastebin.com/L7zaX7Tr

And that is all there is to it. Try it out in your store if you wish.

Notes

In line 21 of the pastebin I used base64_encode to create a hidden “answer” variable which creates something to check the users answer against. In line 6 I decode it, and then in line 8 I check one against the other. I use base64 to “hide” the value of $a + $b from prying eyes.

My use of base64_encode and base64_decode is no more than that…if you are unsure of what I am doing in the code, I suggest to ask question to help yourself to understand more fully, or not use the code. The base64 code might (assuming you use “site monitor”) ring alarm bells. I guarantee that if you use my “math protection” code as is, there is nothing harmful in it.

Summary

A useful way to cut down on the spam that is sent via contact forms. You could also add this to any other form in a similar way (eg, create_account.php, tell_a_friend.php and so on).

JavaScript Off? Check your site…

Some people, myself included, browse websites with .js turned off. If I need to access a sites javascript features I can easily make an exception on a site by site basis.

What this means is that 90% of sites I visit do not work, or work but look awful. For example, visiting any blogspot blog simply gives a blank page, nice usability Google!

In osCommerce with .js turned off, the vast majority is usable, but some parts appear broken. Two examples;

1. The buttons.

As the look/theme of the button is powered by .js, they react as simple links.

2. The images module.

The multiple images gallery and resizing is powered by .js, so these also ruin the design of the layout.

There are more examples of problem area, but more or less, osCommerce is usable without the need for javascript.

In Magento (shopping cart software), they show a message somewhat like this:

You can see a similar message by visiting any of the shops listed on the Magento Showcase, and turning .js off in your browser.

Adding a similar message to osCommerce…

Step 1. Create an icon.

The icon should be .png format and about 30 x 30 pixels or something like that. Fairly small. Save it into /images/icons/ as filename: no-script.png

Step 2. Add the text for the message

Open up /includes/languages/english.php. Add the following code (open the page, then copy/paste): http://pastebin.com/K6kzqwWV

Repeat for all languages in your shop.

Step 3. Add the code to the header of your site

Open up /includes/template_top.php. Add the following (open the page, then copy/paste);

http://pastebin.com/RYXAgf9e

Step 4. Applying style to the message.

Open up stylesheet.css. Add the following (open the page, then copy/paste): http://pastebin.com/9w0sY8Jb

That is all.

If done correctly, you should see a message like this;

But remember – the message only shows if javascript is turned off in the browser.