Exemple #1
0
 public function getProductPrices($sourceOrder)
 {
     $output = array();
     $resOrders = Mage::getModel('payperrentals/reservationorders')->getCollection()->addOrderIdFilter($sourceOrder->getId());
     $hasReservations = $resOrders->getSize() > 0 ? true : false;
     $orderItems = $sourceOrder->getAllItems();
     foreach ($orderItems as $item) {
         $originalStartDate = $item->getBuyRequest()->getStartDate();
         $originalEndDate = $item->getBuyRequest()->getEndDate();
         $stockAvail = ITwebexperts_Payperrentals_Helper_Inventory::getQuantity($item->getProduct()->getId(), $originalStartDate, $originalEndDate, ITwebexperts_Payperrentals_Helper_Data::objectToArray($item->getBuyRequest()));
         if ($stockAvail == '10000000') {
             $output[$item->getId()] = array('avail' => '', 'remaining' => '');
         } else {
             $output[$item->getId()] = array('avail' => $stockAvail + ($hasReservations ? $item->getBuyRequest()->getQty() : 0), 'remaining' => $stockAvail);
         }
     }
     return $output;
 }