1

we use a product-configurator for some products. There you can set the height and weight of pvc-banners. Now is the problem to calculate the shipping cost by the length. The configurator set the "short site" from the pvc-banners at row-weight @ sales_flat_quote_item. thats fine!

now its the problem for me to set the shippingcost by the "heaviest" or better by the longest product.

if i have one product in the cart the shipping cost corect. if i edit the quantity - it`s fine - i modified some files for this.

If i have more than 1 product in the cart the weight1 is add to weight2.

for this i have add a module - but since last update it dosn`t work.

more details:

../app/code/local/Mage/Bannership/etc/config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Mage_Bannership>
            <version>0.2.0</version>
        </Mage_Bannership>
    </modules>
    <global>       
        <models>
            <bannership>
                <class>Mage_Bannership_Model</class>               
            </bannership> 
            <core> 
                <rewrite>
                    <shipping>
                        Mage_Bannership_Model_Shipping
                    </shipping>
                </rewrite>
            </core>          
        </models>       
    </global>   
</config>

../app/code/local/Mage/Bannership/Model/Shipping.php:

class Mage_Bannership_Model_Shipping extends Mage_Shipping_Model_Shipping {

    public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
        $maxWeight = 0;
        foreach($request->getAllItems() as $item) {
            $maxWeight = max($maxWeight, $item->getRowWeight());
        }
        $request->setPackageWeight($maxWeight);

        return parent::collectRates($request);
    }
}

How can I fix that?

0

Update as per below:

<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
    <Mage_Bannership>
        <version>0.2.0</version>
    </Mage_Bannership>
</modules>
<global>       
    <models>
        <bannership>
            <class>Mage_Bannership_Model</class>               
        </bannership> 
        <shipping> 
            <rewrite>
                <shipping>
                    Mage_Bannership_Model_Shipping
                </shipping>
            </rewrite>
        </shipping>          
    </models>       
</global>   

  • The row-weight from the quote-items are okay in db. but the total weight of the cart iss add by the row-weight from each item. – user9603 Aug 20 '15 at 10:44
  • i want to set the total weight(cart) by the highest row-weight from all item in cart. Is "setPackageWeight" the right "function"? – user9603 Aug 20 '15 at 10:46
  • Yes, this is right function. – Yogesh Trivedi Aug 20 '15 at 11:18
0

I have found a solution to fix it.

... we use the Matrixrate - Free Version from Webshopapps - this extension override the other module. So i add some lines code at: /app/code/community/Webshopapps/Matrixrate/Model/Carrier/Matrixrate.php:

~ line 111

// heaviest weight set shipping price - MOD // weight is override by lenght ...

$maxWeight = 0;
if ($request->getAllItems()) {
    foreach($request->getAllItems() as $item) {
        $maxWeight = max($maxWeight, $item->getRowWeight());
    }
$request->setPackageWeight($maxWeight);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.