UPS Rate calculation returning "Maximum number of packages exceeded"

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
Both uses Pack By Dimensions. Pass Dimensions is also checked.
7 years ago
Guys, need help. Still have the same problem. My item has L=17 W=17 H=17 and weight is 15 lbs. I tried ordering 3 quantities in my cart of same item. But only shows 1 package and the dimensions are messed up. I'm using Pack By Dimensions.

System.Exception: Packing Type: PackByDimensions Package: LxHxW=25x25x25; Weight=45; Insured=0 USD.
7 years ago
Up, please help.
7 years ago
@dyoll
What version of nopCommerce?   What are all your UPS configuration settings?
7 years ago
New York,

I'm using the latest 3.80 version. My settings are UPS Ground, Pack by Dimensions, Pass Dimensions = true, Tracing = True.

I believe this is the code for Pack by Dimensions (i did not make any changes):


private void SetIndividualPackageLineItems(StringBuilder sb, GetShippingOptionRequest getShippingOptionRequest, UPSPackagingType packagingType, decimal orderSubTotal, string currencyCode)
        {
            // Rate request setup - Total Dimensions of Shopping Cart Items determines number of packages

            var usedMeasureWeight = GetUsedMeasureWeight();
            var usedMeasureDimension = GetUsedMeasureDimension();

            decimal lengthTmp, widthTmp, heightTmp;
            _shippingService.GetDimensions(getShippingOptionRequest.Items, out widthTmp, out lengthTmp, out heightTmp);

            int length = ConvertFromPrimaryMeasureDimension(lengthTmp, usedMeasureDimension);
            int height = ConvertFromPrimaryMeasureDimension(heightTmp, usedMeasureDimension);
            int width = ConvertFromPrimaryMeasureDimension(widthTmp, usedMeasureDimension);
            int weight = ConvertFromPrimaryMeasureWeight(_shippingService.GetTotalWeight(getShippingOptionRequest), usedMeasureWeight);
            if (length < 1)
                length = 1;
            if (height < 1)
                height = 1;
            if (width < 1)
                width = 1;
            if (weight < 1)
                weight = 1;

            if ((!IsPackageTooHeavy(weight)) && (!IsPackageTooLarge(length, height, width)))
            {
                if (!_upsSettings.PassDimensions)
                    length = width = height = 0;

                int insuranceAmount = _upsSettings.InsurePackage ? Convert.ToInt32(orderSubTotal) : 0;
                AppendPackageRequest(sb, packagingType, length, height, width, weight, insuranceAmount, currencyCode);
            }
            else
            {
                int totalPackagesDims = 1;
                int totalPackagesWeights = 1;
                if (IsPackageTooHeavy(weight))
                {
                    totalPackagesWeights = Convert.ToInt32(Math.Ceiling((decimal)weight / (decimal)MAXPACKAGEWEIGHT));
                }
                if (IsPackageTooLarge(length, height, width))
                {
                    totalPackagesDims = Convert.ToInt32(Math.Ceiling((decimal)TotalPackageSize(length, height, width) / (decimal)108));
                }
                var totalPackages = totalPackagesDims > totalPackagesWeights ? totalPackagesDims : totalPackagesWeights;
                if (totalPackages == 0)
                    totalPackages = 1;

                int weight2 = weight / totalPackages;
                int height2 = height / totalPackages;
                int width2 = width / totalPackages;
                int length2 = length / totalPackages;
                if (weight2 < 1)
                    weight2 = 1;
                if (height2 < 1)
                    height2 = 1;
                if (width2 < 1)
                    width2 = 1;
                if (length2 < 1)
                    length2 = 1;

                if (!_upsSettings.PassDimensions)
                    length2 = width2 = height2 = 0;

                //The maximum declared amount per package: 50000 USD.
                int insuranceAmountPerPackage = _upsSettings.InsurePackage ? Convert.ToInt32(orderSubTotal / totalPackages) : 0;

                for (int i = 0; i < totalPackages; i++)
                {
                    AppendPackageRequest(sb, packagingType, length2, height2, width2, weight2, insuranceAmountPerPackage, currencyCode);
                }
            }
        }
7 years ago
dyoll wrote:
Guys, need help. Still have the same problem. My item has L=17 W=17 H=17 and weight is 15 lbs. I tried ordering 3 quantities in my cart of same item. But only shows 1 package and the dimensions are messed up. I'm using Pack By Dimensions.

System.Exception: Packing Type: PackByDimensions Package: LxHxW=25x25x25; Weight=45; Insured=0 USD.


That's the way the "Packing" works.  Most carriers (like UPS) base their rates primarily on the weight (even if dimensional weight).  The nopC ShippingService has a GetDimensions() method, that will use the cube root of total volume (of all packages) to determine the length of each package:

            if (_shippingSettings.UseCubeRootMethod)
            {
                //cube root of volume

In your case,  17 * 17 * 17  * qty 3 =  4913 * 4 = 14739
cube root of 14739 = 24.518...  - rounds up to 25.
So, the "Packing" calculated 1 package 25 * 25 * 25 of 45 lbs  

(note code comment "
                    //we do not use cube root method when we have only one item with "qty" set to 1
so, that's why you did not see the issue when qty = 1)

You can try setting UseCubeRootMethod to False (in "All Settings"), but note
a) warning:
            else
            {
                //summarize all values (very inaccurate with multiple items)
...

b) it still "packs", just using (different) calculated dimensions.


(P.S. You may be thinking "I just want to ship each product separately in its own box".  Although a Product has a ShipSeparately attribute, the shipping service deals with cart "items". Thus multiple quantity of the same product is a single item in the cart, and it will "ship separately" the item, not each product by quantity.)

(P.P.S  Shipping Director has its own Packing record type.  It uses 'cube root' method, but it lets you specify dimensions of a single "box", and it "packs" boxes, rather than taking cube root of total. [if item won't fit box, then it gets its own dims].   Also, SD packing can support OneRequestPerPackage.  But I would not recommend that if you have 150 quantity, as it will call the UPS API 150 times, which will take a long time.  You can read more about SD Packing.  Read from bottom up ;)
7 years ago
I forgot...
The UPS plugin also has a Packing type "PackByOneItemPerPackage"
7 years ago
In reading this post, I take it that adding a large quantity of 1 item is a problem. For example some of my products are small. Printed forms that sell for 20 cents each. I have them in there as sold per pc and a normal sale is 250, 500, 1000 or even 10,000 pcs.

Is this going to mess up the UPS rate calculator?

If so, what do I need to do to fix that problem?
7 years ago
For many small items, I don't think there is a problem if you pack by volume.  You should test it.
7 years ago
New York wrote:
For many small items, I don't think there is a problem if you pack by volume.  You should test it.


OK, thanks...
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.