コード例 #1
0
 static function getAddonPrice($addon, $adult, $child, $tax = 0, $addon_price = NULL)
 {
     if (!is_array($addon)) {
         return 0;
     }
     if (count($addon) < 1) {
         return 0;
     }
     $db = JFactory::getDbo();
     $total = 0;
     if (empty($addon_price)) {
         AImporter::model('addons');
         $addon_model = new BookProModelAddons();
         $addon_price = $addon_model->getDataByIds($addon);
     }
     foreach ($addon as $id) {
         foreach ($addon_price as $price) {
             if ($price->id == $id) {
                 $total += $price->price * $adult + $price->child_price * $child;
             }
         }
     }
     $total += $total * $tax / 100;
     return $total;
 }
コード例 #2
0
 public function confirm()
 {
     $db = JFactory::getDbo();
     $app = JFactory::getApplication();
     $input = $app->input;
     AImporter::classes('order/transport');
     AImporter::model('addons');
     $addon_ids = $input->get('depart_addon', '', 'array');
     $addon_ids_return = $input->get('return_addon', '', 'array');
     $addonModel = new BookProModelAddons();
     $cart = $this->getCart();
     $this->checkCart($cart);
     $order = new BookproTransportOrder();
     $order->customer = $input->getArray($_POST);
     $order->addons['depart'] = $addonModel->getDataByIds($addon_ids);
     $order->addons['return'] = $addonModel->getDataByIds($addon_ids_return);
     $order->passengers = $input->get('person', array(), 'array');
     $order->cart = $cart;
     $order->trips = $cart->trips;
     if ($order->save()) {
         //process payment
         require_once JPATH_ROOT . '/components/com_bookpro/controllers/payment.php';
         $payment = new BookProControllerPayment();
         $payment->input->set('order_id', $order->table->id);
         $payment->process();
         $order = null;
         return;
     } else {
         return false;
     }
 }