Jump to content
blucollarguy

Multi_Vendor_Shipping new thread

Recommended Posts

First look at the fedex1.php module. The install method should start with this:

    function install($vendors_id='1') {

If so, then it is not getting called with the correct vendors_id and is defaulting to 1. Then look in admin/vendor_modules.php and find the install code (line 39):

            $module->install($vendors_id);  //MVS

You should also look at (line 17):

  $vendors_id = (isset($_GET['vendors_id']) ? $_GET['vendors_id'] : 'a');

If that all looks right, check the URL string to see if you are getting the parameters (with the correct vendor selected and the fedex module highlighted):

...vendor_modules.php?module=fedex1&vendors_id=3&osCAdminID=...

 

The problem should be somewhere in one of those.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites
The problem should be somewhere in one of those.

 

Regards

Jim

I jsut ahd a look at those files and everythign appears as you indicated. I then went back into the admin area and checked the URL when I select the vendor then select FedEx for that vendor and get the URL http://store.majiks.ca/admin/vendor_module...ng&vendors_id=3 So, it's passing the correct vendor ID in the admin area, but when the time comes to actually calculate shipping in the checkout, it seems to be defaulting to vendor #1. Is that the URL you'd meant to check? The admin one I mean.

 

The values are being saved to the dBase properly with the correct vendor ID, but it's not using the right ID when checking out. I looked at the dBase for teh products as well and the correct ID is attached to the products.

 

~James

Edited by Majiks

Share this post


Link to post
Share on other sites

I guessed wrong then. I was thinking that it was an installation problem, when it's really a problem with getting the quotes. Look at your checkout_shipping.php (line 280):

//MVS
 if (SELECT_VENDOR_SHIPPING == 'true') {
   require(DIR_WS_MODULES . 'vendor_shipping.php');
 } else { 
   $quotes = $shipping_modules->quote();

You might want to put some test code in there to see if vendor_shipping.php is getting called correctly. I suspect that $vendors_id is somehow not being set in vendor_shipping.php (line 38), or possibly that the $vendor_shipping array is not getting set (line 13). There are other possibilities as well, but these are a good starting point.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

I had a look in "includes/modules/vendor_shipping.php" and found:

//print "<br>Vendor_id in Shipping: " . $vendor_id;
//Get the quotes array
? ? ?$quotes = $shipping_modules->quote('', '', $vendor_id);

I uncommented the print line to see what the ID was and reloaded the checkout shipping page, it said "Vendor_id in Shipping: 3". So, it's correct there. :unsure: I'm not new to PHP, but am new to osCommerce and MVS and their file structures. I'm getting to know it, but all help is very much appreciated.

 

If the correct vendor ID is being used in vendor_shipping.php should it not be correct when the rates are being calculated? Doesn't vendor_shipping call the individual shipping module, in this case fedex1? I may be wrong about this though as I'm only just starting to get to figure out the structuring of MVS.

 

Where would you suggest starting at to try and work backwards to see where it's being set wron or not being passed to fex1.php? That is of course assuming fedex1.php is defaulting to ID #1 because it isn't being passed the ID number.

 

~James

Edited by Majiks

Share this post


Link to post
Share on other sites

Another thing is why the vendor ID is only be messed up with FedEx, the other methods I have enabled are working properly. :S

Share this post


Link to post
Share on other sites

The quotes are retrieved in the next line. $shipping_modules is an instance of the shipping class in includes/classes/vendor_shipping.php, which is where the quotes are collected from the individual modules. I can't quite see how that is getting messed up. You can try to print out the $quotes array to see what is coming back. It's a lot of data, so you'll have to look through it to find the fedex output.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites
The quotes are retrieved in the next line. $shipping_modules is an instance of the shipping class in includes/classes/vendor_shipping.php, which is where the quotes are collected from the individual modules. I can't quite see how that is getting messed up. You can try to print out the $quotes array to see what is coming back. It's a lot of data, so you'll have to look through it to find the fedex output.

 

Regards

Jim

Usig print_r($quotes) I get the following output:

Array ( [0] => Array ( [module] => Federal Express [error] => No response to CURL from Fedex server, check CURL availability, or maybe timeout was set too low, or maybe the Fedex site is down [icon] =>  ) [1] => Array ( [id] => localpickup [module] => Local Pickup [methods] => Array ( [0] => Array ( [id] => localpickup [title] => Pickup In Thunder Bay [cost] => 0 ) ) ) )

The icon isn't empty for FedEx in the array, it was just showing as the graphic so didn't copy when I pasted it.

Share this post


Link to post
Share on other sites

The bugs are in the fedex module itself. For example (line 130):

      $this->_setInsuranceValue($totals / $shipping_num_boxes);

needs to be:

      $this->_setInsuranceValue($totals / $shipping_num_boxes, $vendors_id);

More to come.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites
More to come.

 

Regards

Jim

Should I just wait for an update and keep using Zone Rates for FedEx for now then?

 

~James

Edited by Majiks

Share this post


Link to post
Share on other sites

Still in the fedex1 module (line 412):

        if ($this->_getMeter() === false) return array('error' => $this->error_message);

should be changed to

        if ($this->_getMeter($vendors_id) === false) return array('error' => $this->error_message);

That should get rid of the error messages. However, this module needs some more changes. To start (line 371):

      $meter_sql = "UPDATE configuration SET configuration_value='" . $this->meter . "' where configuration_key='" . constant('MODULE_SHIPPING_FEDEX1_METER_' . $vendors_id) . "'";

should be:

      $meter_sql = "UPDATE " . TABLE_VENDOR_CONFIGURATION . " SET configuration_value='" . $this->meter . "' where configuration_key='" . constant('MODULE_SHIPPING_FEDEX1_METER_' . $vendors_id) . "'";

The database table should not have been hard-coded in the first place. Now for some more bugs (line 106):

      global $shipping_weight, $shipping_num_boxes, $cart, $order;

should be replaced with:

      global $shipping_num_boxes, $cart, $order;

     $shipping_weight = $cart->vendor_shipping[$vendors_id]['weight'];

That should fix the shipping weight. Next (line 133):

      if (defined("SHIPPING_ORIGIN_COUNTRY")) {
       $countries_array = tep_get_countries(SHIPPING_ORIGIN_COUNTRY, true);

should be replaced with:

      $vendors_data_query = tep_db_query("select handling_charge,
                                                handling_per_box,
                                                vendor_country
                                         from " . TABLE_VENDORS . "
                                         where vendors_id = '" . (int)$vendors_id . "'"
                                       );
     $vendors_data = tep_db_fetch_array($vendors_data_query);
     if (isset($vendors_data['vendor_country']) && $vendors_data['vendor_country'] != '')) {
       $countries_array = tep_get_countries($vendors_data['vendor_country'], true);

and the lines below

      $vendors_data_query = tep_db_query("select handling_charge,
                                                handling_per_box
                                         from " . TABLE_VENDORS . "
                                         where vendors_id = '" . (int)$vendors_id . "'"
                                       );
     $vendors_data = tep_db_fetch_array($vendors_data_query);

should be deleted.

 

That's all that I see right now. I haven't tested this (and I can't, since I don't have a FedEx account to play with), so please test this out and let us know what happens.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

It's stil spitting out the constant errors for MODULE_SHIPPING_FEDEX1_SERVER_1, MODULE_SHIPPING_FEDEX1_CURL_1, and MODULE_SHIPPING_FEDEX1_TIMEOUT_1 in the checkout shipping page.

 

Also, I had to remove a ")" from the following line as it was giving me a parse error in the admin area:

if (isset($vendors_data['vendor_country']) && $vendors_data['vendor_country'] != '')) {

Chagned it to

if (isset($vendors_data['vendor_country']) && $vendors_data['vendor_country'] != '') {

and the parse error disappeared.

 

Should

        $countries_array = tep_get_countries(SHIPPING_ORIGIN_COUNTRY, true);

still be there after inserting

       $countries_array = tep_get_countries($vendors_data['vendor_country'], true);

right above it? Or should it be deleted?

Edited by Majiks

Share this post


Link to post
Share on other sites

Try changing this (fedex1.php, line 355):

      $fedexData = $this->_AccessFedex($data);

to this

      $fedexData = $this->_AccessFedex($data, $vendors_id);

and change this (line 456)

      $fedexData = $this->_AccessFedex($data);

to this

      $fedexData = $this->_AccessFedex($data, $vendors_id);

That should fix the last of the error messages. Sorry I missed those the last time. The line using SHIPPING_ORIGIN_COUNTRY can stay, since it's just a backup for cases where the country is not set properly in the vendors table. Now if I haven't made any more silly typos, this should work.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

No more errors now, just this:

No Rates Returned, E561 : Currency Code for Intra-CA request must CAD.

~James

Share this post


Link to post
Share on other sites

I changed

$data .= '68,"CAD"'; // Insurance value currency

to

$data .= '68,"USD"'; // Insurance value currency

and it worked.

 

I wonder how this will work for those who have USD selected as the currency though. Do I need to offer only CAD as a currency to use FedEx dynamic rates?

 

~James

Edited by Majiks

Share this post


Link to post
Share on other sites

Nope, I just tried addresses in both CA and US with both currencies selected in the store and it works fine with the proper amount shown in the shipping section as long as CAD is specified within the fedex1.php file. :D Thanks for all the help!

 

Now I just need to get shipping taxes to be added to the order with MVS shipping modules as it is with the non-MVS modules so that I'm not paying the taxes my customers should be. lol That and get a Canada Post module working with MVS since I also have an account there and I'll be all set.

 

Thanks very much! You were very helpful and I honestly didn't expect that fast a response as I got from you, but it's very good too see.

 

~James

Edited by Majiks

Share this post


Link to post
Share on other sites

You'd need to ask FedEx about that. They probably have some rules about what currency to use when.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites
You'd need to ask FedEx about that. They probably have some rules about what currency to use when.

 

Regards

Jim

The currency shows properly in the store depending what the customer has selected as it should be, but you need to have CAD specified in the file. I don't know why, but it works like that. As long as CAD is specified in the file, a customer can have USD prices shown in the store jsut fine.

 

If CAD is seleced, shipping shows in CAD.. If USD is selected, shipping shows in USD. Just have to specifiy CAD within the file itself for whatever reason.

 

~James

Edited by Majiks

Share this post


Link to post
Share on other sites

We're still working on the tax bug. Craig or I will probably find it soon enough. If you want to try modifying the Canada Post module, I can send you the latest version of the instructions for modifying modules. We're also here to help if you have questions, although I can't always promise to be this quick about responding. I'm at the computer a lot, just not all the time. Despite rumor, programmers do sleep sometimes.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites
We're still working on the tax bug. Craig or I will probably find it soon enough. If you want to try modifying the Canada Post module, I can send you the latest version of the instructions for modifying modules. We're also here to help if you have questions, although I can't always promise to be this quick about responding. I'm at the computer a lot, just not all the time. Despite rumor, programmers do sleep sometimes.

 

Regards

Jim

Sure, you can send it to "james at majiks dot ca". I'll see what I can do with it over the weekend. Hopefully you'll be able to figure out the tax problem. Would be nice to not have to pay it myself. :) But, not that big a deal though since I only remit taxes for shipping to within Canada and all my suppliers are CDN or US. If I had any international suppliers it could be a big problem. lol

 

Thanks for all of your help with the FedEx module. :D

 

~James

Share this post


Link to post
Share on other sites

:( Spoke too soon. Found one last problem with the FedEx module. You can test this at my store (http://store.majiks.ca) if you like to see exactly what it's doing.

 

I added 2 items to my cart (both from different suppliers), a spincast reel and a flash drive. I got the rates with both set to 1 at around $19(CAD) for each. That's about what it should be. I then proceeded to set the quantity for the flash drive to 50 and not only did it's rate increase, but so did the rate for the reel even though it was still set at a quantity of 1! :o

 

I tried various quantities for the drive while keeping the reel set to 1 and the rate for the reel varied depending on the quantity set for the drive. The only time true rates were shown for both items was when both were set to a quantity of 1.

 

The rates for the reel shouldn't have anyhig to do with the quantity/weight of the drive when they're from separate suppliers and different points of origin. If I were to set teh quantity of the drive to 100 the lowest rate for a single reel is inflated to ~$69(CAD)! :o

 

~James

Edited by Majiks

Share this post


Link to post
Share on other sites

It sounds like it is taking the total weight rather than the weight for just that vendor. Check that you got this fix at line 106 or so:

      global $shipping_num_boxes, $cart, $order;

    $shipping_weight = $cart->vendor_shipping[$vendors_id]['weight'];

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites
It sounds like it is taking the total weight rather than the weight for just that vendor. Check that you got this fix at line 106 or so:

 ? ? ?global $shipping_num_boxes, $cart, $order;

? ? $shipping_weight = $cart->vendor_shipping[$vendors_id]['weight'];

 

Regards

Jim

I have the following:

// class methods
   function quote($method = '', $module = '', $vendors_id = '1') {
     global $shipping_num_boxes, $cart, $order;

    $shipping_weight = $cart->vendor_shipping[$vendors_id]['weight'];

     if (tep_not_null($method)) {
       $this->_setService($method);
     }

     if (constant('MODULE_SHIPPING_FEDEX1_ENVELOPE_' . $vendors_id) == 'True') {
       if ( ($shipping_weight <= .5 && constant('MODULE_SHIPPING_FEDEX1_WEIGHT_' . $vendors_id) == 'LBS') ||
            ($shipping_weight <= .2 && constant('MODULE_SHIPPING_FEDEX1_WEIGHT_' . $vendors_id) == 'KGS')) {
         $this->_setPackageType('06');
       } else {
         $this->_setPackageType('01');
       }
     } else {
       $this->_setPackageType('01');
     }

     if ($this->packageType == '01' && $shipping_weight < 1) {
       $this->_setWeight(1);
     } else {
       $this->_setWeight($shipping_weight);
     }

Share this post


Link to post
Share on other sites

Found it. The fedex module is calculating a shipping cost per box and multiplying it by the number of boxes. The number of boxes being taken is the total for the entire order, so that messes up the result. Looks like we need to calculate the number of boxes per vendor. This is not going to be a quick fix. I need to go back through the code and check that this won't break something else. I'll try to have something whipped up by tomorrow.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites
Found it. The fedex module is calculating a shipping cost per box and multiplying it by the number of boxes. The number of boxes being taken is the total for the entire order, so that messes up the result. Looks like we need to calculate the number of boxes per vendor. This is not going to be a quick fix. I need to go back through the code and check that this won't break something else. I'll try to have something whipped up by tomorrow.

 

Regards

Jim

No problem, thanks very much for your time and effort. It's much appreciated. :)

 

~James

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

×