Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

I've modified one of the latest snapshots of osCommerce slightly to accomodate lengths widths and heights for anyone using Kelvin's Canada Post module (specifically the one modified by Kenneth Wang for post Nov. 1 CVS). Note that there are changes to the CPC module aswell.

 

No guarantees. YMMV. Use these files at your own risk.

 

Modified files are available (for now) at: http://www2.torontopolice.on.ca/dev/osc-cpcmod.tar.gz.

 

These files have ONLY been tested with tep_snapshot-20021121.tar.gz, and canadapost_0.2.tar.gz. Make sure you have those first, and just replace the files in your distribution with the modified ones from my tar.gz.

 

This is a very tiny mod, only four files, one of which is a language mod. I've commented out any code that I've replaced so you can compare it to the original.

 

Modified files: (note: line numbers apply to my modified files, and not the originals)

admin/categories.php - lines 263, 267, 324, 482-493

-> adjustment of queries and form to allow entry of lwh from admin

admin/includes/languages/english/categories.php - lines 85-87

-> adjustment of language file to label fields on product entry

catalog/includes/modules/shipping/canadapost.php - lines 53-54, 62, 272, 273, 280

-> adjustments to pass actual lwh of products, and some formatting adjustments

catalog/includes/classes/shopping_cart.php - line 271

-> adjustment of query to get product lwh

 

Special thanks to the developers of osCommerce, as well as Kelvin and Kenneth for writing such wonderfully clean and extensible code.

 

-John

Posted

The revised canadapost.php module I included adds any handling fee you specified in your canadapost shipping profile. If you've also added a handling fee in oscommerce, you'll be charging your customers double handling. So, either set your oscomm handling fee to 0, or your canadapost profile handling fee to 0. -j

Posted

I forgot the most important step of all... you've got to add three fields to your database:

 

add the fields:

 

products_length, products_width, and products_height to your products table in your database.

 

You can make them all of type int, or mediumint, or even smallint if you wont' need too many digits.

 

Hehe, I'm new, sorry about that. =)

Posted

Thank you John!!!! I haven't tried it yet, but will today!!

:D :D :D :bigups:

 

Violet

Posted

this might work....did for me...not sure if you need dim_type for the canada post 0.2 mod

 

ALTER TABLE products ADD products_dim_type ENUM('cm','in') NOT NULL,

ADD products_length DECIMAL(6,2) DEFAULT '30' NOT NULL,

ADD products_width DECIMAL(6,2) DEFAULT '30' NOT NULL,

ADD products_height DECIMAL(6,2) DEFAULT '30' NOT NULL;

 

use at own risk

crshNbrn

 

adds the lengh,width,height, and dimensional units to products table and pre sets all products in the DB to 30cmX30cm

crshNbrn living on the edge.....

Posted
I've modified one of the latest snapshots of osCommerce slightly to accomodate lengths widths and heights for anyone using Kelvin's Canada Post module (specifically the one modified by Kenneth Wang for post Nov. 1 CVS). Note that there are changes to the CPC module aswell.

-John

 

Hi John,

 

Thank you for your work. Looks like Toronto Police also want to sell something online? 8-)

 

I haven't looked into the modified code yet. But I guess your idea should be assign dimension to each product, and pass them to CanadaPost server. As far as I know, CanadaPost will assume that you want to use one of their package carton, and will try to fit all of your products into the smallest one they have. And then, based on the finally carton it picked, calculate the price.

 

But the problem for me is, we have our own cartons (3 different sizes). We are going to pack multipul products into one of them depend on the products dimension and quantity. My current idea is hard-code the program to pick one of our own carton, and only pass one product (with changed price, added amount, modified description, our own carton size, and ready to ship attribution) to the CanadaPost server.

 

But the problem is, first, this is not a good solution, because it's hard-coded; second, what if a customer buy many products that can't fit into one carton.

 

Any suggestion or comments on this topic will be appreciated.

Kenneth Wang

VA3RRW/BD4RR

Posted

Hey Kenneth, what my mods do is add length width and height fields to products in osCommerce, and then let the CanadaPost module retrieve them. It should be a simple matter to build a script that figures out optimal box arrangement, but Canada Post's servers already do all that work for you...

 

As part of the XML the Canada Post server gets from your store are lengths widths, heights and quantities for all your products, then their server figures out how many of each box (of the boxes you've configured on their server) you'll need, and calculates your price based on that.

 

If you take a look at this sample XML return from their site: http://206.191.4.228/DevelopersResources/p...pleResponse.xml you can see that near the bottom there's a spot called "Packing" that looks like this:

 

<!--

*******************************************************

* The 'packing' section describes in details how

* the items are packed (list of items in each parcel)

*******************************************************

-->

<packing>

<packingID>P_0</packingID>

<box>

<name>Small Box</name>

<weight>0.16</weight>

 

<expediterWeight>1.591</expediterWeight>

<length>10.0</length>

<width>10.0</width>

<height>10.0</height>

<packedItem>

<quantity>1</quantity>

 

<description>KAO Diskettes</description>

</packedItem>

 

 

</box>

 

</packing>

 

You can see that it tells you the type of box used, and what item's it has calculated will optimally fit in them. In this example it used a "Small box". If you need different boxes, or more boxes, Canada Post will return more <box></box> sections along with the products it's figured out to put in them.

 

The trick, I suppose, is storing this information so you can reference it when you actually go to ship your items. It would be easy enough to access it all by adding a few lines to the _parserResult() function. Then, I suppose you could just write them to a field wherever the shipping information is stored in the database.

 

But then, you can always look at it this way: Unless your boxes are being packed by robots, your brain should be able to figure out the best way to pack the boxes, and unless CanadaPost's spatial optimization algorithm is flawed, you should come to the same result, hopefully. That's the approach I'm taking for the moment. When I've got time I may come back and see what I can do about handling the box sizes returned by CP.

 

Hope that helps,

 

-John[/url]

Posted
As part of the XML the Canada Post server gets from your store are lengths widths, heights and quantities for all your products, then their server figures out how many of each box (of the boxes you've configured on their server) you'll need, and calculates your price based on that.

 

Hi John

 

Do you mean I can setup my own box size on CanadaPost's server, instead of using theirs?

 

I have read most of the documents of the server, but didn't noticed that I can do it, and by now, I haven't open my own CP account yet. :oops:

Kenneth Wang

VA3RRW/BD4RR

Posted
As part of the XML the Canada Post server gets from your store are lengths widths, heights and quantities for all your products, then their server figures out how many of each box (of the boxes you've configured on their server) you'll need, and calculates your price based on that.

 

Sorry, forget to say Thank you, John.

 

More shamed. :oops: :oops:

Kenneth Wang

VA3RRW/BD4RR

Posted

Hehe, no problem.

 

Yes, you'll need to create your own Canada Post account first, but once you've done that, part of your account setup is a section where you can input the names and sizes of all of your own boxes. Then those will be the boxes that the Canada Post server will use to calculate your orders.

 

-John

Posted

Something I should have mentionned in my original post... My mods at the top of this thread add three fields to the product input form, which allow you to enter your own dimensions for any product in your store. Much more accurate than fixing the dimensions of objects, giving you a much better shipping estimate.

 

If you set the size of all products to a specific length, width and height that isn't correct, then the problem you run into is that your actual shipping value may be either more or less than the estimate from the server, because your actual products may be bigger or smaller than the fixed values you set for the dimensions.

 

This can be good and bad... good in that you might make some extra cash, because you're overcharging on shipping, and bad because you might lose some cash because you might end up paying more than you charged your customer if your products are bigger than the default size you set for everything. Bad also because your customers might not appreciate being overcharged on shipping. The rate for shipping a CD in an enveloppe is noticeably less than shipping it in a 30cm x 30cm box.

 

-John

Posted

What would cause this error:

An error occured with the canadapost shipping calculations.

If you prefer to use canadapost as your shipping method, please contact the store owner

 

Is this within my CP install or is it something I may have missed in the CanadaPost account setup on their end?

I used your osc-cpc mod and crshNbrn's SQL query to add the tables.

 

Thanks,

Violet

Posted

This could be caused by a number of problems. Sounds like your canada post module is working okay, because it's returning that error, however it may not be passing the correct values to the canada post server.

 

on line 263 of my version of the canadapost.php module, uncomment the line

 

print "message = $statusMessage";

 

Then try again, this will display any error messages that the canada post server returned.

 

If you don't see anything useful there, try uncommenting line 249

 

print $strXML;

 

and reload the page. This will output the XML that you were going to send to the Canada Post server. It won't display well in most browsers, you may need to view the source of the page in the browser to see the actual XML. Take a look and make sure it's sending the proper widths lengths and heights.

 

If that doesn't give you anything useful, add a line at 262, before the $statusMessage = ... that reads:

 

print $resultXML;

 

and reload the page, and take a look at the XML response that the canada post server is giving you. If you examine these three sources, you should, somewhere, be able to figure out what data isn't being transmitted properly. If anything looks fishy, post it here, and I'll see how I can help. If nothing looks out of the ordinary, e-mail me (johnzilla..at..rogers.com) and give me the URL of your store, with all three of those print statements on, and I'll take a look.

 

-John[/code]

Posted

Hi John,

 

I uncommented the first one and found it was an error with the size of the item being "too big" for CP. I have altered the box sizes at CP and everything should work now.

 

Thanks very much!!

 

Violet

Posted

Where in the Canada post site can I setup a store to cutsomize the box size and shipping options?

 

So far I have only been using the testshop but would like to make my own.

 

V Carrol - would you mind posting a little tutorial, explaining to us how/what urls to do this at canadapost and what values to input into OSC?

 

Thanks alot!

 

bARt

 

www.beatstreet.ca

Posted

surfacescan: You should find the answers to your questions about Canada Post here: http://eparcel.magma.ca/faq.html

 

Basically you have to make a free "SellOnline" account with Canada Post, they'll give you a login on their server. Then you configure your account as you need according to their technical guides.

 

When you've got your CP account set up, assuming you've installed one of the versions of Kelvin's Canada Post modules floating around, you just need to update it to use your Canada Post account id. (Admin: Modules->Shipping->CanadaPost)

 

-John

Posted

Thanks for posting that, John! It's a much better site than where I was going, www.canadapost.ca/sellonline/ and going through all the hoops to find little to no info.

I have one more question for you... how can I modify the shipping choices if I only want, say, regular parcel for Canadians and small parcel air for international, as that's how I have the CP account set for.

I have seen a code hack for the old CP mod, would yours work the same way - where I just cut out the other options in the code?

 

Thanks,

Violet

Posted
...you just need to update it to use your Canada Post account id. (Admin: Modules->Shipping->CanadaPost)

 

I tried to do this, however, there is no place to input ones password which was assigned to me by Canada Post. Am I missing something here?

 

~Wayne

Posted

Violet: You should be able to do all of that from the Canada Post server, and shouldn't need to make any modifications to the OSC Module. If you login to the CPC test server at: http://206.191.4.228/servlet/LogonServlet?Language=0 and then hit the "Shipping Services" link, you'll see options for shipping rates to Canada, U.S. and International. All you have to do is go to the International section, and just make sure the only box checked in the "Select Service" column is "Air Parcel". Under the Canada section, make sure the only box in that column that's checked is "Regular"

 

Does that answer your question?

Posted

Wayne: You're not missing anything, you don't need your password when you're using OSC (or any other connection to the Canada Post servers to get shipping prices), you only need it when you log in to the Canada Post server to change any of your settings there.

 

-John

Posted

Johnz, has done a great job answering all our questions. Just in case someone is looking for all the answers on how to setup an account in one messge - here it is:

 

  • requesting a shipping profile account. Provide your business name and contact information including phone number. They will put you on a test server until you want to "go live".

 

Hope somone finds that helpful

 

bART

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