[Skip to main content](#vessel-content)

#   FedEx shipping - Multiple package issue

##

- **[3by400](/forum/user/6842-3by400 "View 3by400's Profile")**
- [![3by400's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar6842.jpg)](/forum/user/6842-3by400 "View 3by400's Profile") Topic Author
- [ Offline](/forum/user/6842-3by400)

Less More

- Posts: 211
- Thank you received: 14
-
-
- [](https://3by400.com)
-

10 years 8 months ago -  10 years 8 months ago [\#230636](#230636) by [3by400](/forum/user/6842-3by400 "View 3by400's Profile")  *[FedEx shipping - Multiple package issue](/forum/28-shipping-methods/882451-fedex-shipping-multiple-package-issue#230636 "-- HikaShop version -- : 2.6.1 -- Joomla version -- : 3.4.4 -- PHP version -- : 5.5.32  I'm working on some custom coding of the HikaShop FedEx shipping plugin. I'm working on shipping multiple packages in one order, but getting lower than expected shipping costs from FedEx compared to their online rate estimates.  Specifically I've found the code in the addPackageLineItem method in the fedex.php file seems to have an issue. The code in this function is not customized or modified. But it is not handling multiple packages. Please note I'm not familiar with nor do I have a copy of the FedEx shipping rate API documentation. However, that's my next step.  First, it starts by setting $packageLineItem&#91;&#93; = array(); Then a foreach loop breaks the $pkg&#95;values passed parameter into individual $pkg items and sets up the contents of the array that will be added for each line item. Then it sets $packageLineItem = array(...); This has the effect of redefining that variable rather than adding to it such that $packageLineItem is always the last item in the foreach loop rather than adding each new formatted array to $packageLineItem.  So the addPackage method never returns more than one package line item and always returns only the last item when multiple packages are submitted.  It seems the solution is to add each new formatted array to the $packageLineItem. I've done this as a test, but I'm not getting any response from FedEx. Since I don't know the format FedEx is expecting for multiple packages in one rate request my testing may not be building the correct array of arrays.  Anyone else noticed this and have a solution?")* was created by *[3by400](/forum/user/6842-3by400 "View 3by400's Profile")*

-- HikaShop version -- : 2.6.1
-- Joomla version -- : 3.4.4
-- PHP version -- : 5.5.32

I'm working on some custom coding of the HikaShop FedEx shipping plugin. I'm working on shipping multiple packages in one order, but getting lower than expected shipping costs from FedEx compared to their online rate estimates.

Specifically I've found the code in the addPackageLineItem method in the fedex.php file seems to have an issue. The code in this function is not customized or modified. But it is not handling multiple packages. Please note I'm not familiar with nor do I have a copy of the FedEx shipping rate API documentation. However, that's my next step.

First, it starts by setting $packageLineItem[] = array();
Then a foreach loop breaks the $pkg_values passed parameter into individual $pkg items and sets up the contents of the array that will be added for each line item.
Then it sets $packageLineItem = array(...); This has the effect of redefining that variable rather than adding to it such that $packageLineItem is always the last item in the foreach loop rather than adding each new formatted array to $packageLineItem.

So the addPackage method never returns more than one package line item and always returns only the last item when multiple packages are submitted.

It seems the solution is to add each new formatted array to the $packageLineItem. I've done this as a test, but I'm not getting any response from FedEx. Since I don't know the format FedEx is expecting for multiple packages in one rate request my testing may not be building the correct array of arrays.

Anyone else noticed this and have a solution?

---

3by400, Inc.
[ 3by400.com](https://3by400.com)
Websites that Work, Marketing that Matters

Last edit: 10 years 8 months ago by [3by400](/forum/user/6842-3by400 "View 3by400's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI4LXNoaXBwaW5nLW1ldGhvZHMvODgyNDUxLWZlZGV4LXNoaXBwaW5nLW11bHRpcGxlLXBhY2thZ2UtaXNzdWU/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")**
- [![Mohamed Thelji's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar6861.png)](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")
- [ Offline](/forum/user/6861-mohamed-thelji)

Less More

- Posts: 12953
- Thank you received: 1778
-
-
-

10 years 8 months ago -  10 years 8 months ago [\#230657](#230657) by [Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")  Replied by *[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")* on topic *[FedEx shipping - Multiple package issue](/forum/28-shipping-methods/882451-fedex-shipping-multiple-package-issue#230657 "-- HikaShop version -- : 2.6.1 -- Joomla version -- : 3.4.4 -- PHP version -- : 5.5.32  I'm working on some custom coding of the HikaShop FedEx shipping plugin. I'm working on shipping multiple packages in one order, but getting lower than expected shipping costs from FedEx compared to their online rate estimates.  Specifically I've found the code in the addPackageLineItem method in the fedex.php file seems to have an issue. The code in this function is not customized or modified. But it is not handling multiple packages. Please note I'm not familiar with nor do I have a copy of the FedEx shipping rate API documentation. However, that's my next step.  First, it starts by setting $packageLineItem&#91;&#93; = array(); Then a foreach loop breaks the $pkg&#95;values passed parameter into individual $pkg items and sets up the contents of the array that will be added for each line item. Then it sets $packageLineItem = array(...); This has the effect of redefining that variable rather than adding to it such that $packageLineItem is always the last item in the foreach loop rather than adding each new formatted array to $packageLineItem.  So the addPackage method never returns more than one package line item and always returns only the last item when multiple packages are submitted.  It seems the solution is to add each new formatted array to the $packageLineItem. I've done this as a test, but I'm not getting any response from FedEx. Since I don't know the format FedEx is expecting for multiple packages in one rate request my testing may not be building the correct array of arrays.  Anyone else noticed this and have a solution?")*

Hello,

You're right, the solution will be to change these lines : Code:

$ct = count($pkg_values); $x = 1; foreach($pkg_values as $pkg) { if($pkg['PackageWeight']['UnitOfMeasurement']['Code'] == "LBS"){ $uom = "LB"; } else { $uom = $pkg["PackageWeight"]["UnitOfMeasurement"]['Code']; } if(is_array($pkg['Dimensions'])){ $dimensions = array("Dimensions"=&gt;array( 'Length' =&gt; $pkg['Dimensions']['Length'], 'Width' =&gt; $pkg['Dimensions']['Width'], 'Height' =&gt; $pkg['Dimensions']['Height'], 'Units' =&gt; $pkg['Dimensions']['UnitOfMeasurement']['Code']) ); } $packageLineItem = array( 'SequenceNumber'=&gt;$x, 'GroupPackageCount'=&gt;$ct, 'Weight' =&gt; array( 'Value' =&gt; $pkg['PackageWeight']['Weight'], 'Units' =&gt; $uom ), $dimensions ); $x++; } );

By: Code:

$x = 0; foreach($pkg_values as $pkg) { if($pkg['PackageWeight']['UnitOfMeasurement']['Code'] == "LBS"){ $uom = "LB"; } else { $uom = $pkg["PackageWeight"]["UnitOfMeasurement"]['Code']; } if(is_array($pkg['Dimensions'])){ $dimensions = array("Dimensions"=&gt;array( 'Length' =&gt; $pkg['Dimensions']['Length'], 'Width' =&gt; $pkg['Dimensions']['Width'], 'Height' =&gt; $pkg['Dimensions']['Height'], 'Units' =&gt; $pkg['Dimensions']['UnitOfMeasurement']['Code']) ); } $packageLineItem[$x] = array( 'SequenceNumber'=&gt;$x+1, 'GroupPackageCount'=&gt;1, 'Weight' =&gt; array( 'Value' =&gt; $pkg['PackageWeight']['Weight'], 'Units' =&gt; $uom ), $dimensions ); $x++; } );

And change these lines : Code:

} if(($this-&gt;freight==true &amp;&amp; $this-&gt;classicMethod==false) &#124;&#124; ($heavyProduct==true &amp;&amp; $this-&gt;freight==true)) $data['XMLpackage'].=$this-&gt;_createPackage($data, $product, $rate, $order ); else $data['XMLpackage'].=$this-&gt;_createPackage($data, $product, $rate, $order, true );

By : Code:

if(($this-&gt;freight==true &amp;&amp; $this-&gt;classicMethod==false) &#124;&#124; ($heavyProduct==true &amp;&amp; $this-&gt;freight==true)) $data['XMLpackage'].=$this-&gt;_createPackage($data, $product, $rate, $order ); else $data['XMLpackage'].=$this-&gt;_createPackage($data, $product, $rate, $order, true ); }

Thanks for your feedback.

Last edit: 10 years 8 months ago by [Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI4LXNoaXBwaW5nLW1ldGhvZHMvODgyNDUxLWZlZGV4LXNoaXBwaW5nLW11bHRpcGxlLXBhY2thZ2UtaXNzdWU/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[3by400](/forum/user/6842-3by400 "View 3by400's Profile")**
- [![3by400's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar6842.jpg)](/forum/user/6842-3by400 "View 3by400's Profile") Topic Author
- [ Offline](/forum/user/6842-3by400)

Less More

- Posts: 211
- Thank you received: 14
-
-
- [](https://3by400.com)
-

10 years 8 months ago [\#230929](#230929) by [3by400](/forum/user/6842-3by400 "View 3by400's Profile")  Replied by *[3by400](/forum/user/6842-3by400 "View 3by400's Profile")* on topic *[FedEx shipping - Multiple package issue](/forum/28-shipping-methods/882451-fedex-shipping-multiple-package-issue#230929 "-- HikaShop version -- : 2.6.1 -- Joomla version -- : 3.4.4 -- PHP version -- : 5.5.32  I'm working on some custom coding of the HikaShop FedEx shipping plugin. I'm working on shipping multiple packages in one order, but getting lower than expected shipping costs from FedEx compared to their online rate estimates.  Specifically I've found the code in the addPackageLineItem method in the fedex.php file seems to have an issue. The code in this function is not customized or modified. But it is not handling multiple packages. Please note I'm not familiar with nor do I have a copy of the FedEx shipping rate API documentation. However, that's my next step.  First, it starts by setting $packageLineItem&#91;&#93; = array(); Then a foreach loop breaks the $pkg&#95;values passed parameter into individual $pkg items and sets up the contents of the array that will be added for each line item. Then it sets $packageLineItem = array(...); This has the effect of redefining that variable rather than adding to it such that $packageLineItem is always the last item in the foreach loop rather than adding each new formatted array to $packageLineItem.  So the addPackage method never returns more than one package line item and always returns only the last item when multiple packages are submitted.  It seems the solution is to add each new formatted array to the $packageLineItem. I've done this as a test, but I'm not getting any response from FedEx. Since I don't know the format FedEx is expecting for multiple packages in one rate request my testing may not be building the correct array of arrays.  Anyone else noticed this and have a solution?")*

Thanks Mohamed. Your solution is almost identical to mine except that you're setting your 'SequenceNumber' =&gt; $x+1 where I set it just to $x. The sequence number starting at 0 instead of 1 seems to work fine with FedEx.

The other issue this doesn't address is the proper use of the 'GroupPackageCount' variable. The FedEx tech support person explained it to me this way. If you have 2 or 3 identical packages (same weight, same dimensions), these would normally be referenced in the same SequenceNumber as GroupPackageCount = 2 or 3 respectively. I haven't seen any other logic in the plugin that would support this. But just saying this is how the GroupPackageCount value is used and with it set to '1' as a constant, the addPackageLineItem method is not able to support proper use of the GroupPackageCount feature.

---

3by400, Inc.
[ 3by400.com](https://3by400.com)
Websites that Work, Marketing that Matters

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI4LXNoaXBwaW5nLW1ldGhvZHMvODgyNDUxLWZlZGV4LXNoaXBwaW5nLW11bHRpcGxlLXBhY2thZ2UtaXNzdWU/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")**
- [![Mohamed Thelji's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar6861.png)](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")
- [ Offline](/forum/user/6861-mohamed-thelji)

Less More

- Posts: 12953
- Thank you received: 1778
-
-
-

10 years 8 months ago [\#231023](#231023) by [Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")  Replied by *[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")* on topic *[FedEx shipping - Multiple package issue](/forum/28-shipping-methods/882451-fedex-shipping-multiple-package-issue#231023 "-- HikaShop version -- : 2.6.1 -- Joomla version -- : 3.4.4 -- PHP version -- : 5.5.32  I'm working on some custom coding of the HikaShop FedEx shipping plugin. I'm working on shipping multiple packages in one order, but getting lower than expected shipping costs from FedEx compared to their online rate estimates.  Specifically I've found the code in the addPackageLineItem method in the fedex.php file seems to have an issue. The code in this function is not customized or modified. But it is not handling multiple packages. Please note I'm not familiar with nor do I have a copy of the FedEx shipping rate API documentation. However, that's my next step.  First, it starts by setting $packageLineItem&#91;&#93; = array(); Then a foreach loop breaks the $pkg&#95;values passed parameter into individual $pkg items and sets up the contents of the array that will be added for each line item. Then it sets $packageLineItem = array(...); This has the effect of redefining that variable rather than adding to it such that $packageLineItem is always the last item in the foreach loop rather than adding each new formatted array to $packageLineItem.  So the addPackage method never returns more than one package line item and always returns only the last item when multiple packages are submitted.  It seems the solution is to add each new formatted array to the $packageLineItem. I've done this as a test, but I'm not getting any response from FedEx. Since I don't know the format FedEx is expecting for multiple packages in one rate request my testing may not be building the correct array of arrays.  Anyone else noticed this and have a solution?")*

Hello,

> The sequence number starting at 0 instead of 1 seems to work fine with FedEx.

When I tested it on my end I had an error message regarding the "Sequence number", so that's why I have set it to x+1

> The other issue this doesn't address is the proper use of the 'GroupPackageCount' variable. The FedEx tech support person explained it to me this way. If you have 2 or 3 identical packages (same weight, same dimensions), these would normally be referenced in the same SequenceNumber as GroupPackageCount = 2 or 3 respectively

I didn't totally understood it, do you mean that if 2 products have the same dimensions and weight then they'll have to be grouped on the same "PackageLineItem" but with a GroupPackageCount set to the quantity of products ?
If that's the case, note that the FedEx shipping plugin wasn't originally developed by us so we weren't aware of it we just maintained it so that our customers can still use it.
There is actually no option to do that so if you want your FedEx shipping method you'll have to directly do it by customizing the code of the FedEx shipping plugin. My advice will be to :
- Directly check if some product have the same dimensions/weight on the "_getRates" function, just before we add package information (dimensions/weight) in the "$Data" variable.
- Adapt the code of the "addPackageLineItem" function.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI4LXNoaXBwaW5nLW1ldGhvZHMvODgyNDUxLWZlZGV4LXNoaXBwaW5nLW11bHRpcGxlLXBhY2thZ2UtaXNzdWU/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.121 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
