Question

I see it's used in Mage_Sales_Model_Quote_Address_Total_Shipping::collect() and it's roughly equivalent to the address' total weight. Also, various Carriers check against this value:

if ($request->getFreeMethodWeight()!=$request->getPackageWeight()) {
    $r->setFreeMethodWeight($request->getFreeMethodWeight());
}

Do you guys know what is its purpose?

Was it helpful?

Solution

FreeMethodWeight is a property set on the request (typically set to 0) as an identifier that the order is eligible for free shipping. The shipping model will typically have defined which method is eligible for free shipping, and make the determination of the use of this method via the free method weight.

In your example above they're being set on the $r object, which is (assumably) of type Mage_Shipping_Model_Rate_Request.

The getter and setter are magic - they set a property called free_method_weight on the request object.

OTHER TIPS

The freeMethodWeight is only used in connection with shopping cart price rules: if you select Free Shipping: "for matching items only", then the number (meaning the qty of each item) you put in the discount qty field will be free. See in Mage_SalesRule_Model_Validator::processFreeShipping. The free method weight will be calculated in the Total Model Mage_Sales_Model_Quote_Address_Total_Shipping to the weight of the items that are NOT free. Example:

  • you select Free Shipping: "for matching items only" in a shopping cart price rule and set "2" in the discount_qty field.
  • Then the quote items will get free_shipping = 2
  • And freeMethodWeight will become itemWeight * (itemQty - 2) in Mage_Sales_Model_Quote_Address_Total_Shipping (= weight of items that are not for free by definition of the discount rule)

If there is no such discount rule configured, the freeMethodWeight will always be equal to the package weight.

So in most cases the freeMethodWeight is equal to the package weight but is, however, taken into account for shipping price calculation in some shipping methods.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top