Jump to content

[Solved] UPS Module calculated incorrect (also FedEX and USPS)


Recommended Posts

hello

The UPS module calculates incorrect shipping charges.

It seems that it sums all the charges by single item.

For example:

Item #1: 1 lbs --> Shipping cost $5 (when along)
Item #2: 2 lbs --> Shipping cost $6 (when along)

If you add 2 quantities of Item #1, you get $10 as shipping fee.
If you add item #1 and item #2 in cart, you get $11 as shipping fee.


Therefore this is a very serious bug or logic error within the UPS module code.


Just wondering if anyone here has a temporary fix for this.

Thank you

Link to comment
Share on other sites

I found out that if you turn on the Caching triggers this bug for not letting you into UPS configure.

I have reported in the bug track, hope the error is not my GoDaddy as I have no other servers to test.

Anyways... I am replying my own post... sigh...

I have modified the upscarrier.php module to have it combine all products weight before calculating.
I have not fully test it, but would like to upload it here for you guys to help me find errors.

Before you test, make sure you clear out the UPS Cache in the mySQL.

Line 1429 - 1430

Lets you set the maximum weight and dimension volume of your package before going to the next.

04/06/11
Remove the code -- it has logic problems -- that's what happens when I code to fast


I know the code is not complete, but its good for now I guess. Wait for Prestashop Devs to figure out a better solution and coding.


The mod can also be allied to USPS and FedEX

Link to comment
Share on other sites

Having the same problem with USPS shipping module:

When adding multiple quantities of a product, the shipping rate only calculates for 1 of such product.

Example:

Item1 : Weight: 2lbs, Shipping $5 per item

Cart 1: 1 X Item1 = $5.00 Shipping
Cart 2: 3 X Item1 = $5.00 Shipping as well.

The price for Cart 2 should reflect 6lbs and cost $15 (or w/e the USPS shipping rate would be for 6lbs), instead the cart only calculates $5.00 total shipping even though there are 3 items in the cart.

MAJOR BUG. PLEASE FIX. CAN'T EVEN RELEASE MY SITE UNTIL THIS BUG IS FIXED!!

PRESTASHOP 1.4 NEW INSTALL w/ SAMPLE DATA.

Link to comment
Share on other sites

  • 2 weeks later...

Ugh...

Glad you guys mentioned the whole weights thing.

Why is it *everything* I do with prestashop, I need to fix their code?

As soon as I fix the address entry part of the checkout, I'll take a look at their stupid modules and put first class back in and look at how theyre calculating weights. But then here's a new problem:

Don't they update modules automatically now? If I modify their modules and post a fix here, we can't let the module update!

Link to comment
Share on other sites

Is there any discussion anywhere in the forums about the USPS module that comes with PrestaShop 1.4, regarding First Class service showing "not available?" All the other USPS services are available, and the one I need to use, First Class, says "not available." Why? I have used Tomer's USPS module and it worked fine. Is the new USPS module that comes with PS 1.4 worthless? Why would the main service, First Class, not be "available" when all the other services such as Priority and Express seem to work fine?


First class is only available for items weighting under 13oz, I'm not sure if that's the issue, but it may be.

If you used my module before, why not use the version for PS 1.4, it has the ability to enter multiple box sizes that you use for shipping, and it will automatically calculate how many boxes are needed to fit all the products.
It will try to use the smallest / lowest amount of boxes.

It also lets you set a free shipping limit for each shipping method.
Link to comment
Share on other sites

04/12/2011

Ok, previously I was posting fixes. I submitted them to the bugtracker and the developer of the modules got in touch with me happy to have feedback to fix the modules.

Currently the SVN version (svn.prestashop.com) has fixed versions.

- You can now select to quote shipping for all items in their own packages (i still dont know why he chooses to do this...) or all in one package as we want.

- Invalid first class queries missing field have been fixed.

- Default "test" weights were 1lb/2lb making it automatically get a fail result for firstclass no matter what

Now, I've made a few more changes that are not on the svn. you will still need the .xml templates off the svn version. So i you want these, update module files with the SVN first, then update with this file.

I added a field for default packaging weight. This is especially crucial when dealing with first class since packaging WILL put your weight up by 1-3 ounces.

I added a field for handling fee. The module disregards prestashop's handling fee. My fix does not currently account for any currency conversion as it was just a quick fix. So if you allow anything other than your default shop currency, check back here for a proper update. (hey, this is bleeding edge updating ;)

uspscarrier.php

uspscarrier.php

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

Is there a solution to the UPS carrier calculating incorrectly. My newly upgraded and live shop is calculating extremely high shipping rates as it just doubles the rate every time you increase the quantity of the product in the cart. If someone has insight on how to fix this I'd appreciate it. The UPS module is a little frightening as I spent hours one night reinstalling it since it would "work" (meaning give available shipping options in cart) and then as soon as I would edit shipping options at all, it would say "no carriers available to this address". Super frustrating.

Someone mentioned modifying the code to add the weight of cart before calculating shipping? Thanks in advance to anyone that can help me get this resolved.

Link to comment
Share on other sites

The problem is he had coded it to calculate shipping rates for each item as its own package then add them together. I don't know why he insisted on this.
On his USPS version, it did the same thing but incorrectly. It would query each item as its own package and return only the highest rate.

I worked with the developer, my version is the one on the SVN. Atleast USPS, he never responded when I sent him a patched UPS module.

Since then I've also added a default packaging weight (for those first class shippers, packaging will usually add 1-2oz easily)
plus a default handling fee since the module ignores the prestashop handling fee in leue of per-item fees.

Also, if i remember correctly, UPS was hardcoded to a default 10"x10"x10" package which is significantly larger than my typical package so I had modified that as well.. I believe it would adjust it if you have dimensions set on your products.

USPS and UPS.zip

Link to comment
Share on other sites

Is there a solution to the UPS carrier calculating incorrectly. My newly upgraded and live shop is calculating extremely high shipping rates as it just doubles the rate every time you increase the quantity of the product in the cart. If someone has insight on how to fix this I'd appreciate it. The UPS module is a little frightening as I spent hours one night reinstalling it since it would "work" (meaning give available shipping options in cart) and then as soon as I would edit shipping options at all, it would say "no carriers available to this address". Super frustrating.

Someone mentioned modifying the code to add the weight of cart before calculating shipping? Thanks in advance to anyone that can help me get this resolved.


Yea, it caches rates. make any change and you'll have to make your cart different (add/drop items) or clear the cache to see results. There is no "clear cache" button so you have to do it manually.

In *my* next revision I'm going to add fields for default package dimensions and a clear cache button. If the developer adds that to the SVN or not is up to him.
Link to comment
Share on other sites

  • 2 weeks later...

I'm having this same problem with the Fedex module; it doubles the rate when you increase product quantity. Could you share what code needs to be to modified so the weight of the cart is calculated as one package.

My online store isn't live until I solve this, so I appreciate any tips immensely!

I'm using the SVN version of the Fedex module

fedexcarrier.php

Link to comment
Share on other sites

I had a temp fix and that was to modify the configuration settings in the back office.. change the max number of packages to 1 and that did the trick.

Now multiple items ship in one box..
That made the difference for me. good luck.


Thanks! But I can't find where to change this in BO?
Link to comment
Share on other sites

It sounds like he's talking about the updated modules, which I had posted here.

It is under "calcul mode" on the configuration page, you can now change it to "all in one package". The developer wanted to retain his original "all in seperate boxes" method as an option, but that was flawed with UPS to begin with so now "all in one box" works and "all in seperate" does not work. I personally see no use for that option for myself or 99.9999% of users, so I won't waste my time on fixing that one myself...

Link to comment
Share on other sites

 // Getting shipping cost for each product
       foreach ($wsParams['products'] as $product)
       {
           // Load specific configuration
           $config = $this->loadShippingCostConfig($product);

           // Get service in adequation with carrier and check if available
           $serviceSelected = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'fedex_rate_service_code` WHERE `id_carrier` = '.(int)($this->id_carrier));
           if (!isset($config['services'][$serviceSelected['id_fedex_rate_service_code']]))
               return false;

           // Load param product
           $wsParams['service'] = $serviceSelected['code'];
           for ($qty = 0; $qty < $product['quantity']; $qty++)
               $wsParams['package_list'][] = array(
                   'width' => ($product['width'] ? $product['width'] : 1),
                   'height' => ($product['height'] ? $product['height'] : 1),
                   'depth' => ($product['depth'] ? $product['depth'] : 1),
                   'weight' => ($product['weight'] ? $product['weight'] : 1),
                   'pickup_type' => (isset($config['pickup_type_code']) ? $config['pickup_type_code'] : Configuration::get('FEDEX_CARRIER_PICKUP_TYPE')),
               );



I think this where I need to tweak the code but I'm no good with php so I'd love if someone could make a suggestion.

Link to comment
Share on other sites

Hi everybody,

Sorry not having answered to this topic sooner.

@Enigma : Thanks for your fix and your help, and sorry not having taken the time to integrate all your fixes (I will try to correct this quickly).
I chose to keep "all in separate" option because some merchants asked me even if I could understand that this option won't be use a lot.
I'm currently working on an option that will permit to roll in a new package once the maxweight (that you will be able to define) is reached, a merchant asked me this option.

@Gbaby : Unfortunately there is no such option on Fedex yet but I will add it soon and upload the module on addons.prestashop.com (where you will be able to download it for free).

Thanks again for you help (specially Enigma who helps me a lot :))

I keep you informed here of the updates.

Link to comment
Share on other sites

Fabien, you finally made it to the party!

Thank you for the great work. You've been more helpful assisting me than people I've bought shipping modules from. I'm just trying to pass along the updates and some tweaks of my own to my fellow users.

Right now we're all just wanting the basics, but I certainly can see the future applications of it. I will need such functionality myself in the near future. It would require declaring different packaging profiles with maximum volume (rather then weight) and calculating by product dimensions the maximum that will fit in one box before 'opening' another shipping box.

Anyhow, to the others:

I don't use FEDEX for shipping, so I cannot test this. Fabien's modules are very similar to eachother so I've updated the fedex module accordingly and it SHOULD work. I also found a random UPS variable left behind in the fedex module and corrected that.

1. BACKUP THE ORIGINAL
2. update this, cross your fingers, and post here if it works correctly please

fedexcarrier.php

Link to comment
Share on other sites

  • 3 weeks later...

@Enigma32,

Sorry taking so much time to answer to this post.
I finally take the time to look at your version of this module and the work done is amazing :)
I added your modification on the SVN (not the all file because some modifications has been done since the last time).

I just corrected one mistake you made (not very important one) :

Notice: Undefined variable: configCurrency in /var/www/prestashop.1.4.x/modules/fedexcarrier/fedexcarrier.php on line 491 Notice: Trying to get property of non-object in /var/www/prestashop.1.4.x/modules/fedexcarrier/fedexcarrier.php on line 491 


I just added this :

$configCurrency = new Currency((int)Configuration::get('PS_CURRENCY_DEFAULT'));



I did not found the UPS variable you said I left behind (but maybe someone else of the team remove it).

I posted it on the SVN and I attached the new module (1.1) to this post.
For people who will test this new version, please post here to tell if it's working correctly or if you have problems with it.

I will now look at your post on USPS and UPS.
Thanks for your help (and work) on this :)

Best regards,

fedexcarrier.zip

Link to comment
Share on other sites

@cs378

I know it's been a while since this post was made but I just wanted to tell that the bug on MySQL caching with module (UPS or other) on PrestaShop 1.4 has been solved.
If you do not want to upgrade to the last version, you just have to get the /classes/MySQL.php from the SVN or from the PrestaShop 1.4.3

Best regards,

Link to comment
Share on other sites

@Enigma32

I commited your fix and new features on the SVN. Thanks again for your precious help !
As for fedex carrier, I corrected your little mistake on the currency sign. I also add the option "calcul mode" in the hash of the cache. This way, when you want to make test by changing the calcul mode, you don't have to make a new cart to see the difference (I'll do the same on fedex).

The new version of USPS in on the SVN, I attached it to this post too.

Now, I'll check the version of your UPS.

Best regards,

uspscarrier.zip

Link to comment
Share on other sites

  • 1 month later...

@Fabien

 

By default, there is no tracking URL in the modules, and if you cannot modify external carriers via shipping->carriers

 

I've added some changes, since our line #'s won't match up at all at this point you'll have to find the relevant snippets

 

uspscarrier.php:

 

in function installCarriers(), after "'delay' => array('fr' => $rateService['service'], 'en' => $rateService['service'])," line i added:

 

'url' => 'https://tools.usps.com/go/TrackConfirmAction_input?qtc_tLabels1=@',

 

in function installExternalCarrier, after line $carrier->delay = $config['delay'];, i added:

 

$carrier->url = $config['url'];

 

 

Similar changes for UPS except for different tracking url:

 

'url' => 'http://wwwapps.ups.com/WebTracking/track?track.x=Track&trackNums=@',

 

 

I do not yet use fedex, so I'm not sure on their tracking url

Link to comment
Share on other sites

×
×
  • Create New...