コード例 #1
0
ファイル: shippingfields.php プロジェクト: alexmixaylov/real
 /**
  * @param $args
  * @return string
  */
 public function renderAdminPosition($args = array())
 {
     // init vars
     $elements = array();
     $output = array();
     $layout = $this->_layout;
     $style = isset($args['style']) ? $args['style'] : 'adminedit';
     $this->_order = isset($args['order']) ? $args['order'] : $this->_order;
     $shipping = $this->_order->getShipping();
     // render elements
     $shippingFields = $this->_order->getShippingFields();
     foreach ($shippingFields as $identifier => $data) {
         if ($element = $this->_order->getShippingFieldElement($identifier)) {
             if ($shipping && !$shipping->hasShippingField($identifier)) {
                 continue;
             }
             $element->bindData($data);
             $params = array_merge(array('_layout' => $this->_layout, '_index' => $identifier), $args);
             $elements[] = compact('element', 'params');
         }
     }
     foreach ($elements as $i => $data) {
         $output[$i] = parent::render('element.' . $style, array('element' => $data['element'], 'params' => array_merge(array('first' => $i == 0, 'last' => $i == count($elements) - 1), $data['params'])));
     }
     // restore layout
     $this->_layout = $layout;
     return implode(PHP_EOL, $output);
 }
コード例 #2
0
ファイル: jbmodel.order.php プロジェクト: alexmixaylov/real
 /**
  * @param JBCartOrder $order
  * @param bool|false  $silentMode
  * @return int|mixed
  */
 public function save(JBCartOrder $order, $silentMode = false)
 {
     $this->app->jbtables->checkOrder();
     $currencies = $order->getCurrencyList();
     $params = $order->getParams();
     $params->set(JBCart::CONFIG_CURRENCIES, $currencies);
     $cartConfig = $order->params->find('config');
     if (!$cartConfig) {
         $cartConfig = JBModelConfig::model()->getGroup('cart.config');
     }
     $params->set('config', (array) $cartConfig);
     $total = $order->getTotalSum()->data();
     $data = array('id' => $order->id, 'status' => $order->getStatus()->getCode(), 'status_payment' => $order->getPaymentStatus(), 'status_shipping' => $order->getShippingStatus(), 'created' => $order->created, 'created_by' => $order->created_by, 'total' => $total[0], 'items' => $order->getItems(false), 'fields' => $order->getFields(), 'shippingfields' => $order->getShippingFields(), 'modifiers' => $order->getModifiersData(), 'params' => $params, 'comment' => $order->comment);
     if ($shipping = $order->getShipping()) {
         $data['shipping'] = $shipping->data();
     }
     if ($payment = $order->getPayment()) {
         $data['payment'] = $payment->data();
     }
     if (!$silentMode) {
         $this->app->jbevent->fire($order, 'basket:beforeSave');
     }
     if ($data['id'] <= 0) {
         unset($data['id']);
         $order->id = $this->_insert($data, ZOO_TABLE_JBZOO_ORDER);
         //TODO hardcoded
         $order->setItemsData((string) $data['items']);
         if (!$silentMode) {
             $this->app->jbevent->fire($order, 'basket:saved');
         }
     } else {
         $data['modified'] = $this->app->jbdate->toMySql();
         $this->_update($data, ZOO_TABLE_JBZOO_ORDER);
         if (!$silentMode) {
             $this->app->jbevent->fire($order, 'basket:updated');
         }
     }
     if ($order->id && !$silentMode) {
         $this->app->jbevent->fire($order, 'basket:afterSave');
     }
     return $order->id;
 }