Page 1 of 1
Canada Post Module Port to 1.4
Posted: Thu Jan 14, 2010 6:20 am
by Stealth1
Can anyone tell me what has changed for the shipping modules? The current Canada Post Module is for 1.3.1 and I am hoping I can simply change a few things to get it to work with 1.4. I uploaded the files and it shows up but when you click install it still says disabled and when you hit edit it goes to a blank page.
Hopefully someone can help me with this.
I currently use OSC and was in the process of buidling a new OSC store but stumbled upon OpenCart and want to make the switch but my store is in Canada and I only use Canada Post for shipping.
Re: Canada Post Module Port to 1.4
Posted: Sun Jan 24, 2010 9:59 am
by X-Rayden
done :

Re: Canada Post Module Port to 1.4
Posted: Tue Jan 26, 2010 1:04 pm
by Stealth1
Thanks, just uploaded the files but I am getting the following errors when I try to save info into the admin side of the module.
Code: Select all
Notice: Undefined index: canadapost_language in /home/trplscom/public_html/tougetuning/opencarttest/admin/controller/shipping/canadapost.php on line 222
Code: Select all
Warning: Cannot modify header information - headers already sent by (output started at /home/trplscom/public_html/tougetuning/opencarttest/admin/index.php:59) in /home/trplscom/public_html/tougetuning/opencarttest/system/engine/controller.php on line 22
Re: Canada Post Module Port to 1.4
Posted: Wed Jan 27, 2010 2:07 am
by X-Rayden
I dont know why, but this kind of problems happens when charset are not the same...
is your charset utf-8 ?
Re: Canada Post Module Port to 1.4
Posted: Wed Jan 27, 2010 4:50 am
by Qphoria
Nah,. the issue is the first error.. the second error will go away if you fix the first error. Has nothing to do with charsets
Re: Canada Post Module Port to 1.4
Posted: Wed Jan 27, 2010 12:59 pm
by Stealth1
Removed all the files and then re-installed and still get the same error. I am no good with code so I am not sure what I am looking for. All I could find was that this sometimes happens when the words don't match exactly like "Canadapost_language" instead of "canadapost_language".
Here is what line 222 is
Code: Select all
221 //Set a default language immediately after install
222 if($this->request->post['canadapost_language'] == "") {
223 $this->request->post['canadapost_language'] = "en";
224 }
Re: Canada Post Module Port to 1.4
Posted: Wed Jan 27, 2010 1:33 pm
by Qphoria
At last resort, I do have a commercial canadapost mod that IS working fine with all versions.
Re: Canada Post Module Port to 1.4
Posted: Wed Apr 28, 2010 2:25 am
by Mucus
The error is an extremely simple one that means the variable isn't just equal to "", it isn't set at all. One way to fix line 222 is this:
Code: Select all
if(!isset($this->request->post['canadapost_language']) || $this->request->post['canadapost_language'] == "") {
Re: Canada Post Module Port to 1.4
Posted: Tue May 25, 2010 4:39 am
by VotreEspace
Re: Canada Post Module Port to 1.4
Posted: Wed May 26, 2010 8:41 am
by bmacdonald
I had to make some changes to get this to work properly, because it wasn't converting units (so if I had a product that weighed 90 grams, I got an error message "Error connecting to Canada Post" because it told CPC that my item weighed 90 kg, which is too heavy).
Changes to
catalog/model/shipping/canadapost.php, around line 121:
Code: Select all
$strXML .= " <weight>" . $this->weight->convert($result['weight'], $result['weight_class'], 'kg') . "</weight>\n";
$strXML .= " <length>" . $this->length->convert($result['length'], $result['length_class'], 'cm') . "</length>\n";
$strXML .= " <width>" . $this->length->convert($result['width'], $result['length_class'], 'cm') . "</width>\n";
$strXML .= " <height>" . $this->length->convert($result['height'], $result['length_class'], 'cm') . "</height>\n";
Same file, around line 150 - need better error messages:
Code: Select all
} else{
preg_match( '~<error>.*<statusMessage>\s*(.*)\s*</statusMessage>.*</error>~s' , $resultXML, $matches);
$error_details = isset($matches[1]) ? ': '.$matches[1] : '';
$return_error = $this->language->get('text_returnerror').$error_details;
}
I know I really should properly parse the XML, but this was a quick and dirty fix to help me with the really ambiguous and misleading message "Error connecting to Canada Post" (it was actually connecting just fine).
Changes to
admin/view/template/shipping/canadapost.tpl: There was a short open tag on line 220 causing some minor formatting issues. I changed it to "<?php"
Re: Canada Post Module Port to 1.4
Posted: Wed Jun 23, 2010 3:20 am
by VotreEspace
Re: Canada Post Module Port to 1.4
Posted: Tue Jun 29, 2010 3:33 am
by adamata
Hi, I'm having the same problem.
After clicking "continue" at the end of step 1 after entering personal details and address,
at the top of the page of step 2, it says as follows...
Warning: fsockopen() [function.fsockopen]: unable to connect to sellonline.canadapost.ca:30000 (Connection timed out) in /home/*****/public_html/store/catalog/model/shipping/canadapost.php on line 185
Further down right below where it says "Canada Post" (under Shipping Method) it displays the following message in red text.
"Error connecting to Canada Post"
Now, most of my products are around 175 grams and dimensions are in cm, so I thought it was a matter of converting measurements. So, I tried what was previously suggested and replaced the following 4 lines of code in canadapost.php.
$strXML .= " <weight>" . $this->weight->convert($result['weight'], $result['weight_class'], 'kg') . "</weight>\n";
$strXML .= " <length>" . $this->length->convert($result['length'], $result['length_class'], 'cm') . "</length>\n";
$strXML .= " <width>" . $this->length->convert($result['width'], $result['length_class'], 'cm') . "</width>\n";
$strXML .= " <height>" . $this->length->convert($result['height'], $result['length_class'], 'cm') . "</height>\n";
Unfortunately, I'm still getting the exact same result. I should mention that I have registered for a sellonline account with Canada Post and my extension is configured with my Canada Post Merchant ID I received from them. Everything in my Canada Post sell online profile are default settings, I haven't changed/modified anything.
The following are my Canada Post Extension settings.
Status: Enabled
Canada Post Server: sellonline.canadapost.ca
Canada Post Port: 30000
Canada Post Merchant ID: MY_MERCHANT_ID
Origin Postal Code: MY_POSTAL_CODE
Handling Cost: 0.00
Turn Around Time (Hours): 0
Use Original Packaging For All Products: No
Tax Class: None
Geo Zone: All Zones
Sort Order: BLANK
Please help... Thanks. 
Re: Canada Post Module Port to 1.4
Posted: Tue Jun 29, 2010 5:01 am
by Qphoria
A lot of hosts are disabling fsock for some reason in favor of curl. Curl is great but there is no good reason to disable fsock. Ask your host to allow fsock or the module will need to be changed to use curl to work for your servers
Re: Canada Post Module Port to 1.4
Posted: Tue Jun 29, 2010 10:08 am
by adamata
Hi Qphoria, thanks for the reply. I posted this issue and what you said about fsock on a forum of my webhost, and they said as follows.
"fsock isn't disabled, but opening arbitrary outgoing (and incoming) ports is... so in effect, you can't really use fsock.
The reason we disable it is because a lot of people write exploits using scripts that attack other servers' daemons running on arbitrary ports. "
If you know of any other way around this, please tell me. If not, I guess my only option is to change the module to use curl like you said. How sure are you that changing it to use curl will work? Do you forsee any other problems with this? Is there anything I should check with my webhost about before pursuing this?
If I have to do this, the other problem is I'm not familiar with curl, so I won't be able to do this myself. Can you point me somewhere or offer any advice on this situation?
Thanks again.
Re: Canada Post Module Port to 1.4
Posted: Tue Jun 29, 2010 9:27 pm
by Qphoria
i am 99.99999% sure curl will work as that is the only other popular option and all servers need a way of using server-to-server communication. Most payment modules like paypal, as well as UPS and FedEx all use curl to verify payments and get rates
Re: Canada Post Module Port to 1.4
Posted: Sat Jan 01, 2011 4:23 am
by bongobiggar
Did anyone get this to work am still trying to to and keep getting the fsock error if someone was successful converting over to curl can you please let me know.
thanks
Re: Canada Post Module Port to 1.4
Posted: Sat Jan 01, 2011 5:02 am
by Qphoria
Ok I've just added curl support to my
canada post module
Re: Canada Post Module Port to 1.4
Posted: Sun Aug 28, 2011 11:23 pm
by VotreEspace
Thanks Qphoria, that goes to show you get more support on a paid service !! (lol at the fact that i maintain the free one, when I can!)