Jump to content



Latest News: (loading..)

- - - - -

Canada Post Automatic Labels


  • Please log in to reply
68 replies to this topic

#1   natrium42

natrium42
  • Members
  • 142 posts
  • Real Name:Alexei Karpenko

Posted 27 September 2007 - 04:08 AM

Support thread for Canada Post Automatic Labels Mod

Canada Post Automatic Labels 1.0
================================

Original Author: Alexei Karpenko (natrium42)
Original Shop: www.electrobee.com
Initial Release: 2007-09-27

Description
===========

This modification allows to ship an order electronically by submitting data to Canada Post server which then returns a PDF file with a label that should be placed onto the package. Most of the information is automatically filled out given the order data.

Screenshot included in the package.

Features
========

- Ships orders via Canada Post with few clicks
- Returns PDF file from Canada Post server with the label to print
- Notifies customers with the tracking number (if it is available) and stores it
- Adds description for customs for each product
- Adds Harmonization/Tariff code for each product
- Adds country of manufacture to each manufacturer
- Proper invoice for customs

Edited by natrium42, 27 September 2007 - 04:14 AM.


#2   terminalcity

terminalcity
  • Members
  • 9 posts
  • Real Name:Daniel

Posted 27 September 2007 - 05:28 AM

Hi Alexei:

I installed the module in a half hour.... like i said int the other thread: FANTASTIC! :) :) :) :)

Everything seems to work, although I can't try the whole process yet as I'm running the store locally during setup (on MAMP) and don't want to send my CC details in cleartext.

Anyway, my question is whether the CP server will automatically select the best rate: i.e. if the package is within small packet size, will it return a label for that?

I don't see "small packet/light packet" on the shipping page.

Thanks

Daniel

Edited by terminalcity, 27 September 2007 - 05:28 AM.


#3   natrium42

natrium42
  • Members
  • 142 posts
  • Real Name:Alexei Karpenko

Posted 27 September 2007 - 06:34 AM

View Postterminalcity, on Sep 27 2007, 01:28 AM, said:

Anyway, my question is whether the CP server will automatically select the best rate: i.e. if the package is within small packet size, will it return a label for that?

I don't see "small packet/light packet" on the shipping page.
If you have the Canada Post shipping module installed, it should automatically select the option that the customer selected. There is no other algorithm in place at this point, but might be a good idea for the future.

All the options available when you ship manually ( try https://est-oee.canadapost-postescanada.ca ) should be available. Light packet is not available via electronic shipping tools website, so you would have to ship light packets from the post office. Small packet doesn't make sense for Canada, since Expedited costs the same for VentureOne customers and includes tracking as a bonus, so I guess Canada Post decided not to include it.

#4   terminalcity

terminalcity
  • Members
  • 9 posts
  • Real Name:Daniel

Posted 27 September 2007 - 07:08 AM

thanks so much for this.

I noticed that you do have the small/light packet options in ship_canadapost.php, so I imagine they will show up when applicable.

I'm wondering now if I can just put my CC on file with EST and avoid sending it  over the net for each transaction. I'll give this  a try tomorrow.

Thanks a lot, it is a huge help to my budding little ecommerce attempt.

D

#5   insaini

insaini
  • Members
  • 208 posts
  • Real Name:Jesse B.
  • Gender:Male
  • Location:Brampton, Ontario

Posted 27 September 2007 - 11:20 AM

excellent contribution my man... much respect

#6   10incher

10incher
  • Members
  • 65 posts
  • Real Name:Chad

Posted 04 January 2008 - 04:33 PM

Hello, I am trying to install this contrib but have run into a bit of a problem.
In catalog/admin/includes/classes/order.php I am trying to:

### To the following line:

	  $order_query = tep_db_query("select customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, currency, currency_value, date_purchased, orders_status, last_modified from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'");

###### After last_modified add

, cp_tracking

The problem is that I have added some previous contributions or have an older version of OScommerce and I don't have that line anywhere in the code for this page. Does anyone know specifically where I can add the new line or how to implement it properly within the code that I do have? I would really love to add this contibution. Here is the code for the page that I have:

<?php
/*
  $Id: order.php,v 1.7 2003/06/20 16:23:08 hpdl Exp $
  Modified for Order Editor 2.5

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

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  class order {
	var $info, $totals, $products, $customer, $delivery;

	function order($order_id) {
	  $this->info = array();
	  $this->totals = array();
	  $this->products = array();
	  $this->customer = array();
	  $this->delivery = array();

	  $this->query($order_id);
	}
//Begin Order Editor modifications
	function query($order_id) {
	  $order_query = tep_db_query("select * from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'");
	  $order = tep_db_fetch_array($order_query);

	  $totals_query = tep_db_query("select * from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' order by sort_order");
	  while ($totals = tep_db_fetch_array($totals_query)) {
		$this->totals[] = array(
	  'title' => $totals['title'], 
	  'text' => $totals['text'], 
	  'class' => $totals['class'], 
	  'value' => $totals['value'],
	  'sort_order' => $totals['sort_order'], 
	  'orders_total_id' => $totals['orders_total_id']);
	  }

	  $this->info = array('currency' => $order['currency'],
						  'currency_value' => $order['currency_value'],
						  'payment_method' => $order['payment_method'],
						  'cc_type' => $order['cc_type'],
						  'cc_owner' => $order['cc_owner'],
						  'cc_number' => $order['cc_number'],
						  'cc_expires' => $order['cc_expires'],
						  'shipping_tax' => $order['shipping_tax'],
						  'date_purchased' => $order['date_purchased'],
						  'orders_status' => $order['orders_status'],
						  'cp_tracking' => $order['cp_tracking'],
						  'last_modified' => $order['last_modified']);

	  $this->customer = array('name' => $order['customers_name'],
							  'company' => $order['customers_company'],
							  'street_address' => $order['customers_street_address'],
							  'suburb' => $order['customers_suburb'],
							  'city' => $order['customers_city'],
							  'postcode' => $order['customers_postcode'],
							  'state' => $order['customers_state'],
							  'country' => $order['customers_country'],
							  'format_id' => $order['customers_address_format_id'],
							  'telephone' => $order['customers_telephone'],
							  'email_address' => $order['customers_email_address']);

	  $this->delivery = array('name' => $order['delivery_name'],
							  'company' => $order['delivery_company'],
							  'street_address' => $order['delivery_street_address'],
							  'suburb' => $order['delivery_suburb'],
							  'city' => $order['delivery_city'],
							  'postcode' => $order['delivery_postcode'],
							  'state' => $order['delivery_state'],
							  'country' => $order['delivery_country'],
							  'format_id' => $order['delivery_address_format_id']);

	  $this->billing = array('name' => $order['billing_name'],
							 'company' => $order['billing_company'],
							 'street_address' => $order['billing_street_address'],
							 'suburb' => $order['billing_suburb'],
							 'city' => $order['billing_city'],
							 'postcode' => $order['billing_postcode'],
							 'state' => $order['billing_state'],
							 'country' => $order['billing_country'],
							 'format_id' => $order['billing_address_format_id']);


	$countryid = tep_get_country_id($this->delivery["country"]);
	$zoneid = tep_get_zone_id($countryid, $this->delivery["state"]);

	$index = 0;
	$orders_products_query = tep_db_query("
	 SELECT 
	 op.orders_products_id, 
	 op.products_name, 
	 op.products_model, 
	 op.products_price,
	 op.products_tax, 
	 op.products_quantity, 
	 op.final_price, 
	 p.products_tax_class_id,
	 p.products_weight
  FROM " . TABLE_ORDERS_PRODUCTS . " op
  LEFT JOIN " . TABLE_PRODUCTS . " p
	ON op.products_id = p.products_id
 WHERE orders_id = '" . (int)$order_id . "'");
 
	   while ($orders_products = tep_db_fetch_array($orders_products_query)) {
		 $this->products[$index] = array(
								'qty' => $orders_products['products_quantity'],
								'name' => $orders_products['products_name'],
								'model' => $orders_products['products_model'],
								'tax' => $orders_products['products_tax'],
		'tax_description' => tep_get_tax_description($orders_products['products_tax_class_id'], $countryid, $zoneid),
								'price' => $orders_products['products_price'],
								'final_price' => $orders_products['final_price'],
								'weight' => $orders_products['products_weight'],
								'orders_products_id' => $orders_products['orders_products_id']);
 
		$subindex = 0;
		$attributes_query = tep_db_query("select * from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'");
		if (tep_db_num_rows($attributes_query)) {
		  while ($attributes = tep_db_fetch_array($attributes_query)) {
			$this->products[$index]['attributes'][$subindex] = 
			array('option' => $attributes['products_options'],
				  'value' => $attributes['products_options_values'],
				  'prefix' => $attributes['price_prefix'],
				 'price' => $attributes['options_values_price'],
		  'orders_products_attributes_id' => $attributes['orders_products_attributes_id']);

			$subindex++;
		  }
		}
		$index++;
	  }
	}
  }
  //end Order Editor
?>


#7   10incher

10incher
  • Members
  • 65 posts
  • Real Name:Chad

Posted 04 January 2008 - 04:59 PM

I also noticed In catalog/admin/orders.php

### Replace the following line: ***********

		<td colspan="2" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_ORDERS_INVOICE, 'oID=' . $HTTP_GET_VARS['oID']) . '" TARGET="_blank">' . tep_image_button('button_invoice.gif', IMAGE_ORDERS_INVOICE) . '</a> <a href="' . tep_href_link(FILENAME_ORDERS_PACKINGSLIP, 'oID=' . $HTTP_GET_VARS['oID']) . '" TARGET="_blank">' . tep_image_button('button_packingslip.gif', IMAGE_ORDERS_PACKINGSLIP) . '</a> <a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('action'))) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>

###### With:

		<td colspan="2" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_SHIP_CANADAPOST, 'oID=' .(int)$HTTP_GET_VARS['oID'] . '&action=new&status=3') . '">' . tep_image_button('button_ship_canadapost.gif', IMAGE_ORDERS_SHIP) . '</a> <a href="' . tep_href_link(FILENAME_ORDERS_INVOICE, 'oID=' . $HTTP_GET_VARS['oID']) . '" TARGET="_blank">' . tep_image_button('button_invoice.gif', IMAGE_ORDERS_INVOICE) . '</a> <a href="' . tep_href_link(FILENAME_ORDERS_PACKINGSLIP, 'oID=' . $HTTP_GET_VARS['oID']) . '" TARGET="_blank">' . tep_image_button('button_packingslip.gif', IMAGE_ORDERS_PACKINGSLIP) . '</a> <a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('action'))) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>

what I have for that line is slightly different is it safe to replace? Here's what I have:

	   <td colspan="2" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_ORDERS_EDIT, 'oID=' . $_GET['oID']) . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_ORDERS_INVOICE, 'oID=' . $_GET['oID']) . '" TARGET="_blank">' . tep_image_button('button_invoice.gif', IMAGE_ORDERS_INVOICE) . '</a> <a href="' . tep_href_link(FILENAME_ORDERS_PACKINGSLIP, 'oID=' . $_GET['oID']) . '" TARGET="_blank">' . tep_image_button('button_packingslip.gif', IMAGE_ORDERS_PACKINGSLIP) . '</a> <a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('action'))) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a> '; ?></td>


#8   10incher

10incher
  • Members
  • 65 posts
  • Real Name:Chad

Posted 04 January 2008 - 05:36 PM

After having a look at everything it looks like some of my code is different because I have the Order Editor contribution installed. The above problems are the only ones that i came across. If anyone knows how to implement the changes above or has a seperate list of changes to make (when installing shipping labels) when you have Order Editor installed, I would greatly appreciate it.

#9   iPhoneGifts

iPhoneGifts
  • Members
  • 1 posts
  • Real Name:Cris
  • Gender:Male
  • Location:Canada

Posted 05 January 2008 - 08:21 PM

is it just me, or is the download link grey'd out ?

This module looks great, but I can't seem to find it? lol

#10   gina4h

gina4h
  • Members
  • 10 posts
  • Real Name:Gina Henry

Posted 12 January 2008 - 09:28 PM

Do you need to add the Canada Post shipping module first or is tha label module an all-in-one?
I am having a lot of problems getting my shipping to work. Any help would be appreciated

#11   gina4h

gina4h
  • Members
  • 10 posts
  • Real Name:Gina Henry

Posted 12 January 2008 - 09:34 PM

Sorry I have another question. Where should I copy the new files to?
what directories do each of the files go into?

#12   Java Roasters

Java Roasters
  • Members
  • 2,145 posts
  • Real Name:Peter Bernard
  • Gender:Male
  • Location:Kagawong Ontario, Canada

Posted 30 January 2008 - 05:22 PM

In admin/ship_canadapost.php if you get the error


Quote

Fatal error: Call to undefined function: stripos() in c:\program files\easyphp1-8\www\mcc\admin\ship_canadapost.php on line 140

Change "stripos" to "strpos".  Stripos is only for PHP5 only.

#13   Pinball

Pinball
  • Members
  • 43 posts
  • Real Name:John
  • Gender:Male
  • Location:Canada

Posted 06 February 2008 - 06:01 AM

View Postnatrium42, on Sep 26 2007, 08:08 PM, said:

Support thread for Canada Post Automatic Labels Mod

Canada Post Automatic Labels 1.0
================================

Original Author: Alexei Karpenko (natrium42)
Original Shop: www.electrobee.com
Initial Release: 2007-09-27

Description
===========

This modification allows to ship an order electronically by submitting data to Canada Post server which then returns a PDF file with a label that should be placed onto the package. Most of the information is automatically filled out given the order data.

Screenshot included in the package.

Features
========

- Ships orders via Canada Post with few clicks
- Returns PDF file from Canada Post server with the label to print
- Notifies customers with the tracking number (if it is available) and stores it
- Adds description for customs for each product
- Adds Harmonization/Tariff code for each product
- Adds country of manufacture to each manufacturer
- Proper invoice for customs

Ah, looks very nice, most of it installs fairly obviously, however there are two things I am having trouble with. First the directory labeled "modified-files" has a new 'invoice.php'. Do I simply dump that in place of my current invoice ('cause I did...). And second - I am not clear on how to run the file "new_install.sql" - i placed it in the catalog directory - but when I opened myPhp, I was unable to locate or execute that file. Running MySQL 5.xxx

A little knowledge is a dangerous thing and I seem to have very little knowledge here...

Thanks,
John :-#)#

#14   natrium42

natrium42
  • Members
  • 142 posts
  • Real Name:Alexei Karpenko

Posted 06 February 2008 - 06:40 PM

The new invoice.php has things for customs (like Harmonization code and short description). Use at your own discretion.

You can run the SQL statements through a screen in myPhpAdmin by copying and pasting the code out of the new_install.sql. Of course, backup your database or better yet use a test server.

#15   Pinball

Pinball
  • Members
  • 43 posts
  • Real Name:John
  • Gender:Male
  • Location:Canada

Posted 06 February 2008 - 09:13 PM

View PostPinball, on Feb 5 2008, 10:01 PM, said:

Ah, looks very nice, most of it installs fairly obviously, however there are two things I am having trouble with. First the directory labeled "modified-files" has a new 'invoice.php'. Do I simply dump that in place of my current invoice ('cause I did...). And second - I am not clear on how to run the file "new_install.sql" - i placed it in the catalog directory - but when I opened myPhp, I was unable to locate or execute that file. Running MySQL 5.xxx

A little knowledge is a dangerous thing and I seem to have very little knowledge here...

Thanks,
John :-#)#

OK, I figured it out, usedmyphpadmin and ran the sql in 'sql' on the data base I was using. Installed just fine then.
interesting utility, if I can just get past a problem I'm having with PayPal sandbox claiming that I have already (as a customer) paid this invoice then I can see if this works. I suspect there is something wrong with the invoice number counter...

John :-#)#

#16   Patrick73

Patrick73
  • Members
  • 32 posts
  • Real Name:Patrick
  • Gender:Male
  • Location:Montreal,QC, Canada

Posted 14 March 2008 - 07:03 PM

Hi, this is an amazing contribution :thumbsup:

I have it working except for an error:

Canada Post Automatic Labels

Step 1. Initialized.
Step 2. Logged in.
Step 3. Started shipping application.
Step 4. Entered address.
Step 5. Selected shipping method.
Step 6. Customs information not necessary for Canada.
Step 7. Payment processed.

Warning: fopen(images/canadapost/869.pdf) [function.fopen]: failed to open stream: No such file or directory in /home/domains/mysite/public_html/catalog/admin/ship_canadapost.php on line 894

Warning: fwrite(): supplied argument is not a valid stream resource in /home/domains/mysite/public_html/perroquet/boutique/produc/ship_canadapost.php on line 895

Warning: fclose(): supplied argument is not a valid stream resource in /home/oisellerie/domains/oisellerielavoliere.com/public_html/catalog/admin/ship_canadapost.php on line 896

Step 8. Label received and saved.
Step 9. Tracking number is 7180699715248001.
Step 10. Success!

Shipping Price (CAD): 14.46
Tracking Number: 7180699715248001
Label: Open PDF


Step 11. Customer notified via email.

And when I click the open label it goes to:

http://www.mysite/catalog/admin/images/canadapost/869.pdf   which I think is not the proper link....

I went to my Canada post account and printed the label from there, so it is working. I just can't print it from my site and I get the error message.

Fantastic work again.

#17   Patrick73

Patrick73
  • Members
  • 32 posts
  • Real Name:Patrick
  • Gender:Male
  • Location:Montreal,QC, Canada

Posted 14 March 2008 - 10:23 PM

View Postoiseuanat, on Mar 14 2008, 02:03 PM, said:

Hi, this is an amazing contribution :thumbsup:

I have it working except for an error:

Canada Post Automatic Labels

Step 1. Initialized.
Step 2. Logged in.
Step 3. Started shipping application.
Step 4. Entered address.
Step 5. Selected shipping method.
Step 6. Customs information not necessary for Canada.
Step 7. Payment processed.

Warning: fopen(images/canadapost/869.pdf) [function.fopen]: failed to open stream: No such file or directory in /home/domains/mysite/public_html/catalog/admin/ship_canadapost.php on line 894

Warning: fwrite(): supplied argument is not a valid stream resource in /home/domains/mysite/public_html/perroquet/boutique/produc/ship_canadapost.php on line 895

Warning: fclose(): supplied argument is not a valid stream resource in /home/oisellerie/domains/oisellerielavoliere.com/public_html/catalog/admin/ship_canadapost.php on line 896

Step 8. Label received and saved.
Step 9. Tracking number is 7180699715248001.
Step 10. Success!

Shipping Price (CAD): 14.46
Tracking Number: 7180699715248001
Label: Open PDF
Step 11. Customer notified via email.

And when I click the open label it goes to:

http://www.mysite/catalog/admin/images/canadapost/869.pdf   which I think is not the proper link....

I went to my Canada post account and printed the label from there, so it is working. I just can't print it from my site and I get the error message.

Fantastic work again.


  Ok I fixed it, I had forgetten to upload the canadapost folder to the image folder, Also you need to set permissions to 777 for it to work.

The order status is set by default to shipped once the label is submitted. By default, the setting is 4 on line 945 of admin/ship_canadapost, my store did not have a status at that value which cause the order to disapear. So you might need to set it manually according to your status.

Awesome contrib. :thumbsup:

#18   Patrick73

Patrick73
  • Members
  • 32 posts
  • Real Name:Patrick
  • Gender:Male
  • Location:Montreal,QC, Canada

Posted 15 March 2008 - 02:02 AM

Hello,

Is there any way to customize value, description and weight.

I use attributes with weight for all my products, so order_weight is to tare weight. As for price, I combine Ebay items with on line purchases, so the order value needs to be increased to package value.

If it could just be possible to have the custom option enable, that would be great, cause now, with the weight attributes, This amazing contrib is useless for me and so close.


Thanks

#19   natrium42

natrium42
  • Members
  • 142 posts
  • Real Name:Alexei Karpenko

Posted 16 March 2008 - 11:26 PM

Canada Post Automatic Labels 1.1
================================

Version 1.1 (2008-03-16)
- added complete customs declaration customization
- added payment option via Canada Post account

Please see http://addons.oscommerce.com/info/5445 to download

#20   natrium42

natrium42
  • Members
  • 142 posts
  • Real Name:Alexei Karpenko

Posted 17 March 2008 - 04:19 PM

Looks like there's a small bug for domestic shipments. Here is the fix:

In admin/ship_canadapost.php replace lines 521-523 with
			<?php
			} else {
			?>
			  <tr>
				<td class="main" align="right">Weight (kg):</td>
				<td class="main">&nbsp;</td>
				<td class="main"><?php echo tep_draw_input_field('package_weight',(string) $order_weight, 'size="5"'); ?></td>
			  </tr>
			<?php
			}
			?>

Going to submit a full fixed package later today.