9

Streamline your checkout process in osCommerce

multimixer | learn | Saturday June 23 2012

There are many cases where the visitor get just one shipping or payment option presented. This can be the case if you have just one shipping or payment module enabled or it can be that you have conditions for your shipping and payment ways: In this case a visitor from UK will get just one shipping or payment option while a visitor from the USA 3 of them.

In any case, it makes no sense to let people navigate through pages where there is nothing to select and no information presented. All your visitors can do in such a case is to press the “continue” button, and this is something the system can do automatically

In this way, you can cut of 2 of the 4 checkout steps and that’s a huge improvement. People will be transfered directly from the shopping cart page to the checkout confirmation page. Please note, that it case you enable a second shipping or payment module, the page will appear again by it self

The tip presented here comes from the “tip and trick” section of the osCommerce forum, to the topic there I contributed my self, unfortunately it’s getting lost in the crowd and I thing it’s worth to have it clearly presented. Like each forum post, it evolved over the time.

Lets start, things are easy, you’ll need just to copy paste

The files you’ll be working on are

  • catalog/checkout_shipping.php
  • catalog/checkout_payment.php

Make a copy of that files and store them somewhere on your computer, in that way you’ll be able to get back to the previous status in case you mess up

1. checkout_shipping.php

open the file and find following line, it’s number 97 in a default file

// process the selected shipping method

Add just before following

// bypass if only 1 shipping method available or free shipping
if ( (tep_count_shipping_modules() <= 1) || ($free_shipping == true) ) {
if (!tep_session_is_registered('shipping')) tep_session_register('shipping');
if ($free_shipping) {
$quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE;
$quote[0]['methods'][0]['cost'] = '0';
} else {
$quote = $shipping_modules->quote($method, $module);
}
$shipping = array('id' => $shipping,
'title' => (($free_shipping == true) ? $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')'),
'cost' => $quote[0]['methods'][0]['cost']);
$shipping = $shipping_modules->cheapest();
tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
}

Done !

2. checkout_payment.php

Open the file and find following line, it’s number 81 in a default file

  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_PAYMENT);

Add just before

// skip if only 1 payment method available
$payment_module_selections = $payment_modules->selection();
if (sizeof($payment_module_selections) <= 1) {
  if (!tep_session_is_registered('payment')) tep_session_register('payment');
  $payment = $payment_module_selections[0]['id'];
  tep_redirect(tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL'));
}

Done !

Mini template system users, you can do exactly the same if your want, your files are identical to the default osCommerce version

Thats all people, try it out

All credits to the original posters at the osCommerce forum

Click +1 to recommend this to your friends when they search.

multimixer

follow multimixer on Twitter

Follow me on twitter. I'm not tweeting all day long and guaranteed no spam and no advertising.

If you like what you read and if you think it will help you in your online business, then please consider a donation.

There is no obligation to do so and all information provided here is free to use.

It will however help to keep this blog alive, free of advertising and full of content.

  • Duncan 28/06/2012 at 21:57

    Thank you for all the work you put into helping people with OSCommerce! I have learnt a lot. I just have one issue with this code. It skips the shipping and payments pages as it should, but the shipping cost is not included in the total due. The only payment module I have installed is Paypal express checkout and the shipping is based on two flat rates (one for international addresses and one for domestic addresses). Do you know what might be causing this? Thank you.

  • multimixer 29/06/2012 at 13:23

    @Duncan, I will check this and post back here

  • sravani 04/01/2013 at 08:13

    thanks ur code worked a lot

  • Patrick 11/03/2013 at 09:46

    I’m busy designing a website and would like to find out how i would go about extending my cart to allow for option addons with pickture to a product.
    i’m busy with a custom shirt shop and it needs to ability to add various elements like a colar form a list of options and allowing the customer to add measurements of his neck into the cart can you assist please.

  • sandip 10/06/2013 at 13:55

    Hello multimixer,

    I have same issue that Duncan has. Please provide the solution if you can.

    I have free shipping for total amount above $300. But now I need to have other shipping options (Say UPS 2D and 3D) along with free shipping. I have changed the code in checkout_shipping.php file to display other shipping methods along with free shipping when total amount exceeds $300.

    But the issue is that, the shipping charges are not getting applied when customer selects any of UPS 2D Or 3D shipping methods. Its always consider free shipping and does not display any shipping charges at peypal.

    Is there any other file where I need to look out for free shipping condition.

    Please help me to get out of this issue I have spend lot of time to resolve the same and now stuck up :(.

    Your early response will be appreciated.

    Thanks in advance.

  • multimixer 10/06/2013 at 14:03

    @sandip

    The moment you have more than 1 shipping method, there is no skipping of the shipping page any more: Page display normally, all shipping options display on the page, customer can select

    Your issue seem to be a general shipping problem, don’t know what changes you did to checkout_shipping.php, I would suggest to post your issue to the forum together with your modified code

  • bunhin 16/06/2013 at 10:45

    Dear George,

    Thank you for your tutorials. I like and learn a lot from your posted tutorials. I am looking for the tutorials to add zones for shipping in the box of “Location / Taxes” of admin panel on the oscommerce 2.3.3, could you help it

    currently in the “location / taxes” box only have : countries, zones, tax zones, tax classes, tax rates, but none for shipping zone

    For local shipping in Indonesia most of the shipping provider based the shipping cost until sub-zones which almost equal to zip code zones.

    Could you please post tips or information or tutorials for this case? Thank you

    • multimixer 07/07/2013 at 07:50

      Yes, probably I could make a separate post about this

      The term “tax zones” is a bit misleading, the settings you do there are not just about taxes

      You can set up as many “tax zones” as you like and use them e.g. for shipping or payment or anything else.

      You could e.g., create 3 new tax zones, call them “”close”, “far”, “very far”, add any geographical zones to them and use that zones for the shipping modules only

  • Shane Metzler 16/08/2016 at 06:36

    George,

    I am learning so much from your posts. Thank you so much for taking the time and documenting everything so thoroughly. I just wanted you to know people are still reading your posts and learning from your excellent turtorials!

    Shane

Leave a Reply