UPS Shipping calculation issue if multiple items are added to cart

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 years ago
Hello,

I am having an issue with my shipping rates not being calculated correctly when more then 1 item is order.  If I place an order for 1 item and select UPS shipping the rate for ground is 10.88.  If I select 2 of the same items the rate jumps up to 88.32.  My item is 20x20x5 and weight = 7 pounds.  

I would assume that it would either think I would ship two seperate boxes but I think it is combining the dimensions to something like 40x40x10 instead of 20x20x10.  Is there a setting that I can change to make the system view each item as a seperate box and not combine the dimmensions?  If not does anyone have other suggestions on how to resolve?

Thanks,
Scott
13 years ago
damn seems like nobody has an answer im thinking of leaving nopcommerce, because the lack of support i get here.
its unbeliveable
13 years ago
Is there any way to correct this issue?
13 years ago
Apparently, this is a long-term bug meaning it has not been fixed for several versions--we're running 1.4 still, and were thinking of switching to UPS to save money, but now can't because of this bug.

I've noticed that the FedEx module is **more** accurate than the UPS module at calculating based on dimensions, but is still off as well.

The UPS module won't even calculate shipping rates if someone buys 10 of our bags because the calculated dimensions exceed their maximum box sizes! FedEx will calculate a rate for 10 our our products, but the fees are underestimated. Which likely means that the FedEx module is calculating only by weight and distance, not dimensions.

The UPS module can be converted to use weight only, no box size which works fine for small objects--it's close to accurate--but not helpful for larger orders. To use weight only you need to **not** have dimensions listed in the Product Variants page for the product--only weight.
13 years ago
Hi,

I too have had this problem. As you have found out the problem is with the way nopCommerce calcualates the dimensions of packages (which i find a very strange way of calcualting).

I have found a work around (as mentioned above) but its not perfect.

UPS seems to ship based on weight up until a certain size, luckily for us (i would check to see your terms, etc) it is quite a large size before this has any effect.

So depending upon the how big your packages are, if you can safey assume the sizes will not exceed this size. then i would simply change the size check inthe UPS module computation method to either be 0 or the max size (so it always sends this size).

Otherwise this is going to be a problem as this problem is NP-hard and therefore a solution will never be complete (3d bin packing problem).

I have found some code for this (however its written in c) here;

http://www.diku.dk/hjemmesider/ansatte/pisinger/3dbpp.c
13 years ago
scottokrasinski wrote:
Hello,

I am having an issue with my shipping rates not being calculated correctly when more then 1 item is order.  If I place an order for 1 item and select UPS shipping the rate for ground is 10.88.  If I select 2 of the same items the rate jumps up to 88.32.  My item is 20x20x5 and weight = 7 pounds.  

I would assume that it would either think I would ship two seperate boxes but I think it is combining the dimensions to something like 40x40x10 instead of 20x20x10.  Is there a setting that I can change to make the system view each item as a seperate box and not combine the dimmensions?  If not does anyone have other suggestions on how to resolve?

Thanks,
Scott


I'm having this issue as well in version 1.9

looking at the shipping calculation used... whoa, umm, i think this needs to be fixed.

The logic I read is that it merges all of the packages dimensions and then checks to see if it's too big of a "package", if it is, then it uses the maximum package size to calculate shipping... which doesn't make sense because the max size is supposed to be per package, not per shipment...

2nd thing wrong: after it sees that the total shipment size isn't bigger than the maximum package size,
it then shortcuts it and divides the summed packages width by the total packages, instead of pulling each individual packages specs. So if you have a 2x2x2x2 and a 8x8x8x8 it will calculate for two packages at 5x5x5x5. Makes me wonder how it would handle decimal, it's probably rounding up, so 3x3x3x3 and 2x2x2x2 would end up being two 3x3x3x3...
ugh

I really need this sending the correct package information...

Has anyone fixed the ups module to send individual package information? (i'd rather not have to recode it)
13 years ago
All of the nopCommerce shipping algorithms have the same problem.  They do not work for real world cases with multiple items of various sizes being added to the cart.

To produce accurate box selection (and shipping estimates) will require implementing "3D Bin Packing" simulation code.  Given a set of items of various sizes, and a set of various sized boxes, what is the how many boxes, and of what size, are required?  Shipping estimates would then be much more accurate, as the box selection would simulate the actual packing of boxes.

I can't find any open source C# code out there that addresses this.  However there is a developer from Finland that is offering a callable API to do exactly that.  Check out http://www.solvingmaze.com/.   Sample integration code already exists for OpenCart and Magneto.

Assuming it works as well as explained on their web site, I hope to start integrating it into nopCommerce 1.90 (although due to time constraints my first attempt will likely be less than elegant.)

Is anyone else working on this problem?
13 years ago
UPS Shipping Calculation Fix-

If you have access to the source code, do the following then recompile and replace your old Nop.Shipping.Ups with the now working one:

using UPSComputationMethod.cs

add

using NopSolutions.NopCommerce.BusinessLogic.Orders;

and replace the CreateRequest function with this

        private string CreateRequest(string AccessKey, string Username, string Password,
            ShipmentPackage ShipmentPackage, UPSCustomerClassification customerClassification,
            UPSPickupType pickupType, UPSPackagingType packagingType)
        {
            var usedMeasureWeight = IoC.Resolve<IMeasureService>().GetMeasureWeightBySystemKeyword(MEASUREWEIGHTSYSTEMKEYWORD);
            if (usedMeasureWeight == null)
                throw new NopException(string.Format("UPS shipping service. Could not load \"{0}\" measure weight", MEASUREWEIGHTSYSTEMKEYWORD));

            var usedMeasureDimension = IoC.Resolve<IMeasureService>().GetMeasureDimensionBySystemKeyword(MEASUREDIMENSIONSYSTEMKEYWORD);
            if (usedMeasureDimension == null)
                throw new NopException(string.Format("UPS shipping service. Could not load \"{0}\" measure dimension", MEASUREDIMENSIONSYSTEMKEYWORD));


            
            string zipPostalCodeFrom = ShipmentPackage.ZipPostalCodeFrom;
            string zipPostalCodeTo = ShipmentPackage.ShippingAddress.ZipPostalCode;
            string countryCodeFrom = ShipmentPackage.CountryFrom.TwoLetterIsoCode;
            string countryCodeTo = ShipmentPackage.ShippingAddress.Country.TwoLetterIsoCode;


            var sb = new StringBuilder();
            sb.Append("<?xml version='1.0'?>");
            sb.Append("<AccessRequest xml:lang='en-US'>");
            sb.AppendFormat("<AccessLicenseNumber>{0}</AccessLicenseNumber>", AccessKey);
            sb.AppendFormat("<UserId>{0}</UserId>", Username);
            sb.AppendFormat("<Password>{0}</Password>", Password);
            sb.Append("</AccessRequest>");
            sb.Append("<?xml version='1.0'?>");
            sb.Append("<RatingServiceSelectionRequest xml:lang='en-US'>");
            sb.Append("<Request>");
            sb.Append("<TransactionReference>");
            sb.Append("<CustomerContext>Bare Bones Rate Request</CustomerContext>");
            sb.Append("<XpciVersion>1.0001</XpciVersion>");
            sb.Append("</TransactionReference>");
            sb.Append("<RequestAction>Rate</RequestAction>");
            sb.Append("<RequestOption>Shop</RequestOption>");
            sb.Append("</Request>");
            if (String.Equals(countryCodeFrom, "US", StringComparison.InvariantCultureIgnoreCase) == true)
            {
                sb.Append("<PickupType>");
                sb.AppendFormat("<Code>{0}</Code>", GetPickupTypeCode(pickupType));
                sb.Append("</PickupType>");
                sb.Append("<CustomerClassification>");
                sb.AppendFormat("<Code>{0}</Code>", GetCustomerClassificationCode(customerClassification));
                sb.Append("</CustomerClassification>");
            }
            sb.Append("<Shipment>");
            sb.Append("<Shipper>");
            sb.Append("<Address>");
            sb.AppendFormat("<PostalCode>{0}</PostalCode>", zipPostalCodeFrom);
            sb.AppendFormat("<CountryCode>{0}</CountryCode>", countryCodeFrom);
            sb.Append("</Address>");
            sb.Append("</Shipper>");
            sb.Append("<ShipTo>");
            sb.Append("<Address>");
            sb.Append("<ResidentialAddressIndicator/>");
            sb.AppendFormat("<PostalCode>{0}</PostalCode>", zipPostalCodeTo);
            sb.AppendFormat("<CountryCode>{0}</CountryCode>", countryCodeTo);
            sb.Append("</Address>");
            sb.Append("</ShipTo>");
            sb.Append("<ShipFrom>");
            sb.Append("<Address>");
            sb.AppendFormat("<PostalCode>{0}</PostalCode>", zipPostalCodeFrom);
            sb.AppendFormat("<CountryCode>{0}</CountryCode>", countryCodeFrom);
            sb.Append("</Address>");
            sb.Append("</ShipFrom>");
            sb.Append("<Service>");
            sb.Append("<Code>03</Code>");
            sb.Append("</Service>");

            decimal dWidth = 0;
            decimal dHeight = 0;
            decimal dWeight = 0;
            decimal dLength = 0;
            foreach (ShoppingCartItem scPack in ShipmentPackage.Items)
            {
                dWidth = scPack.ProductVariant.Width;
                dHeight = scPack.ProductVariant.Height;
                dWeight = scPack.ProductVariant.Weight;
                dLength = scPack.ProductVariant.Length;
                int length = Convert.ToInt32(Math.Ceiling(IoC.Resolve<IMeasureService>().ConvertDimension(dLength, IoC.Resolve<IMeasureService>().BaseDimensionIn, usedMeasureDimension)));
                int height = Convert.ToInt32(Math.Ceiling(IoC.Resolve<IMeasureService>().ConvertDimension(dHeight, IoC.Resolve<IMeasureService>().BaseDimensionIn, usedMeasureDimension)));
                int width = Convert.ToInt32(Math.Ceiling(IoC.Resolve<IMeasureService>().ConvertDimension(dWidth, IoC.Resolve<IMeasureService>().BaseDimensionIn, usedMeasureDimension)));
                int weight = Convert.ToInt32(Math.Ceiling(IoC.Resolve<IMeasureService>().ConvertWeight(dWeight, IoC.Resolve<IMeasureService>().BaseWeightIn, usedMeasureWeight)));
                if (length < 1)
                    length = 1;
                if (height < 1)
                    height = 1;
                if (width < 1)
                    width = 1;
                if (weight < 1)
                    weight = 1;
               int i = scPack.Quantity;
                while (i>0)
                {
                        sb.Append("<Package>");
                        sb.Append("<PackagingType>");
                        sb.AppendFormat("<Code>{0}</Code>", GetPackagingTypeCode(packagingType));
                        sb.Append("</PackagingType>");
                        sb.Append("<Dimensions>");
                        if (IsPackageTooLarge(length, height, width))
                        {
                            sb.AppendFormat("<Length>{0}</Length>", 33);
                            sb.AppendFormat("<Width>{0}</Width>", 33);
                            sb.AppendFormat("<Height>{0}</Height>", 33);
                        }
                        else
                        {
                            sb.AppendFormat("<Length>{0}</Length>", dLength.ToString("N2"));
                            sb.AppendFormat("<Width>{0}</Width>", dWidth.ToString("N2"));
                            sb.AppendFormat("<Height>{0}</Height>", dHeight.ToString("N2"));
                        }
                            sb.Append("</Dimensions>");
                        sb.Append("<PackageWeight>");
                        if (IsPackageTooHeavy(weight))
                        {
                            sb.AppendFormat("<Weight>{0}</Weight>", MAXPACKAGEWEIGHT);
                        }
                        else
                        {
                            sb.AppendFormat("<Weight>{0}</Weight>", dWeight.ToString("N2"));
                        }
                        sb.Append("</PackageWeight>");
                        sb.Append("</Package>");
                 i--;
                }
                    
            }
            sb.Append("</Shipment>");
            sb.Append("</RatingServiceSelectionRequest>");
            string requestString = sb.ToString();
            return requestString;
        }
13 years ago
Anyone else try this fix yet and have any feedback?

Is there a way for this fix to work for the rest of us who do not have the ability to recompile the code?

Thank you for starting to provide solutions!
13 years ago
You need source code and re-compilation is required in order for these changes to take place.

If you don't have access to the source code then download the source code version and install is on your local machine > do the above mentioned changes > recompile the solution > copy the new dlls > replace the required dlls on your server =  it should work
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.