Turn Speech into Text »

How To Customize Shipping Modules in ZenCart

In this tutorial, we will customize the text that is shown to the customer in the flat rate shipping module.

For the purpose of this tutorial, we assume that you have already configured Flat Rate shipping as $5 in

"ZenCart admin -> Modules -> Shipping" as shown...

And customer sees the following during checkout ...

Now we want to change the text so that instead of showing "Best Way", we want it to say "Regular Flat Rate shipping for within the United States".

Using the Template Override System

According to best practices, we will use the ZenCart template override system to make this modification. This tutorial assumes that you have already created your custom template according to this link here and have set your template in "ZenCart admin -> Tools -> Template Selection" to your custom template.

Now your file structure, should look like ...

where yourtemplate is a newly created folder with same name as your custom template name. (I'm only using yourtemplate as an example in the screenshots). This new folder is a duplicate of the classic folder.

The highlighted file "includes/languages/english/modules/shipping/flat.php" contains the text definitions used by the Flat Rate shipping module. Since we want to override this text. We duplicate flat.php and put a copy of it into the yourtemplate folder as shown...

Change the Front-End Shipping Text Definitions

Open up the newly duplicated flat.php that is in yourtemplate folder and change the text to look like ...

When you upload that file to the server and refresh your browser, you will see that the customer-displayed text has changed to the new text that you had specified...

Change Back-End Shipping Text definition

The text change made was for the customer-facing front-end. To change the text shown in the back-end ZenCart admin interface, we have to change the MODULE_SHIPPING_FLAT_TEXT_TITLE defined constant to be "Regular Flat Rate" instead of "Flat Rate" in this file shown here ...

So that now the back-end reflects the text changes ...

Because there is no override for this file for the back-end, this change is a core ZenCart change. And since this minor text change is not so important, it is not necessary to make this change.

Backend text changes in database

Suppose now we want to make text changes to the right-hand configuration column of the Shipping back-end. Those text were inserted into the database during the shipping module install. Therefore if we want to change those text, then we have to change the module install code in the file includes/modules/shipping/flat.php as shown...

Note that this is not the same flat.php we had edited earlier. Again, this is a core ZenCart file and this change is not mandatory.

After upload of this file to server, remove and re-install the shipping module in order to re-populate the database. And now you have the text change reflected here...

Note that this tutorial refers to ZenCart version 1.3.8. Your version may differ.

We continue this example in the next tutorial where we create a new shipping module called "Priority Flat Rate" shipping.