Ejemplo n.º 1
0
 /**
  * @param Item $order
  * @return JBCartOrder
  */
 protected function _convertOrder(Item $order)
 {
     $newOrder = new JBCartOrder();
     $cartElement = current($order->getElementsByType('jbbasketitems'));
     if (!$cartElement) {
         return null;
     }
     $orderItems = $cartElement->getOrderItems();
     $data = (array) $cartElement->data();
     $newOrder->id = -1;
     $newOrder->modified = $order->modified;
     $newOrder->created = $order->created;
     $newOrder->created_by = $order->created_by;
     $newOrder->params = new ParameterData();
     $newOrder->params->set('config', array('default_currency' => $this->_migrate->getCurrency(), 'migration_currency' => $this->_migrate->getCurrency()));
     $paymentElement = $this->_createPayment($data);
     $paymentElement->setOrder($newOrder);
     $newOrder->setPaymentElement($paymentElement);
     $fieldsElement = $this->_createOrderElement($order);
     $fieldsElement->setOrder($newOrder);
     $newOrder->addOrderElement($fieldsElement);
     $newOrder->setStatusList($this->_statusList);
     $newList = array();
     $totalSum = $newOrder->val(0);
     foreach ($orderItems as $orderItem) {
         $key = md5(serialize($orderItem));
         $orderItem = $this->app->data->create($orderItem);
         $totalPrice = $newOrder->val($orderItem->get('price') . ' ' . $orderItem->get('currency'));
         $newList[$key] = array('key' => $key, 'item_id' => $orderItem->get('itemId'), 'item_name' => $orderItem->get('name'), 'element_id' => '', 'total' => $totalPrice->data(true), 'quantity' => $orderItem->get('quantity'), 'template' => array(), 'values' => (array) $orderItem->get('priceParams'), 'elements' => array('_value' => $totalPrice->data(true), '_sku' => $orderItem->get('sku'), '_description' => $orderItem->get('priceDesc')), 'params' => array('quantity' => array('min' => 1, 'max' => 1000, 'step' => 1, 'default' => 1, 'decimals' => 0)), 'modifiers' => array(), 'variations' => array(), 'variant' => 0);
         $totalSum->add($totalPrice);
     }
     $newOrder->setItemsData(json_encode($newList));
     $newOrder->total = $totalSum->val();
     if (isset($data['order_info'])) {
         if (isset($data['order_info']['status'])) {
             $newOrder->setStatus($data['order_info']['status'], JBCart::STATUS_ORDER);
             $newOrder->setStatus($data['order_info']['status'], JBCart::STATUS_PAYMENT);
         }
         if (isset($data['order_info']['description'])) {
             $newOrder->comment = $data['order_info']['description'];
         }
     }
     return $newOrder;
 }
Ejemplo n.º 2
0
 /**
  * Create emails
  */
 public function notificaction()
 {
     $config = $this->_migrate->getNotification();
     if ($config->get('notificaction-create')) {
         $emailCreate = $this->_element->create('sendemail', JBCart::ELEMENT_TYPE_NOTIFICATION, array("name" => JText::_('JBZOO_MIGRATE_NOTIFICATION_CREATE_NAME'), "layout_email" => "default", "subject" => JText::_('JBZOO_MIGRATE_NOTIFICATION_CREATE_NAME'), "recipients" => array("custom" => $config->get('admin-email')), "ishtml" => "1", "issleep" => "0"));
         $emailCreate->saveConfig('order_saved');
     }
     if ($config->get('notificaction-payment')) {
         $emailCreated = $this->_element->create('sendemail', JBCart::ELEMENT_TYPE_NOTIFICATION, array("name" => JText::_('JBZOO_MIGRATE_NOTIFICATION_PAYMENT_NAME'), "layout_email" => "default", "subject" => JText::_('JBZOO_MIGRATE_NOTIFICATION_PAYMENT_NAME'), "recipients" => array("custom" => $config->get('admin-email')), "ishtml" => "1", "issleep" => "0"));
         $emailCreated->saveConfig('order_paymentsuccess');
     }
     if ($config->get('notificaction-payment') || $config->get('notificaction-create')) {
         //$elem->saveConfig('default.title');
         $this->_confModel->setGroup('cart.email_tmpl.default', array('title' => array($this->_element->create('textarea', JBCart::ELEMENT_TYPE_EMAIL, array('showlabel' => '0', 'text' => '{order_name} - {site_name}'))->config), 'body' => array($this->_element->create('items', JBCart::ELEMENT_TYPE_EMAIL, array('name' => JText::_('JBZOO_MIGRATE_EMAIL_ITEMS_NAME'), 'currency' => $this->_migrate->getCurrency(), 'showlabel' => '1', 'subtotal' => '0', 'payment' => '0', 'shipping' => '0', 'modifiers' => '0', 'total' => '1', 'tmpl_item_link' => '1', 'tmpl_image_show' => '0', 'tmpl_image_link' => '0', 'tmpl_image_width' => '75', 'tmpl_image_height' => '75', 'tmpl_sku_show' => '1', 'tmpl_price4one' => '1', 'tmpl_quntity' => '1', 'tmpl_subtotal' => '1'))->config, $this->_element->create('fields', JBCart::ELEMENT_TYPE_EMAIL, array('name' => '', 'showlabel' => '1', 'fields' => array()))->config)));
     }
 }