Jump to content
imageanative

canada.post.rest.rate.service.oscommerce.V2.3

Recommended Posts

On 2018-01-19 at 8:32 AM, luvubeauty said:

I am having issues with the Small Packet Air showing up in the shipping quotes when someone goes to checkout.  I do have insurance turned off and CP tech support is useless, so here I am.  I saw that there were the same issues, but I tried the suggested and still didn't work.  Any other suggestions? 

Why not just “dis-allow” the service in the modules configuration?

 

(side note: I believe the insurance issue was related to the Tracked Package service)

Share this post


Link to post
Share on other sites
On 1/21/2018 at 8:05 AM, greasemonkey said:

Why not just “dis-allow” the service in the modules configuration?

 

(side note: I believe the insurance issue was related to the Tracked Package service)

The small packet is extremely cheaper than tracked package and am positive I am loosing sales because the shipping to the US is so high (tracked package is $25 and small packet is $9).  When it is calling for quotes, it just isn't returning a quote for Small Packet, all other options are available.

Share this post


Link to post
Share on other sites

@luvubeauty just so I understand.... Small Packet is “not” showing up? And you have it allowed in the config?

Can you tell me the weight of one of you items? Small Packet Air (and tracked package) has a max of 1 kg. 

Share this post


Link to post
Share on other sites
51 minutes ago, luvubeauty said:

Yes, correct.  I have the weight all under 1kg, I tried with a few different items (individually) and each weigh under a lbs.  

in includes/modules/shipping/canadapost.php

Find

	return $xmlRequest;

And just above "as a test" add

	echo $weight;

What is the weight printed to the screen?

Share this post


Link to post
Share on other sites

It's showing as 1.364  Not sure why because I have the weight at zero, then I changed it to .1 and it is still showing the same.  Sooo...somewhere down the line it isn't allowing for the weight change?

Share this post


Link to post
Share on other sites

However, it is set for lbs, not kg so it still should be ok? It does change the weight when I go higher, just not lower and it does convert when I change it to KG instead of LBS

Share this post


Link to post
Share on other sites
36 minutes ago, luvubeauty said:

It's showing as 1.364  Not sure why because I have the weight at zero, then I changed it to .1 and it is still showing the same.  Sooo...somewhere down the line it isn't allowing for the weight change?

Yes, small packet air will not show with a weight of 1.364....  (has a max of 1.0 kg - see below note about lbs/kg)

Double check in your admin -> Configurations -> Shipping/Packaging -> Package Tare Weight.... Should be blank or 0.

36 minutes ago, luvubeauty said:

However, it is set for lbs, not kg so it still should be ok? It does change the weight when I go higher, just not lower and it does convert when I change it to KG instead of LBS

If I recall the lbs/kg config in the current version did not work (and cannot work - as Canada Post only accepts kg... so no matter the number sent CP see's it as kg).

I had been working on a new version to fix a bunch of other bugs where I have removed lbs as an option.

Please confirm (once you have checked the tare weight): edit one product from your store to a weight of 1 - then add that same item to your cart (so it is the only item in your cart) and navigate to checkout_shipping.php.

What number shows when you "echo" the weight (still 1.364)?

Triple check by changing config in shipping module from lbs to kg.

Share this post


Link to post
Share on other sites

You are amazing!  All options have come up! 
Weight showed up as 0.45, which would be the conversion to KG from lbs (I have it as 0.10 in the product page).


Is there a way to have the cheapest option on top?

Share this post


Link to post
Share on other sites
On 7/5/2014 at 6:24 AM, RS Designs said:

Hello,

I am also getting the same error as "simple190"

 

 

It is happening in the checkout when try to show sipping options.

 

Also is there any way to make it print out the error code it is getting?

 

I am running this on Version: 2.3.3.4

 

Thanks,

I can fix it

Share this post


Link to post
Share on other sites

Yeah, I'll do that.

I'm just playing with Phoenix in (what little) spare time I have.
I haven't decided if it's going to be worth the trouble, but, I suppose this will be a good first test....


No Good Deed EVER Goes Unpunished

Share this post


Link to post
Share on other sites

I'm looking for help in implementing this module in version 2.2. Is there anyone in the Toronto area that can do this?

Share this post


Link to post
Share on other sites

Well, I'm in Hamilton, and I was one of the people that helped keep this going, way back when. but 2.2 is a long time ago.

You might be better upgrading your database through a number of versions (there are scripts) to something like 2.3.3.4 BS reactive and install GreaseMonkey's latest iteration.

That's what I'm running on my shop and I started with 2.2 and cranked it up through the versions just as I mentioned above.


No Good Deed EVER Goes Unpunished

Share this post


Link to post
Share on other sites

Working on updating this for Phoenix - and I'm having one issue (which I believe I've confused with a similar issue on the UPS XML thread)

Thank you @azpro and @ecartz for your help... and sorry if I caused any additional confusion...

The issue I'm having is when "disallowing" a shipping service I'm receiving the following error:

Quote

Warning: constant(): Couldn't find constant CANADA_POST_Array in /home/********/public_html/*********/includes/modules/shipping/canadapost.php on line 452

Disallow array is built here:

        tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Disallowed Shipping Methods', 'MODULE_SHIPPING_CANADA_POST_TYPES', '', 'Select the Canada Post services <span style=\'color: red; font-weight: bold\'>not</span> to be offered.', '6', '12', 'get_multioption_canadapost_xml',  'canadapost_cfg_select_multioption(array(\'D.RP\',\'D.EP\',\'D.XP\',\'D.XP.CERT\',\'D.PC\',\'D.LIB\',\'U.EP\',\'U.PW.ENV\',\'U.PW.PAK\',\'U.PW.PARCEL\',\'U.SP.AIR\',\'U.SP.SURF\',\'U.XP\',\'I.XP\',\'I.IP.AIR\',\'I.IP.SURF\',\'I.PW.ENV\', \'I.PW.PAK\',\'I.PW.PARCEL\',\'I.SP.AIR\',\'I.SP.SURF\'),',  now())");

With this function:

function canadapost_cfg_select_multioption($select_array, $key_value, $key = '') 
{
	for ($i=0; $i<sizeof($select_array); $i++) {
	  $name = (($key) ? 'configuration[' . $key . '][]' : 'configuration_value');
	  $string .= '<br><input type="checkbox" name="' . $name . '" value="' . $select_array[$i] . '"';
	  $key_values = explode( ", ", $key_value);
	  if ( in_array($select_array[$i], $key_values) ) 
	  $string .= ' checked="checked"';
	  $string .= '> ' . constant('CANADA_POST_' . get_canada_post_service_code($select_array[$i]));
	} 
	$string .= '<input type="hidden" name="' . $name . '" value="--none--">';
	return $string;
}	

It would seem the result of the function = Array ... Inputting "Array" into the DB as the "disallowed" service (in place of the service code) .... hence why it cannot find the constant....

As a test, I can manually remove Array from the DB and replace it with any (multiple service codes) and it works perfectly.

I have no issues on Gold, Edge/Frozen...

I've attached a screen cap....

canadapost.jpg

Share this post


Link to post
Share on other sites

@greasemonkey

You think it might work better if it was set up to disallow everything as default and then add the ones you want to use?


No Good Deed EVER Goes Unpunished

Share this post


Link to post
Share on other sites
On 11/28/2019 at 9:16 AM, Druid6900 said:

@greasemonkey

You think it might work better if it was set up to disallow everything as default and then add the ones you want to use?

I've figured out the issue - just not sure how to fix it yet...

Share this post


Link to post
Share on other sites

So coders, assuming I'm correct (in my testing I am...lol).

How do we take the add to admin/modules.php

		  if (is_array($value) ) {
             $value = implode( ", ", $value);
		     $value = preg_replace ("/, --none--/", "", $value);
		  }

And incorporate it with the the actual shipping modules set function (in my very limited skill - the set function is building an array, which when saved, modules.php with the additional code above, is imploding the or replacing (???) the array before inserting into the configuration value)

  function upsxml_cfg_select_multioption($select_array, $key_value, $key = '') {
    $string = '';
    $key_values = explode( ", ", $key_value);
    for ($i=0, $n=sizeof($select_array); $i<$n; $i++) {
      $name = ((tep_not_null($key)) ? 'configuration[' . $key . '][]' : 'configuration_value');
      $string .= '<br /><input type="checkbox" name="' . $name . '" value="' . $select_array[$i] . '"';
      if (in_array($select_array[$i], $key_values)) $string .= ' CHECKED';
      $string .= '> ' . $select_array[$i];
    }
    return $string;
  }

Sorry for the cross post mods.... I was trying to keep this in one place but messed up....

 

Share this post


Link to post
Share on other sites

What the set_function does is it creates the form input that you use to edit it.  In this case, a bunch of checkboxes.  That is then saved in admin/modules.php .  It's the save case towards the top of the file.  Try changing it to look like

      case 'save':
        foreach ($_POST['configuration'] as $key => $value) {
          if (isset($value) && is_array($value)) {
            implode(', ', $value);
            $value = str_replace(', --none--', '', $value);
          }

          tep_db_query("update configuration set configuration_value = '" . tep_db_input(tep_db_prepare_input($value)) . "' where configuration_key = '" . tep_db_input(tep_db_prepare_input($key)) . "'");
        }
        tep_redirect(tep_href_link('modules.php', 'set=' . $set . '&module=' . $_GET['module']));
        break;
      case 'install':
      case 'remove':

Expect this to change in a future version of Phoenix. 

Sorry, I was getting distracted by the fact that this section of code has not significantly changed in a long time.  If the problem is that other Apps were changing admin/modules.php to add this code, then that makes a lot more sense. 

Edited by ecartz

Always back up before making changes.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×