Jump to content
Sign in to follow this  
mrlake

Problem with Multiple Flat Rate files (flat.php)

Recommended Posts

Greetings,

 

My goal is to create five Flat Rate shipping modules by copying and editing the appropriate

flat.php files.

 

As a test, I created one new Flat Rate module, using the instructions in Mercer's book (osCommerce:

Beginner's Edition, page 138) to copy and edit the flat.php files that support the Flat Rate module.

 

Hoeever, when I display the Admin-> Shipping Modules page, I see two Flat Rate shipping modules,

both of which are named "Flat Rate" (not "Flat Rate" and "Flat Rate 2").

 

When I edit one Flat Rate Module, the changes show up in both modules. The attributes for both of

these modules seem to be from original flat.php file. Not, as I would hope, from the

flat and flat2 files, respectively.

 

Suggestions?

 

 

DETAILS

 

I created copy of "flat.php" in catalog\includes\modules\shipping and

catalog\includes\languages\english\modules\shipping.

 

In the new file, I replaced "flat" with "flat2" as described in the Mercer book cited previously.

 

In order to distinguish flat2.php from flat.php, etc., I customized the strings in . . .

 

catalog\includes\languages\english\modules\shipping\flat2.php

 

. . . as follows . . .

 

define('MODULE_SHIPPING_FLAT_TEXT_TITLE', 'Flat Rate 2');

define('MODULE_SHIPPING_FLAT_TEXT_DESCRIPTION', 'Flat Rate 2');

define('MODULE_SHIPPING_FLAT_TEXT_WAY', 'Best Way 2');

 

etc.

 

I then uploaded all of the files. However, I noticed the problems cited above.

 

When I look at the HTML/PHP code for the Admin-> Shipping Modules page, I see that the code

is partially correct; that is, the table row for each module (tr class="dataTableRow") specifies

the correct flat rate ID (flat or flat2). However, the table cells for each module (td class="dataTableContent">Flat Rate</td>) seem to be coming from the original

original flat.php file.

Share this post


Link to post
Share on other sites

define('MODULE_SHIPPING_FLAT_TEXT_TITLE', 'Flat Rate 2');

define('MODULE_SHIPPING_FLAT_TEXT_DESCRIPTION', 'Flat Rate 2');

define('MODULE_SHIPPING_FLAT_TEXT_WAY', 'Best Way 2');

 

should be

 

define('MODULE_SHIPPING_FLAT2_TEXT_TITLE', 'Flat Rate 2');

define('MODULE_SHIPPING_FLAT2_TEXT_DESCRIPTION', 'Flat Rate 2');

define('MODULE_SHIPPING_FLAT2_TEXT_WAY', 'Best Way 2');

 

same for all parameters in the modules file ... just as explained in the book (I happen to know as I was the reviewer and that passage was added by me, LOL)


:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Share this post


Link to post
Share on other sites

Monika to the rescue once again!

 

Thanks. I made the changes you suggested and the edited Flat Rates module works fine now. I think I know which osComm book I'm getting for Christmas ;-)

 

*

 

On a side note . . . I just went back to page 136 of the Mercer book (Beginner's Edition), and I wonder if they added the passage that you suggested? The section called "Flat Rates" in both the Begiinner's Edition (2006) and the Professional Edition (2005) seem identical.

 

Both versions include this sentence:

 

"Then edit these copies, replacing each occurrence of the term flat or FLAT with the name of the copied files."

 

I interpreted "or" in that sentence to mean "either, but not both." So I just replaced the lowercase version (the only "whole word" variable name I saw). I do not see any passage that is as clear as your last post.

 

However, I also made the mistake of doing a "whole word" search and replace, when I needed to replace the string FLAT within a longer variable names like MODULE_SHIPPING_FLAT2_TEXT_TITLE. So there you go.

Share this post


Link to post
Share on other sites

The sentence you are quoting may seem unclear as "or" is used instead of "and" (was not my choice of wording, just to make sure you know, hehe)... but I think it's followed by the next example sentence that makes it clear that both expressions have to be replaced.

 

TG all working fine now, right? The beginners book is of course a very short compendium where not too many hack examples could be added.


:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Share this post


Link to post
Share on other sites

Oh, I am a great admirer of Mercer's OsComm Beginner's Edition!

 

Anyone who is relatively new to osComm -- especially non-programmers and weekend-Webmasters like myself -- should have this book. I have the Professional edition as well.

 

Thanks again for zeroing in on the source of my problem, Monika.

 

Dave

Share this post


Link to post
Share on other sites

The beginner edition is just a reduced page version of the professional one that's the one I worked on (and I also made the list what should go into the reduced version). There was no multiple flat fee explanation at all in the first draft. As a reviewer, you add suggestions of what should be added (with examples and all) but the author will write the text - and in this case personally I'd have used "and", like mentioned before.

 

Both books are absolutely excellent, I could not agree more.


:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Share this post


Link to post
Share on other sites

Hi Monika,

 

I'm going through the same problem as Dave now. I have read the discussion but still am a bit lost. If you wouldn't mind clearing it up for me and everybody else who might be looking for the solution here.

 

As I understand, I need to create several copies of flat.php (flat2.php, flat3.php, etc) in order to have a few flat rates. In these copies, I need to customize the strings to

 

define('MODULE_SHIPPING_FLAT2_TEXT_TITLE', 'Flat Rate 2');

define('MODULE_SHIPPING_FLAT2_TEXT_DESCRIPTION', 'Flat Rate 2');

define('MODULE_SHIPPING_FLAT2_TEXT_WAY', 'Best Way 2');

 

However in my flat.php file I do not have strings starting with define('MODULE_SHIPPING ...)

 

I have these:

 

class flat {

var $code, $title, $description, $icon, $enabled;

 

// class constructor

function flat() {

global $order;

 

$this->code = 'flat';

$this->title = MODULE_SHIPPING_FLAT_TEXT_TITLE;

$this->description = MODULE_SHIPPING_FLAT_TEXT_DESCRIPTION;

$this->sort_order = MODULE_SHIPPING_FLAT_SORT_ORDER;

$this->icon = '';

$this->tax_class = MODULE_SHIPPING_FLAT_TAX_CLASS;

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

 

etc.

 

The question is: is

 

$this->title = MODULE_SHIPPING_FLAT_TEXT_TITLE;

 

the same as

 

define('MODULE_SHIPPING_FLAT2_TEXT_TITLE', 'Flat Rate 2');

 

 

and if it is, where in my string do I add the value Flat Rate 2 as the syntax in my string is different from the one you quote.

 

Another question: do I have to replace *each* instance of flat/FLAT to flat2/FLAT2?

 

Thanks in advance for any help you can provide.

Tatyana

Share this post


Link to post
Share on other sites

Hi Tatyana, you have 2 files for each module (and more if you have several languages, I'm implying an all-english shop here). You need to duplicate both, and change all instances. I'm copying in here a section from a cookbook recipe to clear things up completely (this procedure has to be done on both files). The first passage is a general info intro, the second a how-to for flat.php:

 

....

First, using your favorite editor (Chef recommends TextPad), find and replace all occurrences of the shipping module's name. In the next step, you can edit the text shown for each module's in the edit column after installation. These expressions can be found in each modules file almost at the bottom in the install() function.

....

Open catalog/includes/modules/shipping/flat.php and create a clone, then replace all occurrences of the flat expression with flat1, keeping its upper or lower case spelling intact. Save this new file as flat1.php

....


:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Share this post


Link to post
Share on other sites

Hi Monika,

 

I have tried doing it as you have explained and here is what I have got. I have created flat2.php (in shop/includes/modules/shipping/ directory) by copying flat.php and saving it as flat2.php. I renamed all occurrences of flat/FLAT into flat2/FLAT2 in this new file. I then created flat2.php in the shop/includes/languages/english/modules/shipping directory and renamed FLAT to FLAT2 in this file as well. Now in my admin area I see Flat Rate and Flat Rate 2, but when I try to click on the Install button, nothing happens at all. I do not get the fields where I would customize the prices, the Install button just stays as it is after I click on it. Also, when I click on Flat Rate 2 and try to click on the Install button, something does happen but not what I need to happen: it jumps back to Flat Rate with its frozen Install button. When I try to make a test purchase and arrive on the Delivery Information page, I see only one shipping method - Flat Rate with its default $5.00 cost. When I tried to hard-code the prices in my flat.php ($3.95) and flat2.php ($10.00) in the shop/includes/modules/shipping/ directory, it does not get reflected on the Delivery Information page. So now I'm stuck with two unedtable shipping methods. Apart from these files, I have not touched any other files that could affect the editability.

 

Do you have any idea why my Flat Rate shipping methods have become unedtable and the hard-coded price is not reflected on the delivery page?

 

Thanks and looking forward to your response,

Tatyana

Share this post


Link to post
Share on other sites

Monika,

 

One more thing: other shipping modules (Per Item, Table Rate, etc.) work fine, can be installed and removed, just not my new Flat Rate modules. So I'm lost. I tried removing flat2.php from both directories and still the Flat Rate module cannot be installed/edited/removed. Any suggestion is much appreciated.

 

Tatyana

Share this post


Link to post
Share on other sites

I suggest you check your configuration table via phpmyadmin, and clean up the shipping modules from it. There is a parameter listing all installed modules, and then of course all the parameters each module has when installed. Maybe there is amismatch there from where you started on your coding and messed things up.


:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Share this post


Link to post
Share on other sites

Tatyana, phpmyadmin is a tool for seeing and manipulating your database. It should be located in your host cPanel.


:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Share this post


Link to post
Share on other sites

Thanks but I was asking about the configuration table you have mentioned. Where is it located? The thing is I have not edited any files but flat.php. I'm pretty sure it is fine though because I have downloaded it from the other osc store I did before. That's why I'm not sure what is wrong at all. Sorry I'm aksing these questions.

Share this post


Link to post
Share on other sites

Tatyana, the configuration table IS in the database. Like I said, it may not be a file, but a database issue.


:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Share this post


Link to post
Share on other sites

Hi,

 

I'm have problems getting my Multiple Flat Rate files to show up - on the checkout_shipping.php page it only lists the first of my 3 files - for example it only gives me the info from flat.php with my first shipping option.

 

When I look in the database in the configuration table the MODULE_SHIPPING_INSTALLED has my 3 files listed flat.php;flat3.php;flat4.php

 

However, I noticed in the checkout_shipping.php that the

 

// get all available shipping quotes

$quotes = $shipping_modules->quote();

 

This only returns one quote.

 

I've hunted around in the shipping.php file in classes directory and I could find anything wrong. It seems to be finding all 3 of my files...

 

Any hints or suggestions? Thank you all for your time.

 

Sincerely,

jason

Share this post


Link to post
Share on other sites

assign them new sort order values in admin ... high ones, like 100, 200, 300 ... it may help.


:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Share this post


Link to post
Share on other sites

Thanks Monika,

 

I changed the sort order and that didn't do anything (somehow I can't change anything via the admin - > I had to go via phpMyAdmin in the configuration table) ... but I now got all three of my zones showing up... basically I had to set the value of MODULE_SHIPPING_FLAT_ZONE in the configuration to zero then they all show up... so I'm not to sure how to get it to work with zones, but I'll keep trying... maybe it is because my code is grabbing from the "Tax Zones" ... instead of just the "Zones" ... this bit:

 

'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");

 

... but I'm not sure ... I never really am :-)

Jason

Share this post


Link to post
Share on other sites

i tried what was described in this thread and i got a 2nd flat rate to show up on my shipping area .. but the second flat rate didnt have a name on the list it was just blank

 

what do i change to give it a name on the list?

Share this post


Link to post
Share on other sites

I've got this up and running great -- with one small problem. When I run a test purchase, the shipping cost defaults to the original flat file rate regardless of which one I select on the prior page.

 

e.g. I have three modules:

 

Ground: $10

2nd Day: $20

Overnight: $35

 

and shipping charges revert to $10 regardless of which method I choose.

 

 

 

Any ideas?


www.rekluse.com

Share this post


Link to post
Share on other sites
I've got this up and running great -- with one small problem. When I run a test purchase, the shipping cost defaults to the original flat file rate regardless of which one I select on the prior page.

 

e.g. I have three modules:

 

Ground: $10

2nd Day: $20

Overnight: $35

 

and shipping charges revert to $10 regardless of which method I choose.

Any ideas?

 

UPDATE: Shipping rate shows up properly for 2nd Day, but still not for Overnight.


www.rekluse.com

Share this post


Link to post
Share on other sites
I've got this up and running great -- with one small problem. When I run a test purchase, the shipping cost defaults to the original flat file rate regardless of which one I select on the prior page.

 

e.g. I have three modules:

 

Ground: $10

2nd Day: $20

Overnight: $35

 

and shipping charges revert to $10 regardless of which method I choose.

Any ideas?

 

Problem solved. All the instances of Flat overnight in my files were expressed as flat_overnight. Apparently you can't have an underscore in whatever you change "flat" to from the original file.


www.rekluse.com

Share this post


Link to post
Share on other sites

Sorry for the bump but i am really stuck here. I have added a flat1.php in all 3 folders (I have a english/dutch webshop). The strange thing is, It doesn't ask what shipping method my customer wants to use what so ever, so it doesn't add a shipping fee to the total either.

 

What I need is a flat fee for

 

- NL

- EUR

- WORLD

 

I thought this would be the best option. It just doesn't work along with me...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×