Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

noob quest: my copy of table rate doesn't show


rachmann

Recommended Posts

ok

Win7 / Apache 2.2 / PHP 5.2.17 / MySQL 5.5 / latest version of osCommerce

Everything is working nominally

 

Hi - yes, I'm new at this - I want to make my own copy of table.php to show up for selection in the

admin -> modules -> shipping -> click '+ Install Module' -> choose form list page.

 

I've copied the table.php file to table2.php in:

C:\Apache\Apache2.2\htdocs\catalog\includes\languages\english

and

C:\Apache\Apache2.2\htdocs\catalog\includes\modules\shipping

 

 

I've updated both to have their own variables:

 

language:

define('MODULE_SHIPPING_TABLE2_TEXT_TITLE', 'Table Rate 2');

define('MODULE_SHIPPING_TABLE2_TEXT_DESCRIPTION', 'Table Rate 2');

define('MODULE_SHIPPING_TABLE2_TEXT_WAY', 'Best Way');

define('MODULE_SHIPPING_TABLE2_TEXT_WEIGHT', 'Weight');

define('MODULE_SHIPPING_TABLE2_TEXT_AMOUNT', 'Amount');

 

and modules:

 

$this->code = 'table2';

$this->title = MODULE_SHIPPING_TABLE2_TEXT_TITLE;

$this->description = MODULE_SHIPPING_TABLE2_TEXT_DESCRIPTION;

$this->sort_order = MODULE_SHIPPING_TABLE2_SORT_ORDER;

$this->icon = '';

$this->tax_class = MODULE_SHIPPING_TABLE2_TAX_CLASS;

$this->enabled = ((MODULE_SHIPPING_TABLE2_STATUS == 'True') ? true : false);

if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_TABLE2_ZONE > 0) ) {

$check_flag = false;

blaw blaw blaw...

$this->quotes = array('id' => $this->code,

'module' => MODULE_SHIPPING_TABLE2_TEXT_TITLE,

'methods' => array(array('id' => $this->code,

'title' => MODULE_SHIPPING_TABLE2_TEXT_WAY,

'cost' => $shipping + MODULE_SHIPPING_TABLE_HANDLING)));

etc, etc..

But my copy doesn't show in the list as

Table Rate 2

How do I get it to show??!?!

Help!

Link to comment
Share on other sites

No, that didn't help - those steps are pretty much what I figured out myself - thus the need for a post.

 

Can you look at my code updates above and see if there's anything I missed? Should I just upload the complete files?

 

How does osCommerce search for new modules in the Shipping folder? Is there something I need to set up/config/allow permission on/whatever to get it to look for new things?

Link to comment
Share on other sites

ok - after looking at log file

(- for other noobs - you'll find that in the directory for what ever is set for error_log when you look for that in the "Server Info" settings under the left hand site "Tools" menu - mine is C:\windows\temp\php-errors.log)

 

I see that something was defined twice:

PHP Fatal error: Cannot redeclare class table in C:\Apache\Apache2.2\htdocs\catalog\includes\modules\shipping\table.php on line 13

SInce my file was named canadian_table.php - it came first, alphabetically, and leaving the original module to flounder - actually most shipping options didn't show up after this error was produced.

 

So I'll Google what variable that might be and perhaps help out some other noobs who can't do this.

 

I'll post a complete report on how to add a new module that is helpful.

Link to comment
Share on other sites

You missed the class declaration:

 

  class table {

 

Check that you also didn't miss the class constructor:

 

// class constructor
   function table() {

 

A better way to write that second one (if you have PHP 5) is:

 

   function __construct() {

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Noob Report:

Ok Noob fans everywhere, you wanna add a new table rate? Listen up!

 

1. make a work directory so you don't mess up your own shipping directory, if you care that is; you don't need to if you're the only one on the server!

mine is C:\temp\oscommerce\workdirectory\

2. copy C:\Apache\Apache2.2\htdocs\catalog\includes\languages\english\table.php to C:\temp\oscommerce\workdirectory\languages

3. copy C:\Apache\Apache2.2\htdocs\catalog\includes\modules\shipping\table.php to C:\temp\oscommerce\workdirectory\modules

4. rename both workdirectory files to the name you want

(I chose canadian_table - make up your own)

a C:\temp\oscommerce\workdirectory\languages\canadian_table.php

b C:\temp\oscommerce\workdirectory\modules\canadian_table.php

5. open the languages directory file from 4a and update all constants to a new standardized name that you will follow for your table version.

(I chose MODULE_SHIPPING_CDNTABLE_ - choose your own)

ie global replace of (not matching whole word, but matching case) :

MODULE_SHIPPING_TABLE_

with

MODULE_SHIPPING_CDNTABLE_

6. save and close file

7. open the modules directory file from 4b and again do the same global replace done in 5

8. in this same file, update the class name from

class table {

to be

class canadian_table {

NOTE: it must be SAME name as your filename - go ahead try it without matching...

9. in the same file update the constructor from

function table() {

to be

function canadian_table() {

NOTE: again, it must be SAME name as your filename and class

 

10. In the same file, inside the constructor, set the code to also match:

 

change

$this->code = 'table';

to be

$this->code = 'canadian_table';

NOTE: once more, it must be SAME name as your filename and class and constructor

11. Save file and close it

12. Copy each new file back to their respective source directories.

13. Enjoy

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...