UK Pound Question Mark – HUH?

Changing host is a simple thing – I’m not going to go into great detail about where to find a host, name server changes or any of that.

I have found that moving an osCommerce site can sometimes be problematic – not least because of database issues and the sheer number of files that osCommerce contains. If you have 1000 products, that’s an extra 1000 (or more likely 2000) images to move as well!

Every time that I have moved an osCommerce store recently, I’ve found that the UK pound sign is replaced by a question mark in the database. This means that all prices show for example ?45.99 instead of £45.99 – also any and all orders that were paid for in pounds, now show the problem question mark instead 🙁

I’ve hunted Google and see lots of this problem – it appears to be MySQL related. No matter, it’s easy to fix in osCommerce (let’s assume you have your database/store up and running on the new host and you now need to fix those pesky £ ? errors)…

Step 1: Fixing the Shop Prices

Go to your Admin Area and then Localization > Currencies. Select UK Pounds and press edit. Change the ? to a £ and press update.

Step 2: Fixing all the existing orders

Hopefully you have PHPMyAdmin as part of your hosting package, it comes as standard with cPanel and Plesk. Run this SQL Command:

UPDATE `orders_total` SET `text` = REPLACE(`text`, "?", "£");

That’s all there is too it. Your shop is now fixed 😀

Really Sexy osCommerce Shop

Check out this osCommerce Shop.  I think this might be the nicest design I have ever seen done with osCommerce.  It does have a couple little cosmetic things that could be done to make it nic, but overall, for design, I think it’s excellent.
www.bboheme.com

What do you think?  Does your site come anywhere close to that in terms of design, layout and presentation?

Gift Vouchers RC1 and RC2

STOP PRESS: This contribution is now updated to Version 5 and has all sorts of cool extras. Please see the latest post about this.

Offering Gift Vouchers/Discounts is an excellent way to make sales, particularly on products where margins are high. A good example of this is “digital products” where (more than likely) margin is probably 100% of the sale amount.

By offering a 50% or more Discount Coupon, vendor is still making a good amount and the buyer has a bargain.

new client required the ability to offer Gift Vouchers and Discounts on the latest version of osCommerce which is called “RC1”. After having a hunt through the Contributions area yesterday, I could not find anything that was suitable in terms of;

  • usable on RC1
  • easy to use for “not web savvy” person
  • coded cleanly

So, I went back to the drawing board and coded my own – based on some work I did years ago. With just a few lines of code I’ve now got a really nice Gift Vouchers package suitable for the latest version of osCommerce.

It’s usable with RC1 and RC2 – I do have a MS2 version somewhere also. Anyone who wants it, please comment below and I will make time to turn it into a freely available contribution.

Added Screenshot showing Sort Orders (that work for me):

Paypal payment but no order

Dani asks;

I use oscmmerce to sell downloadable stuff like ebooks and software, i’m finding that i get lots of paypal payments without an order so I have to contact the person to find out what they ordered. Maybe half of all my paypal payments don’t have orders and i dont know how to fix this. Please help

Dani – this is a problem that is not just localised to you. The standard osCommerce Paypal payment method just sends your customer to paypal to pay. Once they’ve paid they are expected to click the “return to merchant” link. If they don’t click the link, then the order is NOT written to your database at all!

It’s easy to fix! Simply install Paypal IPN (Instant Payment Notification) – this is an “upgraded” version of the Paypal Payment method, which sends a signal back from Paypal to your store, which then writes the order to the database. So whether or not your customer presses “return to merchant”, you’ll receive the order.

If you are running a very old version of osCommerce, you might not be able to use the IPN version – in this case, probably the best you can do is to put a message on the “checkout confimation” screen saying something like “IMPORTANT: You have selected to pay via Paypal. Please make sure that after paying at paypal, you press the “Return To Merchant” Link. Thank You!”.

You can enwrap this in a PHP “if” to only show if the selected payment method is Paypal; if ($payment_modules->selected_module == “paypal”) – this small piece of code will onlyshow your message if the selected payment method is Paypal.

I hope this helps!

As an aside, I also sell lots of digital products, like scripts, ebooks, templates etc – I wanted to point you at www.diycovers.com – for selling digital goods, a good product image can easily increase the number of buyers by a good 10 to 20% in my experience. Even if you are selling products that you have sourced elsewhere that come with a pre-made graphic, it’s always wise to try and differentiate yourself from all the other people who are selling the same thing.

PWA & STS – Merging osCommerce Contributions

Joey asks;

I saw your admin contribution and went to your website. I am having an issue {&} if you can help that would be great.

I made a nice shop but I am new to php and can’t figure out how to merge {PWA and STS}…THANKS!

Where do I start? 😉

PWA (Purchase Without Account) is a totally un-necessary contribution that adds no value to the average osCommerce shop in any way, shape or form. What you need to do is think about how a customer perceives your site and move on from there. Within the official forum there is a very long thread started over 5 years ago by myself, which is ongoing – search for “Customer Login Routines”. My suggestions is as follows;

  1. Rename parts of the checkout procedure so that they are less “in your face”. Eg, chenge “create account” to “your details”.
  2. When starting the checkout, start on “your details” NOT “login”
  3. Remove the password input boxes from the “create account” page. Add a checkbox saying “remember my details” instead.
  4. Create a random password for EVERY customer.
  5. IF thy checked the “remember me” checkbox, then send an email with the password. If they did not, then don’t send that email.
  6. Sanitize the rest of the checkout procedure, by removing some of the unnecessary pages.

If I can find some time, I will make an optimised checkout that does exactly this.

Simple Template System – the ability to design an osCommerce store by amending one file, rather than 30 or 40. This is even more un-needed in the average osCommerce Store.

It’s a pointless contribution that serves only to make your learning of PHP and osCommerce almost NIL. You say that you are new to PHP, and yet you want to use STS to design your site – meaning that you’ll never get to experience the “joy” that working with core code brings to you. You can only learn by getting your hands dirty and you simply cannot do that with STS.

If you already have STS installed, you’ve already stumbled across another real problem that STS brings to you – it’s harder to add contributions – and as only “newbies” and “lazy designers” use STS, it’s almost impossible to find good help.

Also, it adds more layers of code to an already over-coded piece of software – it makes sites load slower – it’s an all round mistake to use it.

Suggestion: Remove STS. Go back to standard osCommerce. Take the time out to learn at least some of the code within osCommerce. You’ll then be able to add Contributions easily.

osc-designing.gifDid you realize that I don’t like STS ? 😉 It’s the WORST templating layer presently available.

In V3 of osCommerce will be included it’s own templating engine, could be worth waiting for, but who knows when v3 will arrive?

For anyone reading this who wants to properly learn a bit about how to lay out an osCommerce site WITHOUT using some flaky templating system, you could do a lot worse than have a read of “Designing for osCommerce” available from www.oscbooks.com.

Update price based on attributes

Lilotanni asks;

When there are attributes assigned to a product and the attribute has money value to them. I wanted the base price to update automatically before the customer add it to cart.

As in if the base price is $200.00 and the attribute is -$10.00, when the customer chooses -$10.00, the displayed price would changed to $190.00 and so on if there are more attributes. I’ve been trying to do that and have gotten no where. Could you help me out?

Well, you need to use javascript.  I’d have had a go at using jQuery to update the price based on attributes, but even easier – there is already an existing contribution!

Check out http://www.oscommerce.com/community/contributions,1385 – I used the Attrib.Price Update 1.4 version and dropped in the product_info.php page directly.

It worked first time 🙂  Good luck with your osCommerce Store.

Sanitize the Best Sellers InfoBox

In this post, I’m going to show how to take out some of the usual osCommerce code and replace it with sanitised (clean), semantically correct code!

The fiel we are working on is /includes/boxes/best_sellers.php

Find this code:

$bestsellers_list = '<table border="0" width="100%" cellspacing="0" cellpadding="1">';
while ($best_sellers = tep_db_fetch_array($best_sellers_query)) {
$rows++;
$bestsellers_list .= '<tr><td class="infoBoxContents" valign="top">' . tep_row_number_format($rows) . '.</td><td class="infoBoxContents"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $best_sellers['products_id']) . '">' . $best_sellers['products_name'] . '</a></td></tr>';
}
$bestsellers_list .= '</table>';

And replace with

$bestsellers_list = '<ol>';
while ($best_sellers = tep_db_fetch_array($best_sellers_query)) {
$rows++;
$bestsellers_list .= '<li><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $best_sellers['products_id']) . '">' . $best_sellers['products_name'] . '</li>';
}
$bestsellers_list .= '</ol>';

What we have done here is strip out a table (always a good thing!) and replace it with a numbered list (ol).  osCommerce makes far too much use of tables to simply position items – which should be done using sematically correct HTML and CSS.

This little change in the best sellers box is the first step towards making osCommerce semantically correct!

Buy Button Only after Selecting Option

I started this modification maybe 5 years ago, but abandoned it when my customer decided he did not want it anymore. I noticed someone on the official osCommerce forum ask for the same thing so I dug out my old code and got it working again.

If that looks workable, I can carry on and clean up the code a bit more and hopefully get it to the stage of a ready contribution release.

osCommerce Online Merchant v2.2 RC2a Released

osCommerce Online Merchant v2.2 RC2a has been released to fix 2 bugs and replaces 2.2 RC2. The fixes are:

  • Use of PHP 5 only stripos() function during the database restoration routine on the Administration Tool. A compatibility function has been added to work on PHP <5 servers.
  • A PHP warning message is produced on requests where the session has not been started (ie, for search engine spiders). This is due to referencing the $_SESSION superglobal variable in tep_session_is_registered() which does not exist if the session has not started. A check for this variable has been added to this function.

The code changes for existing 2.2 RC2 installations can be seen here:

(Click on the green “Expand all” link to reveal the changes)

HOW TO: create osCommerce buttons in seconds

Creating buttons for osCommerce is a chore.  There is a “css button” contribution that I recall seeing years ago – but I thought it would be nicer to point out a really cool site that creates buttons for you – have a look at The osCommerce Button Generator.

Although the button sets are fairly limited – a nice touch is that you can play with the colours and text etc.  Once you are happy with your button set, you can download them and then upload to your osCommerce site.

Creating osCommerce Buttons could not be easier!