Jump to content
Latest News: (loading..)
imageanative

canada.post.rest.rate.service.oscommerce.V2.3

Recommended Posts

Canada Post changed its previous Sell Online services with the new REST or SOAP services. Searching the web or in the community contributions, cannot find anything based on this new services. So I decided to write my own module.( Sean Zhuang)

Canada POST Rates (REST) Service Module for osCommerce 2.3.1 2012-10-01

well i tried to install getting error "unknown error from Canada Post"

as well as others anyone wanna help with this?

http://addons.oscommerce.com/info/8887

Share this post


Link to post
Share on other sites

This should probably be moved to the Addons - Shipping forum...

 

I will try and download in the next couple of weeks to see if I can make it work... I have an Canada Post automatic labels mod based on REST (that is very roughly written... but works). Maybe we can get both refined and working together...

Share this post


Link to post
Share on other sites

This should probably be moved to the Addons - Shipping forum...

 

I will try and download in the next couple of weeks to see if I can make it work... I have an Canada Post automatic labels mod based on REST (that is very roughly written... but works). Maybe we can get both refined and working together...

 

Great thanks Greasemonkey lets do it

Edited by imageanative

Share this post


Link to post
Share on other sites

install fresh 2.3.1 OSC copied all files into the folders and installed db Sql and got the error

1054 - Unknown column 'cd.categories_banner' in 'field list'

 

select c.categories_id, cd.categories_name, cd.categories_banner, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified from categories c, categories_description cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id = '1' order by c.sort_order, cd.categories_name

 

I will try a manual install .

in the catalog got this message

 

(unknown error from Canada Post

yourwebsite via e-mail)

Share this post


Link to post
Share on other sites

Hi Guys, I am not a coder at all. I have the Canada Post module installed that is returning accurate shipping rates for the orders via Sell Online. With a client's order I do have the button to generate a CP Label which i can click; confirm the service, weight, dimensions and options for the shipment. In the portal window I confirm my OSC login and it goes off to do its work but generates simply code and at the bottom Step 1:Initialized but WEB SERVER ERROR after that inside that progress indicator portal. Is there a CP Label function available for OS Commerce? I am 2.3.1 user.

 

Cheers, Bruce

Share this post


Link to post
Share on other sites

Hi Guys, I am not a coder at all. I have the Canada Post module installed that is returning accurate shipping rates for the orders via Sell Online. With a client's order I do have the button to generate a CP Label which i can click; confirm the service, weight, dimensions and options for the shipment. In the portal window I confirm my OSC login and it goes off to do its work but generates simply code and at the bottom Step 1:Initialized but WEB SERVER ERROR after that inside that progress indicator portal. Is there a CP Label function available for OS Commerce? I am 2.3.1 user.

 

Cheers, Bruce

 

Hey Bruce,

 

The propblem is Canada post server related as we can no longer get quotes since the 28th, so there was obviously a change on the Canada posts server. I haven't looked at the problem yet but there is going to be an update to the shipping modules, so keep posted.

Share this post


Link to post
Share on other sites

Hi Guys, I am not a coder at all. I have the Canada Post module installed that is returning accurate shipping rates for the orders via Sell Online. With a client's order I do have the button to generate a CP Label which i can click; confirm the service, weight, dimensions and options for the shipment. In the portal window I confirm my OSC login and it goes off to do its work but generates simply code and at the bottom Step 1:Initialized but WEB SERVER ERROR after that inside that progress indicator portal. Is there a CP Label function available for OS Commerce? I am 2.3.1 user.

 

Cheers, Bruce

 

OK so once you have your login and user setup @ canada post its best to print out your labels on the canada post website http://www.canadapost.ca/eb/business/?LOCALE=en business account your discounts will be added this was and is the best bet.

by the way i use 2 different modules and combine the 2

 

http://addons.oscommerce.com/info/391

http://addons.oscommerce.com/info/8887

 

this way you get Dimension Support

Peace

Edited by imageanative

Share this post


Link to post
Share on other sites

A work-around that needs to be added to the Canada Post label module to deal with the upgrade this past spring (2013) by Canada Post.

 

 

It appears that a double post of https://obc.canadapost.ca/zcpb2b/b2b/zisa_choice.do?targetPage=eorder&language=EN

 

is needed to get the admin side of Automatic labels to work.

 

The first time the software sends the id and password, then the second time it simply simply send https://obc.canadapost.ca/zcpb2b/b2b/zisa_choice.do?targetPage=eorder&language=EN again.

 

Alternatively it may be that you have to double post:

 

https://www.canadapost.ca/cpid/apps/signIn

 

instead, one of them will work the best...

 

I will see what I can do to get this running and post the results.

 

This will shift to the EST (Electronic Shipping Tools) page where you then select Canada/US/International (or at least the software then can take over.

 

Should work until someone makes an easy way to integrate REST or SOAP to OSC.

 

 

John :-#)#

Edited by Pinball

Share this post


Link to post
Share on other sites

Any news on the Canada Post shipping front with respect to OSC ?

 

I'd love to get real-time rates based on dimensions, weight, source postal code and destination postal code. I'm trying to follow all these various threads and cannot even determine if any of the contribs work at all ?


Best & Thanks;
Marvin
----------------------
osCommerce 2.3.3.4 

Share this post


Link to post
Share on other sites

Any news on the Canada Post shipping front with respect to OSC ?

 

I'd love to get real-time rates based on dimensions, weight, source postal code and destination postal code. I'm trying to follow all these various threads and cannot even determine if any of the contribs work at all ?

 

The Canada Post Shipping Module - http://addons.oscommerce.com/info/391 - works just fine. My customers use it all the time...

 

It is the admin side of things that is broken - the Canada Post Automated Labels (CPAL) bit from http://addons.oscommerce.com/info/5842, this is where one needs to either integrate the REST module from http://addons.oscommerce.com/info/8887 or figure out the code to fix the java script breakdown that I mention. CPAL for the admin is a simple checkscreen where you make sure the data going to CP is correct, and you then click the 'submit' button and the script did the rest.

 

Anyone in Vancouver, BC area of Canada who wants to work with me on sorting this out? I'm sure two people and some tea/coffee and an afternoon can figure out how to fix the code.

 

You see the CP Automated Labels (CPAL) - almost - works. It is breaking down after the login page, it now goes to a page that requires java script to get out of and the original CPAL didn't see this page. Oddly enough if you manually put the page URLs in twice it DOES go to the correct page to fill in for the Domestic, US, or International customer's field entries and would probably work from there. I just don't know enough coding to figure out how to get around that second page.

Share this post


Link to post
Share on other sites

The Canada Post Shipping Module - http://addons.oscommerce.com/info/391 - works just fine. My customers use it all the time...

 

 

 

I am using osCommerce 2.2ms2, I had the Canada Post module (not sure what add-on it was, we just uninstalled to install this add on) was working for years and then I started getting errors (would not retrieve current shipping rates). you say that http://addons.oscommerce.com/info/391 still works and will return shipping rates. Is that true?

 

We since have installed this (Above) add-on and we are getting the "unknown error from Canada Post", we just need to offer Canada Post rates. Fedex works but it is a little more pricey.  any help would be great.

 

DB 

Share this post


Link to post
Share on other sites

Hello,

I am also getting the same error as "simple190"

 

"unknown error from Canada Post",

 

 

It is happening in the checkout when try to show sipping options.

 

Also is there any way to make it print out the error code it is getting?

 

I am running this on Version: 2.3.3.4

 

Thanks,

Share this post


Link to post
Share on other sites

I am running version: 2.3.3.4. on localhost.

 

I'm trying to install the canada.post.rest.rate.service.oscommerce.V2.3 module and I get this error:

 

Warning: constant() [function.constant]: Couldn't find constant CANADA_POST_Array in /srv/www/htdocs/catalogtest/includes/modules/shipping/canadapost.php on line 444

 

I can not find where the CANADA_POST_ constant is defined in any of the code. How can I fix this?

 

Also, is there are better better Canada post module? I tried the Canada Post Sell Online v1.0 module http://addons.oscommerce.com/info/7900, but it is not a true 2.3 add on. A fresh 2.3 version if template based and that module is not.

 

Print labels is not a big feature for me. However, I would like to add dimensional support.

 

Thanks.

Share this post


Link to post
Share on other sites

The bit of code that the error is coming from is:

function get_multioption_canadapost_xml($values) 
{
	 if (tep_not_null($values)) {
		 $values_array = explode(',', $values);
		 foreach ($values_array as $key => $_method) {
		   if ($_method == '--none--') {
			 $method = $_method;
		   } else {
			 $method = constant('CANADA_POST_' .get_canada_post_service_code($_method));
		   }
		   $readable_values_array[] = $method;
		 }
		 $readable_values = implode(', ', $readable_values_array);
		 return $readable_values;
	 } else {
	   return '';
	 }
} 

There is another place where 'CANADA_POST_' is called.

 

In the same file the Canada Post related constants are stored on the db here:

    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 Canada Post Shipping Service(REST)', 'MODULE_SHIPPING_CANADA_POST_STATUS', 'True', 'Do you want to offer Canada Post 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 ('Canada Post Customer Number', 'MODULE_SHIPPING_CANADA_POST_CUSTOMER_NUMBER', '', 'Enter the Your Canada Post Customer Number.', '6', '1', now())");
        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Canada Post API Username', 'MODULE_SHIPPING_CANADA_POST_USERNAME', '', 'Enter your Canada Post (API Keys) username.', '6', '2', now())");
        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Canada Post API Password', 'MODULE_SHIPPING_CANADA_POST_PASSWORD', '', 'Enter your Canada Post (API Keys) password.', '6', '3', now())");

        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Canada Post Contract ID', 'MODULE_SHIPPING_CANADA_POST_CONTRACT_ID', '', 'Enter your Canada Post contract id (for commercial/contracted rates only).', '6', '4', 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 ('Canada Post Quote Type', 'MODULE_SHIPPING_CANADA_POST_QUOTE_TYPE', 'commercial', 'Either commercial (for the contract holder) or counter (regular price for consumers)', '6', '5', 'tep_cfg_select_option(array(\'commercial\', \'counter\'), ', 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 ('Enable Insurance', 'MODULE_SHIPPING_CANADA_POST_INSURE', 'True', 'Do you want to insure packages shipped by Canada Post?', '6', '6', '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 ('Origin City', 'MODULE_SHIPPING_CANADA_POST_CITY', '', 'Enter the name of the origin city.', '6', '7', now())");
        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Origin State/Province', 'MODULE_SHIPPING_CANADA_POST_STATEPROV', '', 'Enter the two-letter code for your origin state/province.', '6', '8', now())");
        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Origin Country', 'MODULE_SHIPPING_CANADA_POST_COUNTRY', '', 'Enter the two-letter code for your origin country.', '6', '9', now())");
        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Origin Zip/Postal Code', 'MODULE_SHIPPING_CANADA_POST_POSTALCODE', '', 'Enter your origin zip/postalcode (from which the parcel will be sent).', '6', '10', 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 ('Test or Production Mode', 'MODULE_SHIPPING_CANADA_POST_MODE', 'Test', 'Use this module in Test  or Production mode? <br /><br />Your API Keys username and password are different in Test and Production mode', '6', '11', 'tep_cfg_select_option(array(\'Test\', \'Production\'), ', 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 ('Disallowed Shipping Methods', 'MODULE_SHIPPING_CANADA_POST_TYPES', '', 'Select the Canada Post services <span style=\'color: red; font-weight: bold\'>not</span> to be offered.', '6', '12', 'get_multioption_canadapost_xml',  'canadapost_cfg_select_multioption(array(\'D.RP\',\'D.EP\',\'D.XP\',\'D.XP.CERT\',\'D.PC\',\'D.LIB\',\'U.EP\',\'U.PW.ENV\',\'U.PW.PAK\',\'U.PW.PARCEL\',\'U.SP.AIR\',\'U.SP.SURF\',\'U.XP\',\'I.XP\',\'I.IP.AIR\',\'I.IP.SURF\',\'I.PW.ENV\', \'I.PW.PAK\',\'I.PW.PARCEL\',\'I.SP.AIR\',\'I.SP.SURF\'),',  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 ('Handling Type', 'MODULE_SHIPPING_CANADA_POST_HANDLING_TYPE', 'Flat Fee', 'Handling type for this shipping method.', '6', '13', 'tep_cfg_select_option(array(\'Flat Fee\', \'Percentage\'), ', 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_CANADA_POST_HANDLING', '0', 'Handling fee for this shipping method.', '6', '14', 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_CANADA_POST_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '15', '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, date_added) values ('Sort order of display.', 'MODULE_SHIPPING_CANADA_POST_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '16', now())");

        // add key for enabling email error messages
        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 ('Email Canada Post errors', 'MODULE_SHIPPING_CANADA_POST_EMAIL_ERRORS', 'Yes', 'Do you want to receive Canada Post errors by email?', '6', '17', 'tep_cfg_select_option(array(\'Yes\', \'No\'), ', now())");
    } 

And they are placed in an array here:

function keys() {
        return array('MODULE_SHIPPING_CANADA_POST_STATUS','MODULE_SHIPPING_CANADA_POST_CUSTOMER_NUMBER','MODULE_SHIPPING_CANADA_POST_USERNAME',
'MODULE_SHIPPING_CANADA_POST_PASSWORD','MODULE_SHIPPING_CANADA_POST_CONTRACT_ID','MODULE_SHIPPING_CANADA_POST_QUOTE_TYPE',
'MODULE_SHIPPING_CANADA_POST_INSURE','MODULE_SHIPPING_CANADA_POST_CITY','MODULE_SHIPPING_CANADA_POST_STATEPROV','MODULE_SHIPPING_CANADA_POST_COUNTRY',
'MODULE_SHIPPING_CANADA_POST_POSTALCODE','MODULE_SHIPPING_CANADA_POST_MODE','MODULE_SHIPPING_CANADA_POST_TYPES','MODULE_SHIPPING_CANADA_POST_HANDLING_TYPE',
'MODULE_SHIPPING_CANADA_POST_HANDLING','MODULE_SHIPPING_CANADA_POST_TAX_CLASS','MODULE_SHIPPING_CANADA_POST_SORT_ORDER','MODULE_SHIPPING_CANADA_POST_EMAIL_ERRORS');
    } 

But nowhere is CANADA_POST_ defined. What am I missing?

Share this post


Link to post
Share on other sites

My guess is that you missed the changes starting at line 37 in admin/modules.php, which is where the arrays are handled.

 

Regards

Jim


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

Share this post


Link to post
Share on other sites

I am running version: 2.3.3.4. on localhost.

 

I'm trying to install the canada.post.rest.rate.service.oscommerce.V2.3 module...

 

I'd be very interested to hear from you on whether it works or not. There seems to be little recent info this mod. Please post back and let us know how it goes once it's sorted :)


Best & Thanks;
Marvin
----------------------
osCommerce 2.3.3.4 

Share this post


Link to post
Share on other sites

Thanks Jim. It was the admin/modules.php file. I thought the new file was up to the job and forgot I had left it there.

 

However, now I get the typical "unknown error from Canada Post
Grub 'n' Gear via Email." message at /catalog/checkout_shipping.php.

 

Another bit of strangeness is, the Canada Post option only shows up (with the error) if I have other certain options, like Flat Rate option available to the customer. If I do not have an alternative choice I get,

"error.gif Shipping is currently not available for the selected shipping address. Please select or create a new shipping address to use with your purchase." 

Any suggestions?

Share this post


Link to post
Share on other sites

It sounds like the module is not returning any results at all. In the module admin, set Email Canada Post errors to Yes and run a test order. You should get an email with some more information.

 

Regards

Jim


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

Share this post


Link to post
Share on other sites

With the error displaying Canada Post is not available to select, so I can not get any feedback from them. I have tried it with both the development and the production keys. Could it be that I am on localhost and it is a port issue?

Share this post


Link to post
Share on other sites

You will get an error email if anything is sent to Canada Post. If your email is working, I would assume that you are not actually sending the request, or the response is not being received. This could be a localhost problem, or it could be something else.

 

Regards

Jim


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

Share this post


Link to post
Share on other sites

Hello,

 

I am also getting the same error as "simple190"

 

 

It is happening in the checkout when try to show sipping options.

 

Also is there any way to make it print out the error code it is getting?

 

I am running this on Version: 2.3.3.4

 

Thanks,

 

When you are using the packaging side of Canada Post you must be SURE to have all your dimensions larger than or equal to 0.001 (units). Any zero value will result in either the module or CP rejecting the operation and your customer will not get a postal quote option and so they think the shipping is included (or not, depends on the customer). We had a heck of a time figuring this undocumented fault, and it was only after we had a few customers ordering particular items that we realized what was happening. Downloading the data dimensions and product # & name and then sorting by weight (ascending) found the ten items out of 4,000 that had zero weights. Did the same for Length, Width, and Height as there were a few there too.

Although in fact the database length dimensions default to 12, the weight defaults to 0.000 - so edit that to something like 0.010 (KGS/LBS) so you don't have that particular problem.

At this time I don't know how to get the error codes to display, however Canada Post Developers Site does provide you with the full set of error codes so you can implement them if you can (I can't so far - not proficient at PHP).

Edited by Pinball

Share this post


Link to post
Share on other sites

I've noticed that my USD based store seems to charge Canadian customers postage as if the rate calculated was in USD. So instead of a charge of $20CAD they get a charge of around $30USD. Calculating online gets the correct value of course. We do have CAD and USD as currency options for customers. US customers are not overcharged by the way...just Canadians!

 

Not sure where the currency setting is for the CP module, certainly not in the settings under admin!

 

I'm going to work on getting the REST or SOAP running for generating the labels, it takes too long for staff to type them in manually...

Share this post


Link to post
Share on other sites

Ignore my post #22 just above!

 

I was in error about the pricing in USD being wrong for Canadians - had forgotten to allow for insurance which is not a line item on the Canada Post rate quote. So the system does charge both US and Canadian customer correctly for the rate quote.

 

So sorry about the previous post just above (#22), I should have double checked prior to posting it.

 

Gah!

Share this post


Link to post
Share on other sites

Thanks Jim. It was the admin/modules.php file. I thought the new file was up to the job and forgot I had left it there.

 

However, now I get the typical "unknown error from Canada Post

Grub 'n' Gear via Email." message at /catalog/checkout_shipping.php.

 

Another bit of strangeness is, the Canada Post option only shows up (with the error) if I have other certain options, like Flat Rate option available to the customer. If I do not have an alternative choice I get,

"error.gif Shipping is currently not available for the selected shipping address. Please select or create a new shipping address to use with your purchase." 

Any suggestions?

 

Dan, did you get this resolved?

 

I've installed the Canada Post shipping module on OSCommerce Bootstrap Gold. 

 

I am getting the same error message and additionally, checking the Disallowed Shipping Methods doesn't stick either. For example, when I edit the module's options, click on some of the methods (mostly the world wide shipping methods), click save, they don't seem to stay.

 

I am not getting the "unknown error from Canada Post" message, just seeing "" Shipping is currently not available for the selected shipping address. Please select or create a new shipping address to use with your purchase." "

Edited by woodies

Share this post


Link to post
Share on other sites

Hi All, after the Canada Post blackout this weekend (and continuing) I switched from the old sellonline module to the newer REST module.

 

I have it working, and I'm making (trying to) some improvements.

 

1) the module doesn't have a shipping zone - fixed

2) the module doesn't have display the expected delivery date - fixed

 

HOWEVER, I'm trying to add a turnaround time and because the date is returned from Canada Post - i'm lost;

 

Anyone else working with this mod?

 

Here is what I have;

				$basetype = $canadaPostQuote[$i]['service-code'];
				$cost = $canadaPostQuote[$i]['due'];
				$type = $canadaPostQuote[$i]['service-name'];
				$ddate = $canadaPostQuote[$i]['expected-delivery-date'];

                if ($this->exclude_choices($basetype)) continue;
				
				$_type = $type;

				// changed to make handling percentage based
				if ($this->handling_type == "Percentage") {
					if ($_type) $methods[] = array('id' => $basetype, 'title' => $_type. ', '. $ddate, 'expected-delivery-date' => $ddate, 'cost' => ((($this->handling_fee * $cost)/100) + $cost));
				} else {
					if ($_type) $methods[] = array('id' => $basetype, 'title' => $_type. ', '. $ddate, 'cost' => ($this->handling_fee + $cost));
				}
            }

So the question is - how to I add (say 48 hours) to $ddate?

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

×