Version 1.1 of Discount Coupons and Gift Vouchers for RC osCommerce

Just a quick post to let readers know that I have released version 1.1 of my Discount Coupons and Gift Vouchers contribution for RC releases of osCommerce.

This version fixes 1 bug in checkout_confirmation.php and includes a whole file that I forgot to include in the first version – checkout_process.php

http://addons.oscommerce.com/info/5743

For discussion/support, please see my original post about this.

HOW TO: make just 1 infobox a different style

There are lots of ways to make osCommerce look different. Here is 1 way to make 1 infoBox look different to the rest – it’s easy – and is done using a CSS (Cascading Style Sheet) “trick”…

Step 1: decide which infoBox to change

In this example, I’m going to change the look of the Categories infoBox. Open up the file /includes/boxes/categories.php and find the following line of code

<td>

Change this to:

<td id="categorybox">

Save this file and upload it.

clubosc1.gif

Step 2: Give it some style!

We know that the usual infoBox styling is controlled by three CSS entries;

  1. infoBoxHeading
  2. infoBoxContents
  3. infoBox

So, all we now need to do is use those to control the box we are changing, but we do it using a special CSS “trick”…open up stylesheet.css and scroll right to the very bottom of it. Add the following code;

#categorybox .infoBoxHeading { background: blue; color: yellow; }

Why did we add this code? Well, for starters you can see that the very first piece of code says #categorybox – you’ll remember that in Step 1, we gave this id to the Table Cell (td) that hold the Category Box.

The rest of the code is standard osCommerce style using the existing .infoBoxHeader style definition. In this example, I’ve made the background blue, and the font color yellow. We end up with this:

clubosc2.gif

As you can see, this box is beginning to show the style we want – but some of the style is still showing the standard osCommerce grey colours! Let’s change that…

Add this code to your stylesheet;

#categorybox .infoBox { background: blue; }

We now see the infoBox like this:

clubosc3.gif

Getting closer! Let’s make the background of the box a dark grey and make the text white. Add this code to the stylesheet;

#categorybox .infoBoxContents { background: #aaa; color: white; }

Now the box looks like this:

clubosc4.gif

And we have a problem – the actual links within this box are still the standard black with grey rollover. That’s easy to change, simply add this to the stylesheet;

#categorybox a { color: white;}

This says that any link with our category box should be white. Now the box looks like this – which is almost perfect for the style needed:

clubosc5.gif

The only problem remaining is the goofy little curved corner graphic that is now looking totally wrong. let’s change that to a square corner. This is really easy 😉

Step 3: Get rid the crappy graphic

Open up /includes/classes/boxes.php and find the following code;

'text' => $left_corner),

Change it to:

'text' => ' '),

Now our box looks like this:

clubosc6.gif

Perfect! But the best part is, the rest of the boxes all look as they normally do!

clubosc7.gif

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.