Forums / Addon Shipping Modules / Canada Post module

Canada Post module

Views: 188,607

Results 441 to 460 of 481
4 Feb 2020, 9:08 PM
#441
jugglez avatar

jugglez

New Zenner

Join Date:
Jul 2013
Location:
Toronto
Posts:
7
Plugin Contributions:
0

Canada Post module

swguy:

His change didn't include %. You could just add that if you wish.

$twi_cleanPname = preg_replace('/%�*39;|'/', '', $twi_cleanPname);

Thanks, tried this but didn't work with any product names with % in them.
Getting the same CanadaPost error

5 Feb 2020, 4:25 PM
#442
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Canada Post module

**If this...:
**
// $twi_cleanPname = preg_replace('/&#0*39;|'/', '', $twi_cleanPname); // clean out apostrophe's

is replaced with this:

    // $twi_cleanPname = preg_replace('/&#0*39;|\'/', '', $twi_cleanPname); // clean out apostrophe's
    $twi_cleanPname = preg_replace('/[^A-Za-z0-9- ]/', '', $twi_cleanPname); // Remove any character that isn't A-Z, a-z, 0-9 including hyphen but not a whitespace

and it works... I could use a coffee ;)

Twitch.
https://www.twitchtoo.com Do you work for free? Please donate.
June 7.2026 - NOW AVAILABLE - Twitch Base8 - Obsidian

6 Feb 2020, 4:20 PM
#443
jugglez avatar

jugglez

New Zenner

Join Date:
Jul 2013
Location:
Toronto
Posts:
7
Plugin Contributions:
0

Re: Canada Post module

twitchtoo:

**If this...:
**
// $twi_cleanPname = preg_replace('/�*39;|'/', '', $twi_cleanPname); // clean out apostrophe's

is replaced with this:

    // $twi_cleanPname = preg_replace('/�*39;|\'/', '', $twi_cleanPname); // clean out apostrophe's
    $twi_cleanPname = preg_replace('/[^A-Za-z0-9- ]/', '', $twi_cleanPname); // Remove any character that isn't A-Z, a-z, 0-9 including hyphen but not a whitespace

and it works... I could use a coffee ;)

Thanks ! Works like a charm now!

Donated to your coffee fund!

6 Feb 2020, 4:37 PM
#444
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Canada Post module

What a great way to start the day thanks!

Twitch.
https://www.twitchtoo.com Do you work for free? Please donate.
June 7.2026 - NOW AVAILABLE - Twitch Base8 - Obsidian

7 Feb 2020, 7:36 PM
#445
artbypatrick avatar

artbypatrick

New Zenner

Join Date:
Apr 2014
Location:
Moncton
Posts:
12
Plugin Contributions:
0

Re: Canada Post module

just updated Canada Post module... even tried Dr Bites solution by just updating the canadapost.php file and clearing history... But on my Zen Cart 1.5.6c with PHP 7.2, if I simply do not update (admin)\includes\modules\product\collect_info.php, I can see my product details on the admin side but If I do, then I get this error message:

[07-Feb-2020 14:29:46 America/New_York] Request URI: /shop/xxxx/product.php?cPath=1_263_265&product_type=1&pID=6791&action=new_product, IP address: 156.34.242.95
#1  trigger_error() called at [/home/elmcityh/public_html/shop/xxxx/includes/functions/html_output.php:16]
#2  zen_href_link() called at [/home/elmcityh/public_html/shop/xxxx/includes/functions/html_output.php:181]
#3  zen_draw_form() called at [/home/elmcityh/public_html/shop/xxxx/includes/modules/product/collect_info.php:246]
#4  require(/home/elmcityh/public_html/shop/xxxx/includes/modules/product/collect_info.php) called at [/home/elmcityh/public_html/shop/xxxx/product.php:101]
--> PHP Fatal error: zen_href_link(, cPath=1_263_265&product_type=1&pID=6791&action=new_product_preview, NONSSL), unable to determine the page link. in /home/elmcityh/public_html/shop/xxxx/includes/functions/html_output.php on line 16.

how can I fix this?
Still very early in my Zen years , learned a lot for the past three days

8 Feb 2020, 6:22 PM
#446
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,110
Plugin Contributions:
56

Re: Canada Post module

That log you posted has nothing to do with the Canada Post shipping module. I'll note also that you've got a *modified *version of /admin/includes/modules/product/collect_info.php, since line 246 of the zc156c as-shipped version (highlighted below) does not include a call to zen_draw_form.

  <div class="form-group">
[B]      <?php echo zen_draw_label(TEXT_PRODUCTS_NAME, 'products_name', 'class="col-sm-3 control-label"'); ?>[/B]
    <div class="col-sm-9 col-md-6">
        <?php
        for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
          ?>
        <div class="input-group">
          <span class="input-group-addon">
              <?php echo zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?>
          </span>
          <?php echo zen_draw_input_field('products_name[' . $languages[$i]['id'] . ']', htmlspecialchars(isset($products_name[$languages[$i]['id']]) ? stripslashes($products_name[$languages[$i]['id']]) : zen_get_products_name($pInfo->products_id, $languages[$i]['id']), ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_PRODUCTS_DESCRIPTION, 'products_name') . ' class="form-control"'); ?>
        </div>
        <br>
        <?php
      }
      ?>
    </div>
  </div>
27 Feb 2020, 3:12 AM
#447
nootkan avatar

nootkan

New Zenner

Join Date:
Apr 2006
Location:
Gold River British Columbia Canada
Posts:
9
Plugin Contributions:
0

Re: Canada Post module

twitchtoo:

Unfortunately funding to rebuild this project by my first client was cut when their hosting fees - to open the specific port needed - exceeded their projected income each month! There were other factors of course and each hosting company had similar pricing/support.

We instead developed a static/dynamic lookup that can gather the information by other means and present very accurate postal pricing *without *any time waiting for a remote processing server.

Obviously being wired directly into Canada Post is the purpose of this module and when funding returns I'll be happy to support it!

I can't speak for everyone but because I manage my own dedicated server with websites already using a rest/soap canada post plugin (wp) the opening of the ports isn't an issue for me.

In fact, I have my own api keys registered with Canada Post. I would definitely entertain the idea of discussing what funding is required to upgrade or rebuild this plugin.

Nootkan

1 Apr 2020, 6:19 PM
#448
jugglez avatar

jugglez

New Zenner

Join Date:
Jul 2013
Location:
Toronto
Posts:
7
Plugin Contributions:
0

Re: Canada Post module

ArtbyPatrick:

just updated Canada Post module... even tried Dr Bites solution by just updating the canadapost.php file and clearing history... But on my Zen Cart 1.5.6c with PHP 7.2, if I simply do not update (admin)\includes\modules\product\collect_info.php, I can see my product details on the admin side but If I do, then I get this error message:

[07-Feb-2020 14:29:46 America/New_York] Request URI: /shop/xxxx/product.php?cPath=1_263_265&product_type=1&pID=6791&action=new_product, IP address: 156.34.242.95
#1 trigger_error() called at [/home/elmcityh/public_html/shop/xxxx/includes/functions/html_output.php:16]
#2 zen_href_link() called at [/home/elmcityh/public_html/shop/xxxx/includes/functions/html_output.php:181]
#3 zen_draw_form() called at [/home/elmcityh/public_html/shop/xxxx/includes/modules/product/collect_info.php:246]
#4 require(/home/elmcityh/public_html/shop/xxxx/includes/modules/product/collect_info.php) called at [/home/elmcityh/public_html/shop/xxxx/product.php:101]
--> PHP Fatal error: zen_href_link(, cPath=1_263_265&product_type=1&pID=6791&action=new_product_preview, NONSSL), unable to determine the page link. in /home/elmcityh/public_html/shop/xxxx/includes/functions/html_output.php on line 16.

> 
> how can I fix this?
> Still very early in my Zen years , learned a lot for the past three days


Has anyone been able to fix this error? I'm getting the same issue now, can't view product detail in the backend admin catalog.
PHP 7.2 and Zencart 1.5.6c
Everything was working fine until I installed the Canada Post Module.
20 Apr 2020, 3:25 AM
#449
mavi97 avatar

mavi97

New Zenner

Join Date:
Apr 2020
Location:
Canada
Posts:
7
Plugin Contributions:
0

Re: Canada Post module

I do not have sellonline account with Canada Post. I have new business account.

I am using 1.5.6c
If i enter new account in place of CPC_DEMO_XML it gives error. So is this module able to get rates from Canada Post website.

Regards

6 Jun 2020, 8:24 PM
#450
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Canada Post module

Canada Post Module is available for 1.56c and will be submitted to the forum shortly.

If my work has helped you today in any way - I appreciate your donations!

Twitch.
https://www.twitchtoo.com Do you work for free? Please donate.
June 7.2026 - NOW AVAILABLE - Twitch Base8 - Obsidian

12 Jun 2020, 7:49 PM
#451
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,720
Plugin Contributions:
56

Re: Canada Post module

Checking in - do you have an ETA on submitting the Canada Post updates?

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

12 Jun 2020, 7:58 PM
#452
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Canada Post module

Looks like Monday June 15.
To clarify this update continues on the previous Canada Post SellOnline system.
Funding has not been established to code for their newer API tools at this time.

Twitch.
https://www.twitchtoo.com Do you work for free? Please donate.
June 7.2026 - NOW AVAILABLE - Twitch Base8 - Obsidian

13 Jun 2020, 5:30 AM
#453
thebeadyeye avatar

thebeadyeye

New Zenner

Join Date:
Feb 2007
Posts:
47
Plugin Contributions:
0

Re: Canada Post module

What kind of funding is needed to create the new mod, since the old system is going to be retired.

18 Jun 2020, 11:39 PM
#454
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Canada Post module

thebeadyeye:

What kind of funding is needed to create the new mod, since the old system is going to be retired.

twitchtoo:

Looks like Monday June 15.
To clarify this update continues on the previous Canada Post SellOnline system.
Funding has not been established to code for their newer API tools at this time.

thebeadyeye - This module took over a week to rework and test on no less than 3 hosts, 2 - 1.56c test sites and 4 - 1.56c live production sites. It was derived from a working 1.55f version (1 year of successful production use). And... took nearly a week to compile for two separate production releases - the public Zen Cart forum and the *unreleased *Twitch Base6 core.

I have submitted the public version 1.6.5 for review today! If anyone would like to donate to the cause to discuss funding the new API please email me directly or click the donate button on my homepage :bigups:

Twitch.
https://www.twitchtoo.com Do you work for free? Please donate.
June 7.2026 - NOW AVAILABLE - Twitch Base8 - Obsidian

20 Jun 2020, 1:07 PM
#455
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Canada Post module

Of course there's always one line of code I missed...

includes/modules/shipping/canadapost.php
line 18 - replace this:
var $moduleVersion = '1.6.1';

with this:
var $moduleVersion = '1.6.5 - 20a.20d';

I've submitted a corrected version to the forum!

Twitch.
https://www.twitchtoo.com Do you work for free? Please donate.
June 7.2026 - NOW AVAILABLE - Twitch Base8 - Obsidian

2 Jul 2020, 4:16 PM
#456
dchquilling avatar

dchquilling

New Zenner

Join Date:
Sep 2006
Location:
New Brunswick, Canada
Posts:
12
Plugin Contributions:
0

Re: Canada Post module

Thank you for updating this module.
I'm testing upgrade on my development install (WAMP) and found issue with the Lettermail Shipping.

On my production site lettermail rates only show if package is under max lettermail weight and it fits into one of the lettermail envelopes setup in my sellonline profile (height is set at 1.8cm).

In my development environment lettermail rates are showing if package is under max lettermail weight but over height to fit into lettermail envelope.

I made change in includes/modules/shipping/canadapost.php to fix

change this

154     $canadapostQuote = $this->_canadapostGetQuote();
155     
156     // Twitch bugfix - add lettermail switch control
157     // orginal code    if ($this->lettermail_available && ($shipping_weight <= $this->lettermail_max_weight))
158     if (MODULE_SHIPPING_CANADAPOST_LETTERMAIL_STATUS == 'True' && ($shipping_weight <= $this->lettermail_max_weight))

to this

154     $canadapostQuote = $this->_canadapostGetQuote();
155     
156     // Twitch bugfix - add lettermail switch control
157     // orginal code    if ($this->lettermail_available && ($shipping_weight <= $this->lettermail_max_weight))
158     if (MODULE_SHIPPING_CANADAPOST_LETTERMAIL_STATUS == 'True' && lettermail_available)

Deborah Hartin

3 Jul 2020, 3:41 PM
#457
dchquilling avatar

dchquilling

New Zenner

Join Date:
Sep 2006
Location:
New Brunswick, Canada
Posts:
12
Plugin Contributions:
0

Re: Canada Post module

Thank you for updating this module. If you

I'm testing this on a 1.5.6c upgrade and found a couple of issues

In admin copying a product with dim types kgs/cm and dimensions length 24, width 12, height 1.5
the copied product has dim types lbs/in and dimensions length 0, width 24, height 12

I made change to admin/includes/modules/copy_product_confirm.php insert statement line 72

INSERT INTO " . TABLE_PRODUCTS . " (products_type, products_quantity, products_model, products_image,
                                                      products_price, products_virtual, products_date_added, products_date_available,
                                                      products_weight,
                                                        products_weight_type, products_dim_type, products_length, products_width, products_height, 
                                                        products_ready_to_ship,
                                                      products_status, products_tax_class_id,
                                                      manufacturers_id, products_quantity_order_min, products_quantity_order_units,
                                                      products_priced_by_attribute, product_is_free, product_is_call, products_quantity_mixed,
                                                      product_is_always_free_shipping, products_qty_box_status, products_quantity_order_max,
                                                      products_sort_order, products_price_sorter, master_categories_id)
                  VALUES ('" . zen_db_input($product->fields['products_type']) . "',
                          '" . $products_quantity . "',
                          '" . zen_db_input($product->fields['products_model']) . "',
                          '" . zen_db_input($product->fields['products_image']) . "',
                          '" . $products_price . "',
                          '" . zen_db_input($product->fields['products_virtual']) . "',
                          now(),
                          " . (zen_not_null(zen_db_input($product->fields['products_date_available'])) ? "'" . zen_db_input($product->fields['products_date_available']) . "'" : 'null') . ",
                          '" . $products_weight . "', '0',
                                '" . zen_db_input($product->fields['products_weight_type']) . "',
                                '" . zen_db_input($product->fields['products_dim_type']) . "',
                                '" . zen_db_input($product->fields['products_length']) . "',
                                '" . zen_db_input($product->fields['products_width']) . "',
                                '" . zen_db_input($product->fields['products_height']) . "',
                                '" . zen_db_input($product->fields['products_ready_to_ship']) . "',
                          '" . (int)$product->fields['products_tax_class_id'] . "',
                          '" . (int)$product->fields['manufacturers_id'] . "',
                          '" . zen_db_input(($product->fields['products_quantity_order_min'] == 0 ? 1 : $product->fields['products_quantity_order_min'])) . "',
                          '" . zen_db_input(($product->fields['products_quantity_order_units'] == 0 ? 1 : $product->fields['products_quantity_order_units'])) . "',
                          '" . zen_db_input($product->fields['products_priced_by_attribute']) . "',
                          '" . (int)$product->fields['product_is_free'] . "',
                          '" . (int)$product->fields['product_is_call'] . "',
                          '" . (int)$product->fields['products_quantity_mixed'] . "',
                          '" . zen_db_input($product->fields['product_is_always_free_shipping']) . "',
                          '" . zen_db_input($product->fields['products_qty_box_status']) . "',
                          '" . zen_db_input($product->fields['products_quantity_order_max']) . "',
                          '" . zen_db_input($product->fields['products_sort_order']) . "',
                          '" . zen_db_input($product->fields['products_price_sorter']) . "',
                          '" . zen_db_input($categories_id) . "')");

to

    $db->Execute("INSERT INTO " . TABLE_PRODUCTS . " (products_type, products_quantity, products_model, products_image,
                                                      products_price, products_virtual, products_date_added, products_date_available,
                                                      products_weight,
                                                        products_weight_type, products_dim_type, products_length, products_width, products_height, 
                                                        products_ready_to_ship,
                                                      products_status, products_tax_class_id,
                                                      manufacturers_id, products_quantity_order_min, products_quantity_order_units,
                                                      products_priced_by_attribute, product_is_free, product_is_call, products_quantity_mixed,
                                                      product_is_always_free_shipping, products_qty_box_status, products_quantity_order_max,
                                                      products_sort_order, products_price_sorter, master_categories_id)
                  VALUES ('" . zen_db_input($product->fields['products_type']) . "',
                          '" . $products_quantity . "',
                          '" . zen_db_input($product->fields['products_model']) . "',
                          '" . zen_db_input($product->fields['products_image']) . "',
                          '" . $products_price . "',
                          '" . zen_db_input($product->fields['products_virtual']) . "',
                          now(),
                          " . (zen_not_null(zen_db_input($product->fields['products_date_available'])) ? "'" . zen_db_input($product->fields['products_date_available']) . "'" : 'null') . ",
                          '" . $products_weight . "',
                                '" . zen_db_input($product->fields['products_weight_type']) . "',
                                '" . zen_db_input($product->fields['products_dim_type']) . "',
                                '" . zen_db_input($product->fields['products_length']) . "',
                                '" . zen_db_input($product->fields['products_width']) . "',
                                '" . zen_db_input($product->fields['products_height']) . "',
                                '" . zen_db_input($product->fields['products_ready_to_ship']) . "',  '0',
                          '" . (int)$product->fields['products_tax_class_id'] . "',
                          '" . (int)$product->fields['manufacturers_id'] . "',
                          '" . zen_db_input(($product->fields['products_quantity_order_min'] == 0 ? 1 : $product->fields['products_quantity_order_min'])) . "',
                          '" . zen_db_input(($product->fields['products_quantity_order_units'] == 0 ? 1 : $product->fields['products_quantity_order_units'])) . "',
                          '" . zen_db_input($product->fields['products_priced_by_attribute']) . "',
                          '" . (int)$product->fields['product_is_free'] . "',
                          '" . (int)$product->fields['product_is_call'] . "',
                          '" . (int)$product->fields['products_quantity_mixed'] . "',
                          '" . zen_db_input($product->fields['product_is_always_free_shipping']) . "',
                          '" . zen_db_input($product->fields['products_qty_box_status']) . "',
                          '" . zen_db_input($product->fields['products_quantity_order_max']) . "',
                          '" . zen_db_input($product->fields['products_sort_order']) . "',
                          '" . zen_db_input($product->fields['products_price_sorter']) . "',
                          '" . zen_db_input($categories_id) . "')");

Lettermail shipping option was showing when weight less than max lettermail weight but not "letter" packaging setup in sellonline profile

I made change in includes/modules/shipping/canadapost.php

 
 $canadapostQuote = $this->_canadapostGetQuote();
   
   // Twitch bugfix - add lettermail switch control
   // orginal code    if ($this->lettermail_available && ($shipping_weight <= $this->lettermail_max_weight))
   if (MODULE_SHIPPING_CANADAPOST_LETTERMAIL_STATUS == 'True' && ($shipping_weight <= $this->lettermail_max_weight))

to

 $canadapostQuote = $this->_canadapostGetQuote();
    
    // Twitch bugfix - add lettermail switch control
    // orginal code    if ($this->lettermail_available && ($shipping_weight <= $this->lettermail_max_weight))
    if (MODULE_SHIPPING_CANADAPOST_LETTERMAIL_STATUS == 'True' && $this->lettermail_available)

Deborah Hartin

3 Jul 2020, 4:21 PM
#458
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Canada Post module

**dchquilling **As you can see there are some issues with the lettermail returning rates related to store setting box sizes in Admin > Configuration > Shipping/Packaging *relative *to their own products *relative *to what Canada Post wants to see to return a rate *relative *to the data provided.

That Twitch Bugfix line helped ensure the lettermail would **return a rate **with the conditions mentioned in the install also *relative *to the 'matrix' these types of modules can create with so many potential options/settings and sizes.

You mentioned mixed weight/size metric vs imperial within a product - which is not recommended in the module (but happens I understand) - and provided a fix that works for you. Great! However, because the various settings in various carts cause multiple potential alternative output paths with different data at any endpoint... these changes may not work for everyone if say the box sizes or weights change or the metric/imperial line is crossed or mixed.

So, when time/funding permits I'll have a look at the change and test all of the potential positive solutions and publish a fix/updated module unless someone beats me to it!

If you could provide the settings in Shipping/Packaging, those in all of the lbs/kgs language files, an example of two products one metric one imperial and those set in your Canada Post module I can start testing where you are.

Thanks!

Twitch.
https://www.twitchtoo.com Do you work for free? Please donate.
June 7.2026 - NOW AVAILABLE - Twitch Base8 - Obsidian

3 Jul 2020, 5:28 PM
#459
dchquilling avatar

dchquilling

New Zenner

Join Date:
Sep 2006
Location:
New Brunswick, Canada
Posts:
12
Plugin Contributions:
0

Re: Canada Post module

Sorry - I didn't explain properly - All the products in my store are kgs/cm - no lbs/in

In the insert statement the product_status value '0' was being set after products_weight but should have been set after products_ready_to_ship according to the column order in statement

As a result the values for next 6 columns were off by 1 (width column was set to length value, height column was set to width value)

Deborah Hartin

21 Jul 2020, 2:24 PM
#460
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Canada Post module

Advanced Developers only:

To completely remove Canada Post module you will need to dump all of the product fields made by the shipping module install - after uninstalling it. This SQL Update will also permanently remove the data within so... ONLY use this for* upgrades * and testing - Best not to lose manually entered data.

Backup the database now. Twice. And test your backups.

ALTER TABLE products DROP products_weight_type;
ALTER TABLE products DROP products_dim_type;
ALTER TABLE products DROP products_length;
ALTER TABLE products DROP products_width;
ALTER TABLE products DROP products_height;
ALTER TABLE products DROP products_ready_to_ship;

Future Twitch versions Base6 will have these fields included in the core to ensure there is no change or need for changes when installing/uninstalling shipping modules.

Twitch.
https://www.twitchtoo.com Do you work for free? Please donate.
June 7.2026 - NOW AVAILABLE - Twitch Base8 - Obsidian