public function renderForm() { if (Context::getContext()->shop->getContext() != Shop::CONTEXT_SHOP && Shop::isFeatureActive()) { $this->errors[] = $this->l('You have to select a shop before creating new orders.'); } $id_cart = (int) Tools::getValue('id_cart'); $cart = new Cart((int) $id_cart); if ($id_cart && !Validate::isLoadedObject($cart)) { $this->errors[] = $this->l('This cart does not exists'); } if ($id_cart && Validate::isLoadedObject($cart) && !$cart->id_customer) { $this->errors[] = $this->l('The cart must have a customer'); } if (count($this->errors)) { return false; } parent::renderForm(); unset($this->toolbar_btn['save']); $this->addJqueryPlugin(array('autocomplete', 'fancybox', 'typewatch')); $defaults_order_state = array('cheque' => (int) Configuration::get('PS_OS_CHEQUE'), 'bankwire' => (int) Configuration::get('PS_OS_BANKWIRE'), 'cashondelivery' => Configuration::get('PS_OS_COD_VALIDATION') ? (int) Configuration::get('PS_OS_COD_VALIDATION') : (int) Configuration::get('PS_OS_PREPARATION'), 'other' => (int) Configuration::get('PS_OS_PAYMENT')); $payment_modules = array(); foreach (PaymentModule::getInstalledPaymentModules() as $p_module) { $payment_modules[] = Module::getInstanceById((int) $p_module['id_module']); } $this->context->smarty->assign(array('recyclable_pack' => (int) Configuration::get('PS_RECYCLABLE_PACK'), 'gift_wrapping' => (int) Configuration::get('PS_GIFT_WRAPPING'), 'cart' => $cart, 'currencies' => Currency::getCurrenciesByIdShop(Context::getContext()->shop->id), 'langs' => Language::getLanguages(true, Context::getContext()->shop->id), 'payment_modules' => $payment_modules, 'order_states' => OrderState::getOrderStates((int) Context::getContext()->language->id), 'defaults_order_state' => $defaults_order_state, 'show_toolbar' => $this->show_toolbar, 'toolbar_btn' => $this->toolbar_btn, 'toolbar_scroll' => $this->toolbar_scroll, 'PS_CATALOG_MODE' => Configuration::get('PS_CATALOG_MODE'), 'title' => array($this->l('Orders'), $this->l('Create order')))); $this->content .= $this->createTemplate('form.tpl')->fetch(); }