Cloning a Shipping Module

Building a new shipping module based on an existing one

Note: These instructions are for Zen Cart 1.5.8 and higher. For Zen Cart 1.5.7 and lower, please see Cloning a Shipping Module in 1.5.7 and below.

You can create new Shipping Module by making a clone of 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 flat.php to flatfree.php
  • copy lang.flat.php to lang.flatfree.php

Note: Be sure the filename you choose does not have an underscore (_) in it.

Next, you need to change all occurrences of the strings flat and FLAT as follows:

flat 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';

Be sure to make this change in the remove() function as well.

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:

Still have questions? Use the Search box in the upper right, or try the full list of FAQs. If you can't find it there, head over to the Zen Cart support forum and ask there in the appropriate subforum. In your post, please include your Zen Cart and PHP versions, and a link to your site.

Is there an error or omission on this page? Please post to General Questions on the support forum. Or, if you'd like to open a pull request, just review the guidelines and get started. You can even PR right here.
Last modified May 10, 2024 by Scott Wilson (b2740e1).