Search code examples
magentomagento-1.7

How do I get the package length, width, and height in Magento for a shipping estimate?


I am looking for a snippet that will give me the length, width, and height of the packaging to ship the items currently in the cart.

I am creating a shipping rates module and this is the last piece of the puzzle.

Any information is greatly appreciated!

Jeff


Solution

  • Take a look @ Create Shipping Method Module

    In collectRates(Mage_Shipping_Model_Rate_Request $request) you can get all items using

     $request->getAllItems()
    

    See /app/code/core/Mage/Shipping/Model/Rate/Request.php

    So you could Loop through each item to get their dimension

    foreach($request->getAllItems() as $item){
        //do you logic per item
         $item->getLength();
         $item->getWidth();
         $item->getHeight();
    }