Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Hiding non-applicable shipping options at checkout


TerryK

Recommended Posts

I've set up a number of shipping options in my store:

 

- 2 region-based methods for Canadian provinces

- Table-based method for US shipping

- 2 table-based methods for international orders

 

When testing the cart, I'm noticing that customers in the US and international locations also get Canadian shipping options displayed at checkout, though they do note that the method isn't available to the area selected. US options don't display to international customers, and international options don't display for US customers, so I presume the issue must be in the Canadian shipping file.

 

Is there a way to make it so that the Canadian shipping methods are ONLY displayed to Canadian customers? I noticed that the table-based methods for both US and international have a drop-down field in admin to select the zone for shipping, but the Canadian one doesn't -- only specification of Canadian provinces for regions. I'm not sure if I can add a drop-down in the Canadian regions files to select the country first, but I have a feeling that may solve it. Any ideas?

 

If you want to see it in action, my store is at:

 

http://www.kididdles.com/catalog

 

Thanks,

 

Terry

Edited by TerryK

Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Link to comment
Share on other sites

Hi Terry, your feeling is right.

If you do not or can not designate a specific shipping zone in the shipping-module all world will see it.

Add a shipping zone dropdown, will not be to difficult because you have the examples in the tables, zones, flat. item modules.

In the dropdown all countries mentioned in the TaxZones must be visible to choose from.

 

If you treat the Tax Zones as being Area Zones you will know what I mean.

 

And if shipping charges are different for different areas in Canada, you will also need to subdivide Canada there (in Tax Zones) into postal zones or something similar.

 

Click on Details and then Insert and add the postal zone.

"If you're working on something new, then you are necessarily an amateur."

Link to comment
Share on other sites

Hi John,

 

Thanks for replying!

 

Hi Terry, your feeling is right.

And if shipping charges are different for different areas in Canada, you will also need to subdivide Canada there (in Tax Zones) into postal zones or something similar.

 

Click on Details and then Insert and add the postal zone.

 

I have three separate regional areas for Canada.

 

When I go into the Tax Zones area in admin, am I correct that I have to add each province separately? Do you know if there is a way to get it to let me select multiple provinces for a single zone? If so, I couldn't find it.

 

So far, I've added them all separately. When I go through checkout, the option no longer appears for US and international customers (a good thing!), but I also can't get it to display for Canadian orders now (a bad thing!). I'm not sure what I'm doing wrong, but obviously something...

 

Thanks,

 

Terry

Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Link to comment
Share on other sites

Hi Terry,

 

Hi John,

 

Thanks for replying!

I have three separate regional areas for Canada.

 

When I go into the Tax Zones area in admin, am I correct that I have to add each province separately? Do you know if there is a way to get it to let me select multiple provinces for a single zone? If so, I couldn't find it.

In Tax'GEO'Zones make :CAN_0 [the whole of CAN (if applicable)] Can_1, Can_2 and Can_3 (your regional ?reas) and to each region add with 'Detail and Insert' the provinces you want there.

And in Zones (!) you'll have to first add those provinces (if you deleted them) otherwise you are not able to choose them in TaxZones under ?nsert'.

Than in the shipping dropdown you can choose from 4 possibilities.

 

So far, I've added them all separately. When I go through checkout, the option no longer appears for US and international customers (a good thing!), but I also can't get it to display for Canadian orders now (a bad thing!). I'm not sure what I'm doing wrong, but obviously something...

Terry

See higher up, add the provinces to Zones if they are not there anymore.

 

If you look at the original osC-SQL file in txt-mode in your txt-editor (or import it as a temp database, BACK-UP the valid one first) you'll see what I mean, Canada in 'Zones' has already 13 provinces, those you can divide in 3 and add all of them to the regional areas Can_1,-2 and -3.

Edited by berkedam

"If you're working on something new, then you are necessarily an amateur."

Link to comment
Share on other sites

Thanks for your help, John!

 

I couldn't make the region-based shipping module work, so I duplicated (times 6!) the table method and was then able to specify the correct zones/prices for each - one for regular parcel post and another for rush shipping.

 

Thanks for helping me solve one more issue on my way to store launch on Friday! (I hope...) :)

 

Terry

Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Link to comment
Share on other sites

Thanks for your help, John!

 

I couldn't make the region-based shipping module work, so I duplicated (times 6!) the table method and was then able to specify the correct zones/prices for each - one for regular parcel post and another for rush shipping.

 

Thanks for helping me solve one more issue on my way to store launch on Friday! (I hope...) :)

 

Terry

Maybe i'll take a peek from here (Edam, NL) to there :D

"If you're working on something new, then you are necessarily an amateur."

Link to comment
Share on other sites

Please do! I'd love the feedback. (I have a post in the 'store' forum as well...)

 

Terry

Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Link to comment
Share on other sites

Okay, now I'm totally stumped...

 

Similar to what I need for my multiple shipping methods for Canada, I'm trying to make multiple options for US delivery.

 

First step, I went into geo_zones and divided the states into 7 different regions, then created a new set of table.php files for airmail delivery for them, named usa1air, usa2air, etc. That works great!

 

I then duplicated and renamed my first 7 sets of files to usa1exp, usa2exp, etc. Installs up to USA region 3 work fine. As soon as I try to install region 4, I get this error:

 

Warning: shipping(includes/languages/english/modules/shipping/usa7a): failed to open stream: No such file or directory in /raid/home/kididdles/kididdles/catalog/includes/classes/shipping.php on line 36

Warning: shipping(): Failed opening 'includes/languages/english/modules/shipping/usa7a' for inclusion (include_path='.:/usr/local/scripts/php-4310/lib/php') in /raid/home/kididdles/kididdles/catalog/includes/classes/shipping.php on line 36

Warning: shipping(includes/modules/shipping/usa7a): failed to open stream: No such file or directory in /raid/home/kididdles/kididdles/catalog/includes/classes/shipping.php on line 37

Warning: shipping(): Failed opening 'includes/modules/shipping/usa7a' for inclusion (include_path='.:/usr/local/scripts/php-4310/lib/php') in /raid/home/kididdles/kididdles/catalog/includes/classes/shipping.php on line 37

Fatal error: Cannot instantiate non-existent class: in /raid/home/kididdles/kididdles/catalog/includes/classes/shipping.php on line 39

 

I've checked both my usa7air.php and usa4exp.php files -- in both /includes/modules/shipping and /includes/languages/english/modules/shipping and can't see anything in them that would trigger this! I don't understand why regions 1-7 work fine for the airmail option, but usa7air seems to be triggering an error when I try to install usa4exp.

 

Please help... I'll soon be bald if I don't figure this out soon!

 

Thanks,

 

Terry

Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Link to comment
Share on other sites

The error says: includes/languages/english/modules/shipping/usa7a

 

You are writing that the file is called: usa7air.

 

Also maybe re-create: usa4exp?

 

Check (again) that the right files are in the right directory?

"If you're working on something new, then you are necessarily an amateur."

Link to comment
Share on other sites

I know for sure that usa7air.php works.

 

I have uninstalled usa4exp.php then recreated it using a copy of usa3exp.php, which I know works.

 

I have scoured the shipping module and language files and can't see anything wrong with the code compared to what works for usa3exp. There are no extraneous spaces at the end of the file, no references to 'usa7a' in the file -- nothing! See code below.

 

/catalog/includes/modules/shipping/usa4exp.php:

 

<?php
/*
 $Id: usa4exp.php,v 1.27 2003/02/05 22:41:52 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

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

// class constructor
   function usa4exp() {
     global $order;

     $this->code = 'usa4exp';
     $this->title = MODULE_SHIPPING_USA4EXP_TEXT_TITLE;
     $this->description = MODULE_SHIPPING_USA4EXP_TEXT_DESCRIPTION;
     $this->sort_order = MODULE_SHIPPING_USA4EXP_SORT_ORDER;
     $this->icon = '';
     $this->tax_class = MODULE_SHIPPING_USA4EXP_TAX_CLASS;
     $this->enabled = ((MODULE_SHIPPING_USA4EXP_STATUS == 'True') ? true : false);

     if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_USA4EXP_ZONE > 0) ) {
       $check_flag = false;
       $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_USA4EXP_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
       while ($check = tep_db_fetch_array($check_query)) {
         if ($check['zone_id'] < 1) {
           $check_flag = true;
           break;
         } elseif ($check['zone_id'] == $order->delivery['zone_id']) {
           $check_flag = true;
           break;
         }
       }

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

// class methods
   function quote($method = '') {
     global $order, $cart, $shipping_weight, $shipping_num_boxes;

     if (MODULE_SHIPPING_USA4EXP_MODE == 'price') {
       $order_total = $cart->show_total();
     } else {
       $order_total = $shipping_weight;
     }

     $usa4exp_cost = split("[:,]" , MODULE_SHIPPING_USA4EXP_COST);
     $size = sizeof($usa4exp_cost);
     for ($i=0, $n=$size; $i<$n; $i+=2) {
       if ($order_total <= $usa4exp_cost[$i]) {
         $shipping = $usa4exp_cost[$i+1];
         break;
       }
     }

     if (MODULE_SHIPPING_USA4EXP_MODE == 'weight') {
       $shipping = $shipping * $shipping_num_boxes;
     }

     $this->quotes = array('id' => $this->code,
                           'module' => MODULE_SHIPPING_USA4EXP_TEXT_TITLE,
                           'methods' => array(array('id' => $this->code,
                                                    'title' => MODULE_SHIPPING_USA4EXP_TEXT_WAY,
                                                    'cost' => $shipping + MODULE_SHIPPING_USA4EXP_HANDLING)));

     if ($this->tax_class > 0) {
       $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
     }

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

     return $this->quotes;
   }

   function check() {
     if (!isset($this->_check)) {
       $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_USA4EXP_STATUS'");
       $this->_check = tep_db_num_rows($check_query);
     }
     return $this->_check;
   }

   function install() {
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Enable Table Method', 'MODULE_SHIPPING_USA4EXP_STATUS', 'True', 'Do you want to offer table rate shipping?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Table', 'MODULE_SHIPPING_USA4EXP_COST', '25:8.50,50:5.50,10000:0.00', 'The shipping cost is based on the total cost or weight of items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, etc', '6', '0', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Table Method', 'MODULE_SHIPPING_USA4EXP_MODE', 'weight', 'The shipping cost is based on the order total or the total weight of the items ordered.', '6', '0', 'tep_cfg_select_option(array(\'weight\', \'price\'), ', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_USA4EXP_HANDLING', '0', 'Handling fee for this shipping method.', '6', '0', now())");
     tep_db_query("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_USA4EXP_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");
     tep_db_query("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_USA4EXP_ZONE', '0', '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())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_USA4EXP_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
   }

   function remove() {
     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
   }

   function keys() {
     return array('MODULE_SHIPPING_USA4EXP_STATUS', 'MODULE_SHIPPING_USA4EXP_COST', 'MODULE_SHIPPING_USA4EXP_MODE', 'MODULE_SHIPPING_USA4EXP_HANDLING', 'MODULE_SHIPPING_USA4EXP_TAX_CLASS', 'MODULE_SHIPPING_USA4EXP_ZONE', 'MODULE_SHIPPING_USA4EXP_SORT_ORDER');
   }
 }
?>

 

/catalog/includes/languages/english/modules/shipping/usa4exp.php

 

<?php
/*
 $Id: usa4exp.php,v 1.5 2002/11/19 01:48:08 dgw_ Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2002 osCommerce

 Released under the GNU General Public License
*/

define('MODULE_SHIPPING_USA4EXP_TEXT_TITLE', 'US Xpresspost: Region 4');
define('MODULE_SHIPPING_USA4EXP_TEXT_DESCRIPTION', 'US Xpresspost: Region 4');
define('MODULE_SHIPPING_USA4EXP_TEXT_WAY', '5-7 business days');
define('MODULE_SHIPPING_USA4EXP_TEXT_WEIGHT', 'Weight');
define('MODULE_SHIPPING_USA4EXP_TEXT_AMOUNT', 'Amount');
?>

 

Do you see anything there that looks out of place? I sure can't.

 

Just a thought, but could there possibly be a maximum number of files allowed for table methods? Since it breaks when I get to the 11th file, I wonder if somewhere there's something stating that there can be no more than 10, but would have no idea where to find that.

 

Thanks,

 

Terry

Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Link to comment
Share on other sites

It's just very much Fridaymorning overhere so I looked at yr site

 

And searched the forum.

 

Just a quick reply, because it's much past bedtime.

 

Don't know about max. # of shipping modules but seem to remember that long ago I had the same problem once, will try to remember what it was.

 

You did not by any chance forget to give all yr shipping modules a sort order?

That's for the moment the only thing that comes to mind.

 

I have 11 shipping possibilities (trial site) and they work all and they do all have a sort order.

"If you're working on something new, then you are necessarily an amateur."

Link to comment
Share on other sites

Hi John,

 

I tried with sort order specified, with sort fields blank, and with sort fields all set to zero. No matter which way I do it, as soon as I get to usa4exp (or skipping that and trying usa5, usa6 or usa7), I get the error message.

 

So much for my Friday launch... sigh. I *so* want to get this fixed!

 

Thanks for taking the time to help -- again. :-)

 

Terry

Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Link to comment
Share on other sites

AHA! I think I've figured it out!

 

In the database, the configuration value for MODULE_SHIPPING_INSTALLED is 255 characters. With the file names I've given my shipping modules, I exceed that amount. The 255th character is the the 'a' at the end of 'usa7a.' So... if I can crop the names so the total is less than 255, I should have this thing solved. Will post if I'm right.

 

Terry

Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Link to comment
Share on other sites

That was definitely the problem -- by shortening the file names so the total was less than 255 characters, it works! Hurray!

 

:)

 

Terry

Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Link to comment
Share on other sites

This was one of those problems that I don't think I'll EVER forget the answer to -- what a waste of two days along the way...

 

Anyhow, I was a few hours late, but I did manage to get the store open for business tonight. (Yay!)

 

Thanks for your help on the shipping issues, John. I appreciate it!

 

Terry

Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

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.
Note: Your post will require moderator approval before it will be visible.

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...