Cloning a Shipping Module

Cloning a Zen Cart Shipping Module

You can create Shipping Modules easiest by cloning the closest matching Shipping Module to what you are trying to do.

As an example, we will consider the flat shipping module.

Shipping Modules have 2 parts:

The code file is located in:

The language file is located in:

To clone this module, for example, to flatfree.php you would copy the two flat.php files to flatfree.php

Next, you need to edit all occurrences of flat to flatfree and FLAT to FLATFREE These identifiers are case sensitive.

These words are written separately or within the constants such as:

class flat {
$this->code = 'flat';


class flatfree {
$this->code = 'flatfree';

Once you have cloned the module then you can alter how it calculates shipping to the method that you need. This calculation is done in the quote() method.

Flat does not have complicated logic to compute a quote; it uses a single figure.

To see examples of quote calculations that are more complex, you might look at the items.php Shipping Module.

Cloning or creating a Shipping Module to function the way you need it is not too difficult if you just work through the steps on paper then recreate the same steps within the quote() function.

These forum threads might also give you ideas: * Thread: Additional Shipping Option - Flat Rate Per Item * Thread: How do I set 2 flat shipping rates to 2 different zone?

Last modified April 10, 2020 by Scott C Wilson (d3cbf9a).