Currencies as Icons in 2.3.x

Almost exactly 5 years ago I posted about using icons for currency selection. The question still comes up fairly regularly in the osCommerce forum.

So, here’s how to do it in 2.3.x – you’re going to end up with something like this:

20130325_1

You need to make a “currency” icon for each currency that you have. In a standard installation of osCommerce, this is EURO’s [ EUR ] and US Dollars [ USD ]. Save them into the /images/icons/ directory as .png files like so; EUR.png USD.png

Next up open up /includes/modules/boxes/bm_currencies.php

Step 1: create a variable holder

$currencies_string = NULL;

this line of code needs to be placed in the execute() function, right underneath the line that starts global $PHP_SELF …

Step 2: create the variable

Here we need to loop through the available currencies and output them as an image. Code; http://pastebin.com/6D8ewzsn

This should be added underneath this line of code: reset($currencies->currencies);

Step 3: Change the $data to output the $currencies_string

http://pastebin.com/iSu4tVDB

Done. Refresh your page and you should see your currencies box as images. Of course, I could make this into a better addon allowing you to associate an image with a currency from within the admin area, but that’s for another day if someone wants it badly enough.

In action

Latest osCommerce 2.3.3 Theme – Penny

This theme changes around 10 core osCommerce files so is easy to install even onthe most modified of sites. Have a look at the demo.

It is a 1 column design, so there is lots of available space on every page for promoting your products. It has a horizontal menu (with dropdowns), along with a much nicer footer area. Of course, the “new products” module is also updated.

The cost of this template? Just £16 (approx $25), and you could even get it for free by purchasing the “design oscommerce” ebook. If you would like to see my other templates I’ve recently built head over to choices page.

Nice and easy modification for a beer

A person searching for a way to ensure unique data came across this post which I made for a client a couple of years ago.

Within 20 minutes, that new client had paypal’d me a couple of beers, I had installed the modification, tested it and tweaked it a little ready for him to use. And this is something that he had been trying to find for over 6 months!

Developers; that is the exact point of keeping every single piece of code you ever write. If someone comes to you in the future you can dig it out and re-use.

Grouping together products for easy purchasing

Imagine for example that you owned a gift shop running osCommerce, and your gifts are in categories…fairly straighforward shop setup, right?

Now imagine that it is a month or so away from Valentines day, and you want to make a new page in your shop on which you will add some products from “this” category and some from “that” category and some from “another” category. How would you do that?

You could simply create a new category in your shop called “Valentines Gifts” and duplicate/copy the chosen products into it. That would work, wouldn’t it?

How about this for an idea…a system where the shop owner can;

1. make new pages via admin (eg; Valentines, Mothers Day, Fathers Day etc), including title, description and image
2. assign products to one or more of these new pages
3. have each new pages show ALL of the products assigned to it in one display – each product showing “image”, “price”, “quantity input”, “attributes”
4. have one overall BUY button for the whole page

Any products where the quantity input box is greater than 0, get added to the cart in one shot. So, if the page has 10 products, and the buyer wanted 5 of them, they would update the quantity to “1” for each of the 5, and press the buy button. All 5 get added to the cart, at the correct quantity, and with the chosen attributes.

What have I described? A “multi product add to cart” page that can be configured to showcase products based on events throughout the year. Wouldn’t it be an awesome add to any osCommerce site?

Now go further and say that the shopowner decided he wanted to only show the assigned products as part of the page, and have no “product_info.php” page for the particular assigned product. This way he could create a page that contained a “range” of buyable products, where the only way to purchase is by looking at the whole set of products in the range, rather than each product individually on product_info.php – an example of this might be something like a beginners fish aquarium where the buyer can say “I want 2 moollys, 2 angelfish, 0 black sharks, 5 loaches, 20 tetra, 3 packs of fishfood, 0 rainbowfish” and not have to visit the product_info for each! Wouldn’t that make the system even more awesome?

Video In Action

This video shows how to add a new page, assign products to the page(s). Also shows the “multiple buy” facility on the shop selection page. Let me know what you think ?

Customers Personal Page

Imagine if you will owning an osCommerce shop that is quite large, and giving customers the ability to “save” products to a special page thereby making it very easy for them to return and order something they found at your site. I suppose it is a bit like a “private wishlist”.

Imagine no more as this now exists for the 2.3.x branch of osCommerce. With a few lines of code I was able to make the following changes;

1. Add a button on the product_info.php page that allows a customer to “add” or “remove” a product to their personal page. Also a button that directly links to their personal page.

Note that the “add” button only shows if the product is not already saved to the personal page. And similar for the “remove” button, this only shows if the product is saved already in the personal page.

2. New page (I call this the “personal page”). This lists all the added products, and gives the ability to “remove” the product from the page or to “add to cart”.

The personal page is only available to logged in customers, and each customer can fill this with the products they love, or buy again and again etc. In this way each customer can use it as a personal reminder or wishlist.

Video of it in action

What we have here is the beginnings of a very solid public wishlist as there presently is no good wishlist system in osCommerce. With some extra coding this code foundation could be extended to allow customers to have multiple wishlists (eg, birthday, wedding, xmas and so on), and to allow other users to purchase items from the wishlist to be delivered to the lucky recipient. Perhaps in the future this foundation can be built upon to allow something that’s sorely needed in osCommerce.

Simple Pre Order System

One of my long standing clients needed a solution that allows customer to purchase “out of stock” products, and writes a prominent message telling them that their order will be dispatched when the product is back in stock.

Customer came up with the idea of some sort of flag based on products_stock (which is the correct way to do things). But what happens when the product is back in stock – the flagged message would disappear.

I spent 10 minutes thinking on this and decided to utilise the order_status_history feature. Why not set up a new order_status called “Pre Order” and write a message here that shows which products in the order are out of stock. This message would automatically in the account_history and in the admin/orders pages.

I then set out to make the code as quickly as I could to test out the idea, and it seems to work very well whilst keeping code changes to an absolute minimum.

In the Shop Side (account_history_info)

This status happens automatically for any product with a quantity of zero or less in stock. This is done on a per product basis, so the message only lists those products in the order that are problematic for delivery. This message is also repeated in the “thank you for your purchase” email as well.

All in all, a nice little modification that allows the customer to see exactly why they might have a delay in receiving their items, and allows the shopowner to receive fewer emails from customers wondering why they have not yet received their order.

osCommerce Reboot

It’s been a long time coming but osCommerce (the brand) has been rebooted.

Now that the website and forum have been overhauled, code work can begin again on the next three releases in the osCommerce portfolio;

  1. v2.3.4 – a final update in the 2.3 branch bringing a lot of bug fixes and some extra functionality
  2. v2.4 – a new release bringing the 2.3 branch closer to the 3.0 branch. A “halfway house” if you will.
  3. v3 and forwards – the main product of osCommerce for the coming years.

Good times ahead for osCommerce, and for the users of osCommerce.

Hopefully the bad and disastrous times that the osCommerce brand has suffered over the past 5 or 6 years can be repaired by the new emphasis on quality products and quality customer service. Only time will tell.

Individual Shipping Per Product Per Zone

Approached recently by a potential customer who needs to set up a system for charging postage on a per product basis, per geographic zone. This needs to work as a “extra cost” on top of the usual shipping cost. Think in terms of an awkward to send product where you might want to charge $10 extra on top of the usual shipping fee. I’ll illustrate this with an example…

Step 1: Set up a couple of zones (for shipping purposes)
Although this says “tax zones” they can be used for shipping geographically.

Step 2: Edit (or create) a product
On this page we have extra input box asking for the shipping price per zone.

This defaults to zero, in here you can insert different price per zone. In the example, I’ll make the fee 5 for UK and 10 for Europe. I press “Save” to update the details of the product.

Step 3: Set up your Shipping Method(s)

For this example I’ll use the easiest (to look at) shipping module which is “flat rate”. I’ve set the fee to 2.50 flat fee for all orders.

Making an Order

If I now place into my cart a product that has NO extra cost set up, the shipping module will return 2.50 as the shipping cost.

Now if I also add a product that I have placed an extra cost (Unreal Tournament in this example), the shipping should show a total of 7.50 (which is 2.50 flat fee + UK extra cost of 5).

Hopefully, you’ll have read between the lines and understand that I could just as easily have created a new shipping module to only read the value of the extra cost parameter (per zone). In this way, I can set shipping prices per product and not have to have it react as a “surcharge” on top of an existing shipping module (as shown in this example).

Conclusion

Hopefully you can see that osCommerce is fairly easy to modify if you work out what you need to do in advance, understand how osCommerce hangs together and then stick to the project at hand.

For this example, the main files modified are admin/categories.php and the order_class file. The rest is simple arithmetic.

Shipping from Ireland EIRE to Ireland Northern – what a pain

I have a customer who owns a shop based in Eire where the postage cost to Northern Ireland (part of the UK) is substantially less expensive than post to the mainland UK. This presents quite a difficulty with getting shipping rates that are spot on, as the UK is England, Scotland, Wales and NI (there is no separated regions for shipping).

In effect, if Northern Ireland had it’s own ISO code things would be simple. To get around this, I set up my own “user defined” ISO code for Northern Ireland and added it to the countries list as “United Kingdom (NI)”. Downside of this approach is that the person creating the new account must select UKNI and not UK as their country. Not really a deal breaker, I think. So, now, the shopowner can separate NI from the UK quite easily, by using the new ISO code “QN” in the zones.php module.

The customer then also needs the ability to have the zones module work on order_total, not weight, and also the ability to insert % costs as well as $£ costs.

All in all, quite a straightforward project.

And then, a spanner in the works

I thought…what about already existing customers in NI, who (because they joined before the new fake UKNI country) still have shipping addresses linked to the UK. As soon as they log back in to order, they will get the more expensive UK shipping prices. Fortunately, there is a way around this also…all postcodes in Northern Ireland start with “BT”, so I need to come up with a piece of SQL to run in phpmyadmin that says; if (country == UK) and (first two letters of postcode == BT) update country to QN

That probably won’t make much sense as it is pseudo-code, all it does is transfer customers shipping addresses from the UK to UKNI, which means they get the proper shipping prices from this point forward.

Thinking Forward

This approach could also possibly be used for shipping to places such as Highlands and Islands, Channel Islands, IOM and so on. Just set up a fake ISO code for each and perhaps put a message on the create_account page to remind customers to choose their correct “country”…

Going back to the problem of the user selecting UKNI rather than UK, this can be accomplished using a line of javascript as we know that ALL postcodes in NI start with BT we can read that value from the postcode input box and update the country dropdown immediately. Video;

It would be very simple to also show a message or such to say we have “pre selected” the country to further aid the user.

Reorder the same

In osCommerce there is native functionality that allows the person to reorder on a product by product basis – it’s the bm_order_history infobox. It pretty much lists the last few products ordered and has a clickable link which either adds the product to the shopping_cart, or goes to the product_information page to allow to select the product options.

I’ve had a plan to write a “let me re-order the exact same again” script, and after having chatted with Matt last night I set out to make it a reality. And so I present to you my effort at a re-ordering script.

Step 1. Add a new button at the account_history page.

Step 2. Make some new code in the shopping cart to grab the orders products, and insert them into the shopping cart.

Notice that the inserted product(s) include the options/attributes if applicable. Now the buyer is ready to continue shopping or checkout.

Video in Action

If you need something similar, please feel free to get in touch by email.

How about something similar, yet completely off the wall ?

Take for example a regular client who decides she really loves a few products she bought from you, but does not want to re-order the whole same order? In this case, why not present all the products purchased from previous orders the client made. Then allow the customer to tick the products to re-order?

And of course, work the re-ordering mechanism into the bm_order_history box to replace the “1 by 1” functionality!