Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / Clone Flat Rate Shipping with Zone

Clone Flat Rate Shipping with Zone

Views: 3,593

Results 1 to 20 of 22
28 Jul 2012, 8:07 AM
#1
nfallat avatar

nfallat

New Zenner

Join Date:
Jan 2009
Posts:
84
Plugin Contributions:
0

Clone Flat Rate Shipping with Zone

I have read many posts in the forums on this but have not found a clear answer to my problem yet that works.:(

I cloned the Flat Rate shipping to set up a shipping rate just for Canada. Everything looks OK in the admin. Flatcanada. Zone has been set up and defined and details completed. Setting up the Zone causes the status of the Flatcanada shipping to be yellow. I read that this just means that it is filtered for a zone.

The problem is, the new Flatcanada shipping option does not show up at checkout. I set up a Canada shipping address to go through checkout.

Even when I remove the zone and the Flatcanada status turns green (and it is set up exactly the same as original Flat except for shipping cost), it does not show up at checkout.

After hours of trying I think I must be missing something simple. Any help would be appreciated.

28 Jul 2012, 1:22 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Clone Flat Rate Shipping with Zone

Could you post your code for:
/includes/modules/shipping/flatcanada.php

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

28 Jul 2012, 2:48 PM
#3
nfallat avatar

nfallat

New Zenner

Join Date:
Jan 2009
Posts:
84
Plugin Contributions:
0

Re: Clone Flat Rate Shipping with Zone

Yes. Here is the code.

<?php /** * @package shippingMethod * @copyright Copyright 2003-2009 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license <http://www.zen-cart.com/license/2_0.txt> GNU Public License V2.0 */ // $Id: flatcanada.php 14498 2009-10-01 20:16:16Z ajeh $ // class flatcanada { var $code, $title, $description, $icon, $enabled; // class constructor function flatcanada() { global $order, $db; $this->code = 'flatcanada'; $this->title = MODULE_SHIPPING_flatcanada_TEXT_TITLE; $this->description = MODULE_SHIPPING_flatcanada_TEXT_DESCRIPTION; $this->sort_order = MODULE_SHIPPING_flatcanada_SORT_ORDER; $this->icon = ''; $this->tax_class = MODULE_SHIPPING_flatcanada_TAX_CLASS; $this->tax_basis = MODULE_SHIPPING_flatcanada_TAX_BASIS; // disable only when entire cart is free shipping if (zen_get_shipping_enabled($this->code)) { $this->enabled = ((MODULE_SHIPPING_flatcanada_STATUS == 'True') ? true : false); } if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_flatcanada_ZONE > 0) ) { $check_flag = false; $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_flatcanada_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id"); while (!$check->EOF) { if ($check->fields['zone_id'] < 1) { $check_flag = true; break; } elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) { $check_flag = true; break; } $check->MoveNext(); } if ($check_flag == false) { $this->enabled = false; } } } // class methods function quote($method = '') { global $order; $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_flatcanada_TEXT_TITLE, 'methods' => array(array('id' => $this->code, 'title' => MODULE_SHIPPING_flatcanada_TEXT_WAY, 'cost' => MODULE_SHIPPING_flatcanada_COST))); if ($this->tax_class > 0) { $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); } if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title); return $this->quotes; } function check() { global $db; if (!isset($this->_check)) { $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_flatcanada_STATUS'"); $this->_check = $check_query->RecordCount(); } return $this->_check; } function install() { global $db; $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable flatcanada Shipping', 'MODULE_SHIPPING_flatcanada_STATUS', 'True', 'Do you want to offer flatcanada rate shipping?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Cost', 'MODULE_SHIPPING_flatcanada_COST', '5.00', 'The shipping cost for all orders using this shipping method.', '6', '0', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_flatcanada_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Tax Basis', 'MODULE_SHIPPING_flatcanada_TAX_BASIS', 'Shipping', 'On what basis is Shipping Tax calculated. Options are<br />Shipping - Based on customers Shipping Address<br />Billing Based on customers Billing address<br />Store - Based on Store address if Billing/Shipping Zone equals Store zone', '6', '0', 'zen_cfg_select_option(array(\'Shipping\', \'Billing\', \'Store\'), ', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_flatcanada_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_flatcanada_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())"); } function remove() { global $db; $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key like 'MODULE\_SHIPPING\_flatcanada\_%'"); } function keys() { return array('MODULE_SHIPPING_flatcanada_STATUS', 'MODULE_SHIPPING_flatcanada_COST', 'MODULE_SHIPPING_flatcanada_TAX_CLASS', 'MODULE_SHIPPING_flatcanada_TAX_BASIS', 'MODULE_SHIPPING_flatcanada_ZONE', 'MODULE_SHIPPING_flatcanada_SORT_ORDER'); } } ?>
28 Jul 2012, 4:11 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Clone Flat Rate Shipping with Zone

You goofed ... :eek:

What you want to do is do the replacements case sensative ...
flat should be flatcanada
FLAT should be FLATCANADA

in both the code and language files ...

And I am assuming that you have named the files:
/includes/modules/shipping/flatcanada.php
/includes/languages/english/modules/shipping/flatcanada.php

again, case sensative ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

28 Jul 2012, 5:56 PM
#5
nfallat avatar

nfallat

New Zenner

Join Date:
Jan 2009
Posts:
84
Plugin Contributions:
0

Re: Clone Flat Rate Shipping with Zone

Ajeh:

You goofed ... :eek:

What you want to do is do the replacements case sensative ...
flat should be flatcanada
FLAT should be FLATCANADA

in both the code and language files ...

And I am assuming that you have named the files:
/includes/modules/shipping/flatcanada.php
/includes/languages/english/modules/shipping/flatcanada.php

again, case sensative ...

Thanks for your response. I did as you said (sorry for the boneheaded mistake) but now in the admin it has red warning duplicate sort order. But the sort order is not duplicate. And when I tried to remove and reinstall it does not remove. Perhaps I should have removed this before I fixed the code and then reinstalled. Here is a screenshot:

Attachment 10889

28 Jul 2012, 6:21 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Clone Flat Rate Shipping with Zone

I cannot read your images it is too small ...

Make sure if you are using Sort Orders that they are all unique numbers and NONE are using 0 ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

28 Jul 2012, 6:40 PM
#7
nfallat avatar

nfallat

New Zenner

Join Date:
Jan 2009
Posts:
84
Plugin Contributions:
0

Re: Clone Flat Rate Shipping with Zone

I'm sorry about that. Here it is again. The module is in red status and I can't change it. Clicking on the Action button for this module does nothing. If I click Remove, the edit box does come up as you can see and I can edit it, but when I then click Remove it is still there. I thought if I removed it and reinstalled it might work. Each active module has a non-o sort order.

Attachment 10890

28 Jul 2012, 6:45 PM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Clone Flat Rate Shipping with Zone

I am not sure what is up with your flatcanada shipping module ...

Please go to:
/includes/modules/shipping

and delete and files for you flatcanada ...

Please go to:
/includes/languages/english/modules/shipping

and delete and files for you flatcanada ...

Now if you go to the Modules ... Shipping ... is the error message gone?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

28 Jul 2012, 7:08 PM
#9
nfallat avatar

nfallat

New Zenner

Join Date:
Jan 2009
Posts:
84
Plugin Contributions:
0

Re: Clone Flat Rate Shipping with Zone

Yes, I actually just renamed with z_ to turn them off and the error message is gone. I will also add that I had also copied the file to includes/languages/engligh/modules/mytemplate/shipping which I did not rename. So I guess it's not looking at the custom folder. As a side issue, I thought maybe I had to make the change in the custom folder. I'm still learning.

Should I now try to reinstall?

28 Jul 2012, 7:18 PM
#10
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Clone Flat Rate Shipping with Zone

Try installing your fixed files for:
/includes/modules/shipping/flatcanada.php
/includes/languages/english/modules/shipping/flatcanada.php

Do any errors come up?

Now, do an Install ... then do a REMOVE ...

Then, do an Install and configure it for your site and see if all is working ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

28 Jul 2012, 7:53 PM
#11
nfallat avatar

nfallat

New Zenner

Join Date:
Jan 2009
Posts:
84
Plugin Contributions:
0

Re: Clone Flat Rate Shipping with Zone

I am not familiar with the term "fixed files" but I assume you meant to reupload the flatcanada files. This intalls the module. Still same error message and can't successfully remove the module in the admin.

Oh, I just noticed that the name showing in the list of modules in the admin reads FLATCANADA. Don't know if that matters but all the other modules are listed in lower case. Maybe I misunderstood your earlier instructions. I had changed all instances of flatcanada to FLATCANADA in the files.

28 Jul 2012, 8:01 PM
#12
nfallat avatar

nfallat

New Zenner

Join Date:
Jan 2009
Posts:
84
Plugin Contributions:
0

Re: Clone Flat Rate Shipping with Zone

Oh, wait. I see what might be an issue. I'll update further.

28 Jul 2012, 8:33 PM
#13
nfallat avatar

nfallat

New Zenner

Join Date:
Jan 2009
Posts:
84
Plugin Contributions:
0

Re: Clone Flat Rate Shipping with Zone

I thought I saw something wrong but not. You have been really more than patient. I'll lay it all out one more time:

includes/modules/shipping
flatcanada.php

class FLATCANADA {
var $code, $title, $description, $icon, $enabled;

// class constructor
function FLATCANADA() {
global $order, $db;

  $this->code = 'FLATCANADA';
  $this->title = MODULE_SHIPPING_FLATCANADA_TEXT_TITLE;
  $this->description = MODULE_SHIPPING_FLATCANADA_TEXT_DESCRIPTION;
  $this->sort_order = MODULE_SHIPPING_FLATCANADA_SORT_ORDER;
  $this->icon = '';
  $this->tax_class = MODULE_SHIPPING_FLATCANADA_TAX_CLASS;
  $this->tax_basis = MODULE_SHIPPING_FLATCANADA_TAX_BASIS;

  // disable only when entire cart is free shipping
  if (zen_get_shipping_enabled($this->code)) {
    $this->enabled = ((MODULE_SHIPPING_FLATCANADA_STATUS == 'True') ? true : false);
  }

  if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FLATCANADA_ZONE > 0) ) {
    $check_flag = false;
    $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_FLATCANADA_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
    while (!$check->EOF) {
      if ($check->fields['zone_id'] < 1) {
        $check_flag = true;
        break;
      } elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
        $check_flag = true;
        break;
      }
      $check->MoveNext();
    }

    if ($check_flag == false) {
      $this->enabled = false;
    }
  }
}

// class methods
function quote($method = '') {
global $order;

  $this->quotes = array('id' => $this->code,
                        'module' => MODULE_SHIPPING_FLATCANADA_TEXT_TITLE,
                        'methods' => array(array('id' => $this->code,
                                                 'title' => MODULE_SHIPPING_FLATCANADA_TEXT_WAY,
                                                 'cost' => MODULE_SHIPPING_FLATCANADA_COST)));
  if ($this->tax_class > 0) {
    $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
  }

  if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);

  return $this->quotes;
}

function check() {
  global $db;
  if (!isset($this->_check)) {
    $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_FLATCANADA_STATUS'");
    $this->_check = $check_query->RecordCount();
  }
  return $this->_check;
}

function install() {
  global $db;
  $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable FLATCANADA Shipping', 'MODULE_SHIPPING_FLATCANADA_STATUS', 'True', 'Do you want to offer FLATCANADA rate shipping?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
  $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Cost', 'MODULE_SHIPPING_FLATCANADA_COST', '5.00', 'The shipping cost for all orders using this shipping method.', '6', '0', now())");
  $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_FLATCANADA_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())");
  $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Tax Basis', 'MODULE_SHIPPING_FLATCANADA_TAX_BASIS', 'Shipping', 'On what basis is Shipping Tax calculated. Options are<br />Shipping - Based on customers Shipping Address<br />Billing Based on customers Billing address<br />Store - Based on Store address if Billing/Shipping Zone equals Store zone', '6', '0', 'zen_cfg_select_option(array(\'Shipping\', \'Billing\', \'Store\'), ', now())");
  $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_FLATCANADA_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())");
  $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_FLATCANADA_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
}

function remove() {
  global $db;
  $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key like 'MODULE\_SHIPPING\_FLATCANADA\_%'");
}

function keys() {
  return array('MODULE_SHIPPING_FLATCANADA_STATUS', 'MODULE_SHIPPING_FLATCANADA_COST', 'MODULE_SHIPPING_FLATCANADA_TAX_CLASS', 'MODULE_SHIPPING_FLATCANADA_TAX_BASIS', 'MODULE_SHIPPING_FLATCANADA_ZONE', 'MODULE_SHIPPING_FLATCANADA_SORT_ORDER');
}

}
?>

includes/languages/english/modules/shipping
flatcanada.php

define('MODULE_SHIPPING_FLATCANADA_TEXT_TITLE', 'Flat Rate');
define('MODULE_SHIPPING_FLATCANADA_TEXT_DESCRIPTION', 'Flat Rate');
define('MODULE_SHIPPING_FLATCANADA_TEXT_WAY', 'Best Way');
?>

includes/languages/english/modules/mytemplate/shipping
flatcanada.php

define('MODULE_SHIPPING_FLATCANADA_TEXT_TITLE', 'Shipping to Canada<br>');
define('MODULE_SHIPPING_FLATCANADA_TEXT_DESCRIPTION', 'FLATCANADA Rate');
define('MODULE_SHIPPING_FLATCANADA_TEXT_WAY', 'Shipping to Canada on orders under $350 - Approx. 10-15 Business Days from when the manufacturer ships to us. Less if we have it in our own stock. Free shipping is available within Canada on orders over $350.');
?>

Attachment 10892

28 Jul 2012, 10:54 PM
#14
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Clone Flat Rate Shipping with Zone

Delete those files and start over ...

Copy the files:
/includes/modules/shipping/flat.php
/includes/languages/english/modules/shipping/flat.php

to the files:
/includes/modules/shipping/flatcanada.php
/includes/languages/english/modules/shipping/flatcanada.php

Now edit the new files:
/includes/modules/shipping/flatcanada.php
/includes/languages/english/modules/shipping/flatcanada.php

and do replacements ... these are case sensative ...

Where you see:
flat (lower case) replace with flatcanada (lower case)

Where you see:
FLAT (UPPER case) replace with FLATCANADA (UPPER case)

Now load the files to the server ...

Do you see any errors?

If not, Install the flatcanada module and configure it ...

Make sure that the Sort Order is a unique value that is NOT 0 ( NOT zero) ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

28 Jul 2012, 11:58 PM
#15
nfallat avatar

nfallat

New Zenner

Join Date:
Jan 2009
Posts:
84
Plugin Contributions:
0

Re: Clone Flat Rate Shipping with Zone

I was more detailed on the case as you said but still same problem, same error message. And when you say if no message then install the module, it installs by itself once the files are uploaded, shows red status, no sort order (but if you click edit it's sort 4) and can't remove it without deleting the flatcanada files. Here is the code one more time. I was sure if I was supposed to change "flat" at the top $Id but I did this time.

// $Id: flatcanada.php 14498 2009-10-01 20:16:16Z ajeh $
//

class flatcanada {
var $code, $title, $description, $icon, $enabled;

// class constructor
function flatcanada() {
global $order, $db;

  $this->code = 'flatcanada';
  $this->title = MODULE_SHIPPING_FLATCANADA_TEXT_TITLE;
  $this->description = MODULE_SHIPPING_FLATCANADA_TEXT_DESCRIPTION;
  $this->sort_order = MODULE_SHIPPING_FLATCANADA_SORT_ORDER;
  $this->icon = '';
  $this->tax_class = MODULE_SHIPPING_FLATCANADA_TAX_CLASS;
  $this->tax_basis = MODULE_SHIPPING_FLATCANADA_TAX_BASIS;

  // disable only when entire cart is free shipping
  if (zen_get_shipping_enabled($this->code)) {
    $this->enabled = ((MODULE_SHIPPING_FLATCANADA_STATUS == 'True') ? true : false);
  }

  if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FLATCANADA_ZONE > 0) ) {
    $check_flag = false;
    $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_FLATCANADA_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
    while (!$check->EOF) {
      if ($check->fields['zone_id'] < 1) {
        $check_flag = true;
        break;
      } elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
        $check_flag = true;
        break;
      }
      $check->MoveNext();
    }

    if ($check_flag == false) {
      $this->enabled = false;
    }
  }
}

// class methods
function quote($method = '') {
global $order;

  $this->quotes = array('id' => $this->code,
                        'module' => MODULE_SHIPPING_FLATCANADA_TEXT_TITLE,
                        'methods' => array(array('id' => $this->code,
                                                 'title' => MODULE_SHIPPING_FLATCANADA_TEXT_WAY,
                                                 'cost' => MODULE_SHIPPING_FLATCANADA_COST)));
  if ($this->tax_class > 0) {
    $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
  }

  if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);

  return $this->quotes;
}

function check() {
  global $db;
  if (!isset($this->_check)) {
    $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_FLATCANADA_STATUS'");
    $this->_check = $check_query->RecordCount();
  }
  return $this->_check;
}

function install() {
  global $db;
  $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Flatcanada Shipping', 'MODULE_SHIPPING_FLATCANADA_STATUS', 'True', 'Do you want to offer flatcanada rate shipping?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
  $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Cost', 'MODULE_SHIPPING_FLATCANADA_COST', '5.00', 'The shipping cost for all orders using this shipping method.', '6', '0', now())");
  $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_FLATCANADA_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())");
  $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Tax Basis', 'MODULE_SHIPPING_FLATCANADA_TAX_BASIS', 'Shipping', 'On what basis is Shipping Tax calculated. Options are<br />Shipping - Based on customers Shipping Address<br />Billing Based on customers Billing address<br />Store - Based on Store address if Billing/Shipping Zone equals Store zone', '6', '0', 'zen_cfg_select_option(array(\'Shipping\', \'Billing\', \'Store\'), ', now())");
  $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_FLATCANADA_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())");
  $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_FLATCANADA_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
}

function remove() {
  global $db;
  $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key like 'MODULE\_SHIPPING\_FLATCANADA\_%'");
}

function keys() {
  return array('MODULE_SHIPPING_FLATCANADA_STATUS', 'MODULE_SHIPPING_FLATCANADA_COST', 'MODULE_SHIPPING_FLATCANADA_TAX_CLASS', 'MODULE_SHIPPING_FLATCANADA_TAX_BASIS', 'MODULE_SHIPPING_FLATCANADA_ZONE', 'MODULE_SHIPPING_FLATCANADA_SORT_ORDER');
}

}
?>

// $Id: flatcanada.php 1969 2005-09-13 06:57:21Z drbyte $
//

define('MODULE_SHIPPING_FLATCANADA_TEXT_TITLE', 'Flat Rate');
define('MODULE_SHIPPING_FLATCANADA_TEXT_DESCRIPTION', 'Flat Rate');
define('MODULE_SHIPPING_FLATCANADA_TEXT_WAY', 'Best Way');
?>

// $Id: flatcanada.php 1969 2005-09-13 06:57:21Z drbyte $
//

define('MODULE_SHIPPING_FLATCANADA_TEXT_TITLE', 'Regular Ground Shipping within Continental US (See Policies)<br>');
define('MODULE_SHIPPING_FLATCANADA_TEXT_DESCRIPTION', 'Flat Rate');
define('MODULE_SHIPPING_FLATCANADA_TEXT_WAY', 'Ground Shipping in Continental US. on orders under $175 - Approx. 10-15 Business Days from when the manufacturer ships to us. Less if we have it in our own stock. Free shipping is available within continental US on orders over $175 and international orders over $350.');
?>

29 Jul 2012, 2:46 AM
#16
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Clone Flat Rate Shipping with Zone

Do both of your files start with:

<?php What does the language file have in it, you posted two different things ... What is the exact error you see? If I use your files, using the one set of the language defines and adding the missing: <?php to the tops of the files ... I am not getting errors ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

29 Jul 2012, 3:36 AM
#17
nfallat avatar

nfallat

New Zenner

Join Date:
Jan 2009
Posts:
84
Plugin Contributions:
0

Re: Clone Flat Rate Shipping with Zone

Yes, <?php is at the top of the files above the zencart info. I included the code for both includes/languages/english/modules/shipping AND includes/languages/english/modules/cambridge_pro/shipping. Like I said, I am always under the assumption that the file(s) in the customer folders are the ones being read. I did try uploading the files to the default folder first (error message in admin) and then uploaded it to the customer folder as well, still error message in admin. The error message in the admin is "WARNING: YOU HAVE DUPLICATE SORT ORDERS WHICH WILL RESULT IN CALCULATION ERRORS PLEASE CORRECT THESE ISSUES NOW! "

But when I go in to edit the shipping module, now on the list in the admin after uploading the flatcanada files, it does not recognize the click on the Action button. It does show the setup in the box to the right (see screenshots above) but the sort in the box says 4. I can edit this sort but it does not update the sort order in the modules list (again see above which shows NO sort order). Editing the module in the admin appears to have no effect. And "Removing" it in the admin has no effect. Only is removed when I delete the files.

I owe you a "cup of coffee!"

29 Jul 2012, 1:16 PM
#18
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Clone Flat Rate Shipping with Zone

Go to your Tools ... Install SQL Patches ... and enter:
delete FROM configuration WHERE configuration_key LIKE '%flatcanada%';

Now go to the Modules ... Shipping ...

1 do you see the flatcanada uninstalled?

2 do you see all of the shipping modules listed and the blue panel on the right?

3 do you see any error messages?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

29 Jul 2012, 5:56 PM
#19
nfallat avatar

nfallat

New Zenner

Join Date:
Jan 2009
Posts:
84
Plugin Contributions:
0

Re: Clone Flat Rate Shipping with Zone

I inserted your patch and it did NOT uninstall the flatcanada module BUT error message is gone and I was able to successfully click on the Action button, set up the cost and sort order and update.

The flatcanada shipping option is now available at checkout, if Canadian shipping address is used, which is what I was wanting.

So, I think it is finally working. Your patch seems to have worked!

I really appreciate all of your efforts, not only on this, but all over the forum where you seem to be very active on many issues.

29 Jul 2012, 6:02 PM
#20
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Clone Flat Rate Shipping with Zone

Just to be sure ...

I would go to the Modules ... Shipping ... and see if the REMOVE and INSTALL work on your Flat Canada shipping module ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!