Forums / Bug Reports / Template override in languages/english/modules/shipping not working

Template override in languages/english/modules/shipping not working

Views: 2,779

Results 1 to 6 of 6
23 Apr 2012, 3:52 PM
#1
tc avatar

tc

New Zenner

Join Date:
Nov 2009
Posts:
1
Plugin Contributions:
0

Template override in languages/english/modules/shipping not working

I upgraded my 1.3.8 site to 1.5. I started with a fresh 1.5 install and moved everything over.

My customer just rang to tell me people are having trouble ordering and when I tried to sign up as a new user I received a message telling me there where no shipping options available. When I log into the admin system and look at modules/shipping I saw lots of messages like this:

ERROR: module not loaded due to missing language file: /home/plr/public_html/includes/languages/english/modules/shipping/flatCourierUK.php

The file flatCourierUK.php was in a folder with the template name inside shipping. As soon as I moved it out to shipping then it started working again.

flatCourierUK.php was a shipping method I created based on the standard flat.php I created as it was the easiest way I found to create multiple flat shipping fees. The customer chooses which flat shipping method they want based on where they are, so for example royal mail for parcels under 5Kg or courier to the shetland islands.

Is this a bug with zencart not handling my language override properly or is it me not creating the new shipping method correctly?

24 Apr 2012, 7:08 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Template override in languages/english/modules/shipping not working

Sounds like you didn't test any transactions after doing the upgrade. Something to remember for future.

The "module not loaded due to missing language file" message appears when you don't have matching files for shipping module and its corresponding language file.

Shipping modules come in pairs:
/includes/modules/shipping/FILENAME.php
/includes/languages/YOUR_LANGUAGE/modules/shipping/FILENAME.PHP
If you don't have the pair of files on the server, you'll get errors and malfunction.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

28 May 2017, 5:05 PM
#3
yesaul avatar

yesaul

New Zenner

Join Date:
Apr 2011
Location:
Espoo, Finland
Posts:
73
Plugin Contributions:
0

Re: Template override in languages/english/modules/shipping not working

TC!!:

The file flatCourierUK.php was in a folder with the template name inside shipping. As soon as I moved it out to shipping then it started working again.

DrByte:

Shipping modules come in pairs:
/includes/modules/shipping/FILENAME.php
/includes/languages/YOUR_LANGUAGE/modules/shipping/FILENAME.PHP

The overiding system is being applied for language files in /includes/languages/YOUR_LANGUAGE/modules/shipping/ folder.

But it seems, the code in admin/modules.php and admin/orders.php files does not provide this option...

In admin/orders.php should be

                    if (file_exists(zen_get_file_directory(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/' . $module_type . '/', $file, 'false'))) {
                        include(zen_get_file_directory(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/' . $module_type . '/', $file, 'false'));

instead of

                    if (file_exists(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/' . $module_type . '/' . $file)) {
                        include(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/' . $module_type . '/' . $file);

and in admin/orders.php should be (in many places):

require_once zen_get_file_directory(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/payment/', $order->info['payment_module_code'] . '.php', 'false');

instead of:

require_once(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/payment/' . $order->info['payment_module_code'] . '.php');

and

require zen_get_file_directory(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/payment/', $order->info['payment_module_code'] . '.php', 'false');

instead of:

require(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/payment/' . $order->info['payment_module_code'] . '.php');

(quoting code from v.155e)

28 May 2017, 9:11 PM
#4
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Template override in languages/english/modules/shipping not working

The issue described and the suggested revision(s) do not align.

DrByte pointed out that all modules should be in includes/modules/shipping/ and have whatever name each is to be called. Then the words to be displayed for that shipping module are to be captured within each language used for each such shipping module (a language that does not have definitions for that shipping module will not show the shipping module as available, but will also generate an error.

The suggested code fix appears that would offer the default language (typically "english") for the admin if the current admin language is not supported by the front end of the system. In otherwords it would make it "easier" on the admin side to use an admin language not supported by the store, but at the cost of the admin's "user experience" because the text would not be presented in the language used by the admin if that language was not addressed in the catalog.

Basically, the shipping methods themselves are not overrideable. The language part of it is. Limits to the display of a shipping method are contained either in the admin setup (such as zones) or in additional code within the module based on whatever factor(s) of concern.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

28 May 2017, 10:14 PM
#5
yesaul avatar

yesaul

New Zenner

Join Date:
Apr 2011
Location:
Espoo, Finland
Posts:
73
Plugin Contributions:
0

Re: Template override in languages/english/modules/shipping not working

mc12345678:

The issue described and the suggested revision(s) do not align.

The issue described and the suggested revision(s) do align.

Please read carefully the description of the problem and its solution in the initial topicstarter's message:

TC!!:

ERROR: module not loaded due to missing language file: /home/plr/public_html/includes/languages/english/modules/shipping/flatCourierUK.php

The file flatCourierUK.php was in a folder with the template name inside shipping. As soon as I moved it out to shipping then it started working again.

Additionally, this has absolutely no connection with language (wether English or not) used in admin

31 May 2017, 7:57 PM
#6
a_berezin avatar

a_berezin

Deceased

Join Date:
Aug 2004
Location:
Saint Petersburg, Russia
Posts:
1,782
Plugin Contributions:
5

Re: Template override in languages/english/modules/shipping not working

Hi yesaul,

yesaul:

The overiding system is being applied for language files in /includes/languages/YOUR_LANGUAGE/modules/shipping/ folder.

But it seems, the code in admin/modules.php and admin/orders.php files does not provide this option...

In admin/orders.php should be

                if (file_exists(zen_get_file_directory(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/' . $module_type . '/', $file, 'false'))) {
                    include(zen_get_file_directory(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/' . $module_type . '/', $file, 'false'));
> instead of 
> ```
                    if (file_exists(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/' . $module_type . '/' . $file)) {
                        include(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/' . $module_type . '/' . $file);

and in admin/orders.php should be (in many places):

require_once zen_get_file_directory(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/payment/', $order->info['payment_module_code'] . '.php', 'false');

> 
> instead of:
> 
> ```
require_once(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/payment/' . $order->info['payment_module_code'] . '.php');

and

require zen_get_file_directory(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/payment/', $order->info['payment_module_code'] . '.php', 'false');

> 
> instead of:
> 
> ```
require(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/payment/' . $order->info['payment_module_code'] . '.php');

(quoting code from v.155e)

Thanks for the bugfix. Really unpleasant bug. Add this bugfix to zen-cart-1.5.5-Russian.

NOTE: We are sorry that Andrew is no longer with us.
We are grateful for all his contributions to the Zen Cart community.