示例#1
0
 /**
  * Retrieve the different item types from the ratepay item table
  * if post params given the quantities and the prices get adjustet
  *
  * @param int $orderId
  * @param array $post
  * @return array
  */
 public static function getItemsByTable($orderId, array $post = array(), $subType = false)
 {
     $items = self::getRpItems($orderId);
     $itemData = array();
     foreach ($items as $item) {
         $id = $item['id'];
         if (array_key_exists($id, $post) && array_key_exists('toShip', $post[$id])) {
             $itemData[] = rpData::getDeliverItemData($item, $post[$id]['toShip']);
         } elseif (array_key_exists($id, $post) && array_key_exists('toCancel', $post[$id])) {
             $itemData[] = rpData::getCancelItemData($item, $post[$id]['toCancel']);
         } elseif (array_key_exists($id, $post) && array_key_exists('toRefund', $post[$id])) {
             $itemData[] = rpData::getRefundItemData($item, $post[$id]['toRefund']);
         } else {
             $itemData[] = rpData::getRemainingItemData($item, $subType);
         }
     }
     if (array_key_exists('voucherAmount', $post)) {
         $itemData[] = rpData::getCreditItem($post);
     }
     return $itemData;
 }