verifying the component items of a Bundle item is available at any location

$qty = 0;

$sortedSource = [];

foreach ($items as $item) {

$newsku = $item->getSku();

$sourceItemList = $cduObj->getSourceItemBySku($newsku);

$sortedSource[$newsku] = 0;

foreach ($sourceItemList as $source) {

if ($source->getStatus() == 1) {

$sortedSource[$newsku] = $sortedSource[$newsku] + $source->getQuantity();

}

}

if ($sortedSource[$newsku] != 0) {

$sortedSource[$newsku] = $sortedSource[$newsku] / $item->getQty();

}

}

$filteredItems = array_filter($sortedSource, function($value) {

return $value >= 1;

});

if (count($sortedSource) == count($filteredItems)) {

$qty = 1;

}

Leave a comment

Your email address will not be published. Required fields are marked *