Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / Adding 2 more flat rate shipping modules

Adding 2 more flat rate shipping modules

Views: 25,151

Results 1 to 20 of 55
16 Dec 2008, 10:08 AM
#1
jasonrocket avatar

jasonrocket

New Zenner

Join Date:
Oct 2008
Posts:
59
Plugin Contributions:
0

Adding 2 more flat rate shipping modules

I need the flat rate shipping module 2 more times so that customers can chose between:-

Before 10am delivery
before noon delivery
Before 5:30 pm delivery

Is there a way to do this?

16 Dec 2008, 12:29 PM
#2
fairestcape avatar

fairestcape

Totally Zenned

Join Date:
Mar 2008
Location:
Cape Town & London (depends on the season)
Posts:
2,957
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

You can create CLONES (copies) of the FLAT module. This duplicates the functions of the module, but enables more than one Flat Rate module to operate.

Essentially you need to do this:

  1. On your home computer, create TWO folders:

**- flatone

  • flattwo**

In each of these folders, create the following directory trees:

includes\modules\shipping
includes\languages\english\modules\shipping\

So you now have a Zencart-compatible directory structure for each of the TWO new modules you are about to create.

**- flatone\includes\modules\shipping\

  • |- - - - - - - - - - -\languages\english\modules\shipping\
  • flattwo\includes\modules\shipping\
  • |- - - - - - - - - - -\languages\english\modules\shipping**

You should have a copy of your zencart software on your home computer, so make copies of the relevant "flat.php" files, (but if not, you can FTP the files) -: (FIRST to the respective folders in flatone, then again to the respective folders in flattwo)

includes\modules\shipping*flat.php*
includes\languages\english\modules\shipping*flat.php*

The point here is to get two SETS of identical files of the original FLAT module, into the right directory structure on your hard drive.

(NB: BOTH of these files are called "flat.php", but they are different! One is the MODULE file, and the other is the LANGUAGE file. You must make sure the correct file goes to the correct directory!)

When you have all the copied files in the right place, you can start the clone process:

Go to your folder called flatone.

Navigate in turn, to the two "flat.php" files and RE-NAME both of them "flatone.php"

(Do the same with the "flat.php" files in the directory tree in flattwo - this time, you call the "flat.php" files "flattwo.php".)

**- flatone\includes\modules\shippingflatone.php (module file)

  • |- - - - - - - - - - -\languages\english\modules\shippingflatone.php (language file)
  • flattwo\includes\modules\shippingflattwo.php (module file)
  • |- - - - - - - - - - -\languages\english\modules\shippingflattwo.php (language file)**

Now you need to EDIT each file. And it's quite simple...

Open:

flatone\includes\modules\shippingflatone.php (module file)

Currently, it will look like this (first few lines):

<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce                                       |
// +----------------------------------------------------------------------+
// | Copyright (c) 2004 The zen-cart developers                           |
// |                                                                      |
// | http://www.zen-cart.com/index.php                                    |
// |                                                                      |
// | Portions Copyright (c) 2003 osCommerce                               |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license,       |
// | that is bundled with this package in the file LICENSE, and is        |
// | available through the world-wide-web at the following url:           |
// | http://www.zen-cart.com/license/2_0.txt.                             |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to       |
// | [email protected] so we can mail you a copy immediately.          |
// +----------------------------------------------------------------------+
// $Id: flat.php 1969 2005-09-13 06:57:21Z drbyte $
//

  class flat {
    var $code, $title, $description, $icon, $enabled;

// class constructor
    function flat() {
      global $order, $db;

      $this->code = 'flat';
      $this->title = MODULE_SHIPPING_FLAT_TEXT_TITLE;
      $this->description = MODULE_SHIPPING_FLAT_TEXT_DESCRIPTION;








      $this->sort_order = MODULE_SHIPPING_FLAT_SORT_ORDER;
      $this->icon = '';
      $this->tax_class = MODULE_SHIPPING_FLAT_TAX_CLASS;
      $this->tax_basis = MODULE_SHIPPING_FLAT_TAX_BASIS;

Now, you will see as you read through the file, the words:

flat
and
FLAT
appear...

Make sure to keep lower and uppercase when they appear, change instances of:-

flat to flatone
and
FLAT to FLATONE

So you will have, for example (first couple of lines here):

 
// $Id: flatone.php 1969 2005-09-13 06:57:21Z drbyte $
//

 class flatone {
    var $code, $title, $description, $icon, $enabled;

// class constructor
    function flatone() {
      global $order, $db;

      $this->code = 'flatone';
      $this->title = MODULE_SHIPPING_FLATONE_TEXT_TITLE; 

... see how instances of flat and FLAT become flatone and FLATONE ?

When you have changed all instances, SAVE the file.

Now you need to edit the corresponding LANGUAGE FILE.

So, on your hard drive, open the following:

flatone\includes\languages\english\modules\shipping\flatone.php

This will have the following code:

// $Id: flat.php 1969 2005-09-13 06:57:21Z drbyte $
//

define('MODULE_SHIPPING_FLAT_TEXT_TITLE', 'Flat Rate');
define('MODULE_SHIPPING_FLAT_TEXT_DESCRIPTION', 'Flat Rate');
define('MODULE_SHIPPING_FLAT_TEXT_WAY', 'Best Way');
?>

Now you do the same here with flat and FLAT

// $Id: flatone.php 1969 2005-09-13 06:57:21Z drbyte $
//

define('MODULE_SHIPPING_FLATONE_TEXT_TITLE', 'Flat Rate ONE');
define('MODULE_SHIPPING_FLATONE_TEXT_DESCRIPTION', 'Flat Rate ONE');
define('MODULE_SHIPPING_FLATONE_TEXT_WAY', 'Best Way FLAT RATE ONE');
?>

(Naturally, you will also change the defines to suit your needs - I have just given them a quick label to help identify them later).

SAVE the file.


NOW... you duplicate the process for flattwo


When you have completed your edits, you now FTP the files to your server. You can choose to use your custom over-ride folders to house the new files, or leave them in their default directories - as there is no core file called "flatone.php" it will not be overwritten in a future upgrade.

Please note that on your hard drive you have ROOT folders called:

flatone
and
flattwo

These folders are NOT FTP'd - Just the contents of their INCLUDES folders. (So you are conforming to the directory structure of ZC).


Now, go to your ADMIN CONSOLE and navigate to the shipping modules.

You will now see - in addition to the flat module, you have:

flatone
flattwo

If you have been sensible and given your language defines appropriate labels, you will see these modules properly labelled.

Install, configure and use the modules.

17 Dec 2008, 12:00 PM
#3
jasonrocket avatar

jasonrocket

New Zenner

Join Date:
Oct 2008
Posts:
59
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

That worked perfect fairestcape. thanks

18 Dec 2008, 2:13 AM
#4
megkin avatar

megkin

New Zenner

Join Date:
Jul 2005
Location:
Brisbane
Posts:
8
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

Hi

Thanks for the great step by step!

I have a quick question. When I change the names from flat to flatone etc and then go to the shipping modules in admin the main name is still Flat Rate. So now I have two modules called Flat Rate ie. I want one to remain Flat Rate and the other to be known as Parcel Post. How do I change the name from flat rate to whatever I want it to be?

Thanks for your assistance.

Megan

18 Dec 2008, 7:06 AM
#5
megkin avatar

megkin

New Zenner

Join Date:
Jul 2005
Location:
Brisbane
Posts:
8
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

Hi

I managed to find where this is located in the flat.php file. I just need to play around now and get the shipping to do what I want it to do ;)

Thanks for your initial guide as it was a really great help.

Megan

8 Apr 2009, 11:05 PM
#6
studiotucker avatar

studiotucker

New Zenner

Join Date:
Sep 2008
Posts:
47
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

Thanks for the idiot-proof instructions.
worked perfectly...... misasfashioncafe

Robert

16 Dec 2009, 9:14 AM
#7
tagyourbaby avatar

tagyourbaby

New Zenner

Join Date:
Feb 2008
Location:
Auckland, NZ
Posts:
53
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

Thanks heaps for this just what i needed :)

10 Jan 2010, 10:25 AM
#8
dinnages avatar

dinnages

Zen Follower

Join Date:
May 2007
Location:
Brighton/Hove/Sussex
Posts:
146
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

studiotucker:

Thanks for the idiot-proof instructions.
worked perfectly...... misasfashioncafe
Robert

Absolutely, found that a very simple set of instructions, so except for those programmers who really understand php workings unlike me for example, this sort of description helps those who like Zen-Cart without having to know how to write php code itself.
The serious bit many could fall over is the copy of the whole folders in the root directory! Was a good reminder there.

Ive just created FLATUK, FLATEU, FLATUS, FLATROW after Ive already got those four Zone Definitions set. What I needed was a fixed rate for each of the four as a customer bought from Brazil and used the UK flat rate fee! My mistake but fortunately was covered being lightweight items. FLAT RATE covers the low cost items, but over a set price you can allow for a UK post paid facility. However be mindful of the odd items that are really heavy, and spoil the FLAT RATE figures. Therefore I cannot discount those items with tight margins!

3 Mar 2010, 9:22 AM
#9
fairestcape avatar

fairestcape

Totally Zenned

Join Date:
Mar 2008
Location:
Cape Town &amp; London (depends on the season)
Posts:
2,957
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

I'm glad people are finding this post helpful and useful.

Many (though not all) of the shipping modules can be cloned in the same way. Examples of "clonable" shipping modules include:

Flat Rate
Zone Rates
Table Rates

... and one in particular that I like in the Free Add-ons:

ZoneTables.

Just follow the principles outlined in my earlier post.

5 Mar 2010, 1:45 PM
#10
mike_dean avatar

mike_dean

Totally Zenned

Join Date:
Feb 2006
Location:
Central Coast, NSW, Australia
Posts:
531
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

fairestcape:

I'm glad people are finding this post helpful and useful.

Many (though not all) of the shipping modules can be cloned in the same way. Examples of "clonable" shipping modules include:

Flat Rate
Zone Rates
Table Rates

... and one in particular that I like in the Free Add-ons:

ZoneTables.

Just follow the principles outlined in my earlier post.

Excellent walkthrus... Just one question.

If I need to make 7 separate zones, for shipping across Australian States, would this be the process to use ?

5 Mar 2010, 5:16 PM
#11
fairestcape avatar

fairestcape

Totally Zenned

Join Date:
Mar 2008
Location:
Cape Town &amp; London (depends on the season)
Posts:
2,957
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

Mike_Dean:

Excellent walkthrus... Just one question.

If I need to make 7 separate zones, for shipping across Australian States, would this be the process to use ?

If they are all for FLAT RATE shipping, then YES... you make 7 separate "clones"

flatone
flattwo
flathree
flatfour
flatfive
flatsix
flatseven

In your case, it could be more appropriate to NAME these in line with the Australian zones themselves:

flatqld
flatvic
flatnsw
flatsa
flatnt
flatwa
flattas

... then you know - at a glance - what each one refers to.

The KEY here is to use all alpha characters (no numerical) and that each clone is unique in the names used.

5 Mar 2010, 8:11 PM
#12
mike_dean avatar

mike_dean

Totally Zenned

Join Date:
Feb 2006
Location:
Central Coast, NSW, Australia
Posts:
531
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

fairestcape:

If they are all for FLAT RATE shipping, then YES... you make 7 separate "clones"

In your case, it could be more appropriate to NAME these in line with the Australian zones themselves:

flatqld
flatvic
flatnsw
flatsa
flatnt
flatwa
flattas

... then you know - at a glance - what each one refers to.

The KEY here is to use all alpha characters (no numerical) and that each clone is unique in the names used.

That makes a lot of sense.. thankyou...

6 Mar 2010, 1:15 AM
#13
mike_dean avatar

mike_dean

Totally Zenned

Join Date:
Feb 2006
Location:
Central Coast, NSW, Australia
Posts:
531
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

Mike_Dean:

Excellent walkthrus... Just one question.

If I need to make 7 separate zones, for shipping across Australian States, would this be the process to use ?

Have I got something configured incorrectly, or am I correct in saying that the Zone Rates shipping will not calculate a freight charge unless you are registered and logged in. Else the system has no idea where you are in order to calculate the correct freight..

Should the shipping estimator have a zones option for getting an estimate ?

6 Mar 2010, 9:28 AM
#14
mike_dean avatar

mike_dean

Totally Zenned

Join Date:
Feb 2006
Location:
Central Coast, NSW, Australia
Posts:
531
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

Mike_Dean:

Have I got something configured incorrectly, or am I correct in saying that the Zone Rates shipping will not calculate a freight charge unless you are registered and logged in. Else the system has no idea where you are in order to calculate the correct freight..

Should the shipping estimator have a zones option for getting an estimate ?

Solved this issue.

The ozpost shipping module has the states removed.. hence them not showing up.. Grabbed an original tpl_modules_shipping_estimator and all good...

22 Mar 2011, 7:43 AM
#15
extraherbos avatar

extraherbos

New Zenner

Join Date:
Mar 2011
Posts:
1
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

Excellent explanation here, just a question:

Supossing i want to name flattwo to whatever will also work?
Or do i have to rename flat to flatone too?

22 Mar 2011, 1:59 PM
#16
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Adding 2 more flat rate shipping modules

You can change all of the:
flat to fred
FLAT to FRED
filename: fred.php

and it would work ...

You just need to follow the pattern ...

12 Apr 2011, 4:57 PM
#17
mitman avatar

mitman

New Zenner

Join Date:
Sep 2010
Posts:
9
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

So what happens when you want to duplicate the "table" shipping method, there are the words "table" used in the PHP code itself so for anyone like myself who isn't sure if its calling for the filename or drawing a table or doing something else in the particular line of code....

How to do it?

:frusty:

12 Apr 2011, 5:56 PM
#18
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Adding 2 more flat rate shipping modules

I believe if you search the Add Ons for Table Rate you should find a Cloned set that you can use as a guide ...

12 Apr 2011, 5:58 PM
#19
mitman avatar

mitman

New Zenner

Join Date:
Sep 2010
Posts:
9
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

Ajeh:

I believe if you search the Add Ons for Table Rate you should find a Cloned set that you can use as a guide ...

After many attempts I've actually just got it figured out, cant remember exactly which TABLE instances I changed to TABLETWO but its working now :D

If anyone needs the code I can copy it here.

Thanks

11 Aug 2011, 4:45 PM
#20
tcjay avatar

tcjay

Zen Follower

Join Date:
Jul 2010
Location:
Boston
Posts:
139
Plugin Contributions:
0

Re: Adding 2 more flat rate shipping modules

It works like a charm! :clap:

Now that there are two seperate fixed rates, I would like to have a seperate fixed rate for one product. How do I go about programming this.

TIA Tom :cool: