0

I have some notice in a line 27 of the method bellow, and can't find the issue !

public function blockOrder()
{
    $items = Mage::getSingleton('checkout/cart')->getQuote()->getItemsCollection();
    $tab = array();
    foreach ($items as $itemCart) {
    /*line 27*/ $tab[$itemCart->getUdropshipVendor()] += $itemCart->getPrice() * $itemCart->getQty();
    }
    foreach ($tab as $vendorId => $amountInCart) {
        $vendorMinAmount = Mage::getModel('udropship/vendor')->load($vendorId)->getMinimumOrderAmount();
        if ($amountInCart < $vendorMinAmount) {
            return true;
        }
        return false;
    }
}
1
  • Problems is caused by += if values for this key was not set before.
    – sv3n
    Commented Jun 21, 2017 at 13:24

1 Answer 1

3

turn this

foreach ($items as $itemCart) {
    $tab[$itemCart->getUdropshipVendor()] += $itemCart->getPrice() * $itemCart->getQty();
}

into this

foreach ($items as $itemCart) {
    $vendor = $itemCart->getUdropshipVendor();
    if (!isset($tab[$vendor])) {
        $tab[$vendor] = 0;
    }
    $tab[$vendor] += $itemCart->getPrice() * $itemCart->getQty();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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