Forums / Addon Shipping Modules / Implementing Purolator Shipping Module

Implementing Purolator Shipping Module

Locked

Views: 21,325

Results 1 to 20 of 53
This thread is locked. New replies are disabled.
19 Jul 2006, 3:10 PM
#1
wajdi avatar

wajdi

New Zenner

Join Date:
May 2006
Location:
Montreal, Quebec
Posts:
41
Plugin Contributions:
0

Implementing Purolator Shipping Module

Hey guys & gals,

My employer needs purolator shipping charges. So I decided to impelement a purolator shipping module for good ol' Zen-Cart. I have the algorithm working, but I'm having trouble properly integrating it in to the environment.

Call it a stupidity on my part or lack of experience with the zen-cart structure. But I am really really having a hard time trying to get it integrated and started up. If anyone here who has written a module can shine some light on my problem that would be great!

and the sooner it's implemented I can have it up for all you guys who are wanting a purolator module as well.

This is what I have done so far.

I have a database set up with all postal codes across canada mapped to all their geographical locations. Each code will correspond to a flat rate price up to 10 lbs. after which prices incremenent according to specific weight ranges.

The entire algorithm has been tested and works flawlessly. I am just having a very very hard time getting it "installed" in to zen-cart.

any takers?

Thanks for the help guys/gals

21 Jul 2006, 7:36 PM
#2
wajdi avatar

wajdi

New Zenner

Join Date:
May 2006
Location:
Montreal, Quebec
Posts:
41
Plugin Contributions:
0

Re: Implementing Purolator Shipping Module

Update:

So I finally started understanding the environment a bit better and on the admin side I managed to get the purolator module to show up and it "installs". When I go to the client side and try to make a purchase it doesn't recognize my shipping method and neglects it completely.

These are the files I created:

includes\modules\shipping\purolator.php
includes\english\modules\shipping\purolator.php

So, my question is, are there any other sections I have to modify to get this thing working?

thanks.

21 Jul 2006, 7:49 PM
#3
wajdi avatar

wajdi

New Zenner

Join Date:
May 2006
Location:
Montreal, Quebec
Posts:
41
Plugin Contributions:
0

Re: Implementing Purolator Shipping Module

For the people reading this thread, here is yet another update:

I just managed to get the purolator option to show up on the client side, however the charge remains at 'zero' and when I click on next to go to the checkout page it remains on the "choose your shipping options" page.

any ideas what I could be missing? (see previous reply for what files I created

26 Jul 2006, 4:32 PM
#4
wajdi avatar

wajdi

New Zenner

Join Date:
May 2006
Location:
Montreal, Quebec
Posts:
41
Plugin Contributions:
0

Re: Implementing Purolator Shipping Module

Alright,

I got it working...

anyone interested? so far it doesn't seem like it :P

I'm just putting in some touch ups to make sure provinces/postal codes match their according regions so someone can't put in British Columbia and have a postal code for Montreal. Just minor things here and there.

oh if anyone was wondering, this was built for a canada only store. Apparantly shipping in the states is all one rate anyway so it shouldn't be too hard to add it in there. I'll probably do that as well.

alright...I'll be posting updates regularly as to what I'm adding to this thing. Don't want to release it until I'm happy with it.

cheers.

27 Jul 2006, 12:08 AM
#5
cbh avatar

cbh

New Zenner

Join Date:
Mar 2005
Posts:
21
Plugin Contributions:
0

Re: Implementing Purolator Shipping Module

I'd be interested in checkng it out. I currently am trying to get Virtuemart working with Canada Post and Fedex in Joomla but might go back to my Zen Cart installation if I don't have any success on the Joomla end of things.

Thanks!
Chris Hutcheson.

27 Jul 2006, 2:49 AM
#6
zapisto avatar

zapisto

Zen Follower

Join Date:
Aug 2005
Posts:
163
Plugin Contributions:
0

Re: Implementing Purolator Shipping Module

wajdi:

Alright,

I got it working...

anyone interested? so far it doesn't seem like it :P

I'm just putting in some touch ups to make sure provinces/postal codes match their according regions so someone can't put in British Columbia and have a postal code for Montreal. Just minor things here and there.

oh if anyone was wondering, this was built for a canada only store. Apparantly shipping in the states is all one rate anyway so it shouldn't be too hard to add it in there. I'll probably do that as well.

alright...I'll be posting updates regularly as to what I'm adding to this thing. Don't want to release it until I'm happy with it.

cheers.

hey wajdi shoot me an PM i will test it for you and can also help a bit if need.
i am trying writing a module for Bus shiping also.

27 Jul 2006, 7:39 PM
#7
wajdi avatar

wajdi

New Zenner

Join Date:
May 2006
Location:
Montreal, Quebec
Posts:
41
Plugin Contributions:
0

Re: Implementing Purolator Shipping Module

Hey guys,

Alright, well I put together this zip file with a read me. Should be very straight forward to install. Didn't require too many files to get it working. If you have any problems installing it, then I probably forgot to include a certain file. Just let me know and I'll get it on it asap.

Anyway, let me know what you think.

Just as a note. This is a very early release of the module, there are still certain things I want to work on to make it more foolproof. Right now it does exactly what it's suppose to do:

  1. take postal code
  2. get rate
  3. find price based on weight + location

If you want to edit the rates you have to change it in the table itself (shipping_rates.sql). I didn't include an interface on the admin side to change rates yet. That might be something I will do in the future. For now there is no urgency for me to create one.

oh, and for now this is Canada only.

Anyway, enough blabbering, enjoy.

-wajdi

31 Jul 2006, 8:06 PM
#8
wajdi avatar

wajdi

New Zenner

Join Date:
May 2006
Location:
Montreal, Quebec
Posts:
41
Plugin Contributions:
0

Re: Implementing Purolator Shipping Module

Hey hey,

Some errors found in my code that I didn't quite clean up. I'm sorting it all out now. Should be up hopefully tonight, but most likely tomorrow.

For those who were wondering,

Quick bugs I found:

this line:

// List all postal codes that start with the same letter as the user defined input
$qry = "select postal from postal_zone where postal like '".this->$postal_code"%'";

// List all the zones that start with the same letter as the user defined input
$zne = "select zone from postal_zone where postal like '".this->$postal_code"%'";

should read:

// List all postal codes that start with the same letter as the user defined input
$qry = "select postal from postal_zone where postal like '".substr($postal_code, 0, 1)."%'";
// List all the zones that start with the same letter as the user defined input
$zne = "select zone from postal_zone where postal like '".substr($postal_code, 0, 1)."%'";

More to come....

31 Jul 2006, 8:44 PM
#9
wajdi avatar

wajdi

New Zenner

Join Date:
May 2006
Location:
Montreal, Quebec
Posts:
41
Plugin Contributions:
0

Re: Implementing Purolator Shipping Module

update numero deux:

Alright, so I found the problem but I can't fix it. Something is going on with the shipping rates that zen-cart seems to be controlling. I verified the calculations in my code and they are popping the final shipping costs properly. Even up to the point where:

$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_PUROLATOR_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => $shipping_method,
'cost' => $shipping_cost)));

is called, the $shipping_cost is valid and makes sense. However when it is displayed in the shipping estimator (or checkout, eitherway) the price is always slightly reduced by a certain amount. So something is going on in some script that I'm unaware of.

any ideas?

31 Jul 2006, 8:55 PM
#10
wajdi avatar

wajdi

New Zenner

Join Date:
May 2006
Location:
Montreal, Quebec
Posts:
41
Plugin Contributions:
0

Re: Implementing Purolator Shipping Module

wow am I stupid....

So turns out the reason why I was getting discrepencies was because..

DRUM ROOOOLL!!!!!!!!!!

I didn't change the exchange rate, so I was comparing canadian dollars to US dollars.

yes....I'm special....in a stupid way.

:thumbsup:

31 Jul 2006, 11:10 PM
#11
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: Implementing Purolator Shipping Module

Glad to see you got it to work!

PS: Did you know when you type "purolator module" in google, you get this thread? :)

Tutorials on Zen Cart
http://tutorials.zen-cart.com/index.php

advanced.programmer at gmail dot com
In love with Zen Cart!!

31 Jul 2006, 11:33 PM
#12
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: Implementing Purolator Shipping Module

Hi wajdi
I was going through the Purolator site http://www.purolator.com/index.html
and was not able to find any tutorial on integration with the shopping cart
Can you let me know the link?
Thanks
San

Tutorials on Zen Cart
http://tutorials.zen-cart.com/index.php

advanced.programmer at gmail dot com
In love with Zen Cart!!

1 Aug 2006, 2:45 PM
#13
wajdi avatar

wajdi

New Zenner

Join Date:
May 2006
Location:
Montreal, Quebec
Posts:
41
Plugin Contributions:
0

Re: Implementing Purolator Shipping Module

superprg:

Glad to see you got it to work!

PS: Did you know when you type "purolator module" in google, you get this thread? :)

awesome :thumbsup: :thumbsup:

that's pretty cool.

superprg:

Unfortunately there are no guidelines offered by anyone (to my knowledge) on how to integrate shipping modules in to zen cart or how to create purolator modules for websites.

The way I did it was by reading through the modules already built in and understanding how they were all linked in the environment.

Thankfully the zen-cart environment is so user-friendly for developers it almost made me cry in joy....

If you check out the zip file attached you will see what is required for shipping modules. In the most basic case you just need two files and most likely a table (or many) to throw in to the database. One in each of the following directories:

includes\languages\english\modules\shipping<shipping_module.php>
includes\modules\shipping<shipping_module.php>

The first directory is for all your "defines" of outputted text

i.e: define('MODULE_SHIPPING_PUROLATOR_TEXT_TITLE', 'Purolator Shipping Rates');

The second directory points to the actual implementation of the module you want to implement.

I strongly suggest trying to understand how the various functions/variables are used in other modules to know what you would need to properly implement the tool you require.

If you have any more questions don't hesitate to ask...it took me quite some time to understand the overall structure and get it working, so don't give up :)

1 Aug 2006, 6:26 PM
#14
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: Implementing Purolator Shipping Module

Thanks mate
I am going through it
I will let you know in case I run into any problems!
SAn

Tutorials on Zen Cart
http://tutorials.zen-cart.com/index.php

advanced.programmer at gmail dot com
In love with Zen Cart!!

1 Aug 2006, 6:29 PM
#15
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: Implementing Purolator Shipping Module

I dint understand the shipping_rates table

CREATE TABLE shipping_rates (
shippingid int(2) NOT NULL auto_increment,
zone_detail varchar(4) NOT NULL default '',
lt_ten decimal(3,2) NOT NULL default '0.00',
ten_twenty decimal(3,2) NOT NULL default '0.00',
twenty_thirty decimal(3,2) NOT NULL default '0.00',
thirty_fifty decimal(3,2) NOT NULL default '0.00',
fifty_hundred decimal(3,2) NOT NULL default '0.00',
hundred_twofifty decimal(3,2) NOT NULL default '0.00',
gt_twofifty decimal(3,2) NOT NULL default '0.00',
PRIMARY KEY (shippingid)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=34 ;

What are lt_ten, ten_twenty etc?
Thanks

Tutorials on Zen Cart
http://tutorials.zen-cart.com/index.php

advanced.programmer at gmail dot com
In love with Zen Cart!!

1 Aug 2006, 7:06 PM
#16
wajdi avatar

wajdi

New Zenner

Join Date:
May 2006
Location:
Montreal, Quebec
Posts:
41
Plugin Contributions:
0

Re: Implementing Purolator Shipping Module

superprg:

I dint understand the shipping_rates table

CREATE TABLE shipping_rates (
shippingid int(2) NOT NULL auto_increment,
zone_detail varchar(4) NOT NULL default '',
lt_ten decimal(3,2) NOT NULL default '0.00',
ten_twenty decimal(3,2) NOT NULL default '0.00',
twenty_thirty decimal(3,2) NOT NULL default '0.00',
thirty_fifty decimal(3,2) NOT NULL default '0.00',
fifty_hundred decimal(3,2) NOT NULL default '0.00',
hundred_twofifty decimal(3,2) NOT NULL default '0.00',
gt_twofifty decimal(3,2) NOT NULL default '0.00',
PRIMARY KEY (shippingid)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=34 ;

What are lt_ten, ten_twenty etc?
Thanks

Hey,

lt_ten = less than 10
ten_twenty = between 10 and 20 (same applies for the rest)
gt_twofifty = greater than 250

The fields in the shipping_rates table correspond to weight ranges. Whatever value is under the ten_twenty, twenty_thirty, etc is an incrementing value that adds to the lt_ten value.

So depending on your weight the shipping price will be determined. For example:

weight = 14
postal code: XXX-XXX gives us zone XXXX which has a flat rate (lt_ten) of $5.25

However the weight is 14, so it belongs in the range ten_twenty. Assuming that the incrementing value for this range is 0.24:

0.24 will be added to 5.25 four times to adjust for appropriate weight.

I hope that helps :)

1 Aug 2006, 7:09 PM
#17
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: Implementing Purolator Shipping Module

Thanks much man!

Tutorials on Zen Cart
http://tutorials.zen-cart.com/index.php

advanced.programmer at gmail dot com
In love with Zen Cart!!

1 Aug 2006, 7:14 PM
#18
wajdi avatar

wajdi

New Zenner

Join Date:
May 2006
Location:
Montreal, Quebec
Posts:
41
Plugin Contributions:
0

Re: Implementing Purolator Shipping Module

no probs dude.

2 Aug 2006, 3:37 PM
#19
wajdi avatar

wajdi

New Zenner

Join Date:
May 2006
Location:
Montreal, Quebec
Posts:
41
Plugin Contributions:
0

Re: Implementing Purolator Shipping Module

error checking time.

The shipping estimator needs some fine tuning to work with the purolator module.

When you first select the shipping estimator and you are not a logged in as a registered user you will get an sql error because the province and postal code are empty. Once you enter the appropriate values, all works well. Probably due to a cookie being dropped but even when you close the estimator and decide to go for a another set of items, it will remember your postal code and province even when both boxes are empty.

So, I'm thinking maybe the best thing to do would be to put in the error checking in the shipping estimator side seeing that none of these problems arise when you are in the checkout phase. Do not want to end up putting in error checks that will come out in the checkout when it is not necessary.

Anyone have any other suggestions?

8 Aug 2006, 12:47 PM
#20
gln avatar

gln

New Zenner

Join Date:
Mar 2006
Posts:
8
Plugin Contributions:
0

Re: Implementing Purolator Shipping Module

how you are checking postal code against province....
if i enter ontario postal code and select nfld as province , how can you fix that....?