natrium42 Posted September 27, 2007 Posted September 27, 2007 (edited) 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 September 27, 2007 by natrium42 Quote
terminalcity Posted September 27, 2007 Posted September 27, 2007 (edited) 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 September 27, 2007 by terminalcity Quote
natrium42 Posted September 27, 2007 Author Posted September 27, 2007 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. Quote
terminalcity Posted September 27, 2007 Posted September 27, 2007 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 Quote
insaini Posted September 27, 2007 Posted September 27, 2007 excellent contribution my man... much respect Quote
10incher Posted January 4, 2008 Posted January 4, 2008 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 ?> Quote
10incher Posted January 4, 2008 Posted January 4, 2008 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> Quote
10incher Posted January 4, 2008 Posted January 4, 2008 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. Quote
iPhoneGifts Posted January 5, 2008 Posted January 5, 2008 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 Quote
gina4h Posted January 12, 2008 Posted January 12, 2008 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 Quote
gina4h Posted January 12, 2008 Posted January 12, 2008 Sorry I have another question. Where should I copy the new files to? what directories do each of the files go into? Quote
Guest Posted January 30, 2008 Posted January 30, 2008 In admin/ship_canadapost.php if you get the error 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. Quote
Pinball Posted February 6, 2008 Posted February 6, 2008 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 :-#)# Quote
natrium42 Posted February 6, 2008 Author Posted February 6, 2008 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. Quote
Pinball Posted February 6, 2008 Posted February 6, 2008 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 :-#)# Quote
Patrick73 Posted March 14, 2008 Posted March 14, 2008 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. Quote
Patrick73 Posted March 14, 2008 Posted March 14, 2008 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: Quote
Patrick73 Posted March 15, 2008 Posted March 15, 2008 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 Quote
natrium42 Posted March 16, 2008 Author Posted March 16, 2008 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 Quote
natrium42 Posted March 17, 2008 Author Posted March 17, 2008 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"> </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. Quote
natrium42 Posted March 18, 2008 Author Posted March 18, 2008 Canada Post Automatic Labels 1.2 ================================ Version 1.2 (2008-03-17) - bugfix: missing weight for domestic shipments - added clear buttons to customs form - fixed customs form such that >6 items are modifiable (Canada Post still only accepts the first 6) - added splitter for long address lines into address1 and address2 Please see http://addons.oscommerce.com/info/5445 to download Quote
insaini Posted March 27, 2008 Posted March 27, 2008 To All, Next Version up will be released soon. Canada Post Automated Labels AJAX. Includes Real-Time progress updates and some extra options. Quote
natrium42 Posted April 10, 2008 Author Posted April 10, 2008 Canada Post Automatic Labels 1.2.1 ================================== Version 1.2.1 (2008-04-10) - Canada Post changed ID for Intl Small Packets Air from 000000000000001121 to 000000000000009610 - Canada Post changed ID for Intl Small Packets Surface from 000000000000001122 to 000000000000009611 Next version should remove these hard-coded values so that Canada Post is free to change them without any changes required to this module. Please see http://addons.oscommerce.com/info/5445 to download Quote
royfra Posted June 20, 2008 Posted June 20, 2008 hello ! thanks for that great contrib. How do I edit the custom form? The "clear" and "customize shipment" options does not seams to work? I would like to edit the value in it. Here's a screenshot. Also, how do I avoid clear text tranmission of my cc infos.? thanks for your help! Francis Roy Quote
Recommended Posts
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.