public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); if (!$this->customer->isLogged()) { $this->session->data['redirect'] = $this->html->getSecureURL('account/newsletter'); $this->redirect($this->html->getSecureURL('account/login')); } $this->document->setTitle($this->language->get('heading_title')); if ($this->request->is_POST()) { $this->loadModel('account/customer'); $this->model_account_customer->editNewsletter($this->request->post['newsletter']); $this->session->data['success'] = $this->language->get('text_success'); $this->redirect($this->html->getURL('account/account')); } $this->document->resetBreadcrumbs(); $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE)); $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/account'), 'text' => $this->language->get('text_account'), 'separator' => $this->language->get('text_separator'))); $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/newsletter'), 'text' => $this->language->get('text_newsletter'), 'separator' => $this->language->get('text_separator'))); $form = new AForm(); $form->setForm(array('form_name' => 'newsFrm')); $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'newsFrm', 'action' => $this->html->getSecureURL('account/newsletter'))); $this->data['form']['newsletter'] = $form->getFieldHtml(array('type' => 'radio', 'name' => 'newsletter', 'value' => $this->customer->getNewsletter(), 'options' => array('1' => $this->language->get('text_yes'), '0' => $this->language->get('text_no')))); $this->data['form']['continue'] = $form->getFieldHtml(array('type' => 'submit', 'icon' => 'fa fa-check', 'name' => $this->language->get('button_continue'))); $this->data['back'] = $this->html->getURL('account/account'); $back = HtmlElementFactory::create(array('type' => 'button', 'name' => 'back', 'text' => $this->language->get('button_back'), 'icon' => 'fa fa-arrow-left', 'style' => 'button')); $this->data['form']['back'] = $back; $this->view->batchAssign($this->data); $this->processTemplate('pages/account/newsletter.tpl'); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function main() { $this->loadLanguage('default_pp_pro_uk/default_pp_pro_uk'); $this->load->model('checkout/order'); $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); $data['cc_owner'] = HtmlElementFactory::create(array('type' => 'input', 'name' => 'cc_owner', 'value' => $order_info['payment_firstname'] . ' ' . $order_info['payment_lastname'], 'style' => 'input-medium')); $data['cc_owner'] = $data['cc_owner']->getHtml(); $cards = array('Visa' => 'Visa', 'MasterCard' => 'MasterCard', 'Maestro' => 'Maestro'); $data['cc_type'] = HtmlElementFactory::create(array('type' => 'selectbox', 'name' => 'cc_type', 'value' => 0, 'options' => $cards, 'style' => 'short input-small')); $data['cc_number'] = HtmlElementFactory::create(array('type' => 'input', 'name' => 'cc_number', 'value' => '', 'style' => 'input-medium')); $months = array(); for ($i = 1; $i <= 12; $i++) { $months[sprintf('%02d', $i)] = strftime('%B', mktime(0, 0, 0, $i, 1, 2000)); } $data['cc_expire_date_month'] = HtmlElementFactory::create(array('type' => 'selectbox', 'name' => 'cc_expire_date_month', 'value' => sprintf('%02d', date('m')), 'options' => $months, 'style' => 'short input-small')); $today = getdate(); $years = array(); for ($i = $today['year']; $i < $today['year'] + 11; $i++) { $years[strftime('%Y', mktime(0, 0, 0, 1, 1, $i))] = strftime('%Y', mktime(0, 0, 0, 1, 1, $i)); } $data['cc_expire_date_year'] = HtmlElementFactory::create(array('type' => 'selectbox', 'name' => 'cc_expire_date_year', 'value' => sprintf('%02d', date('Y') + 1), 'options' => $years, 'style' => 'short input-small')); $data['cc_start_date_month'] = HtmlElementFactory::create(array('type' => 'selectbox', 'name' => 'cc_start_date_month', 'value' => sprintf('%02d', date('m')), 'options' => $months, 'style' => 'short input-small')); $years = array(); for ($i = $today['year'] - 10; $i < $today['year'] + 2; $i++) { $years[strftime('%Y', mktime(0, 0, 0, 1, 1, $i))] = strftime('%Y', mktime(0, 0, 0, 1, 1, $i)); } $data['cc_start_date_year'] = HtmlElementFactory::create(array('type' => 'selectbox', 'name' => 'cc_start_date_year', 'value' => sprintf('%02d', date('Y')), 'options' => $years, 'style' => 'short input-small')); $data['cc_cvv2'] = HtmlElementFactory::create(array('type' => 'input', 'name' => 'cc_cvv2', 'value' => '', 'style' => 'short', 'attr' => ' size="3" ')); $data['cc_issue'] = HtmlElementFactory::create(array('type' => 'input', 'name' => 'cc_issue', 'value' => '', 'style' => 'short', 'attr' => ' size="1" ')); $back = $this->request->get['rt'] != 'checkout/guest_step_3' ? $this->html->getSecureURL('checkout/payment') : $this->html->getSecureURL('checkout/guest_step_2'); $data['back'] = HtmlElementFactory::create(array('type' => 'button', 'name' => 'back', 'text' => $this->language->get('button_back'), 'style' => 'button', 'href' => $back)); $data['submit'] = HtmlElementFactory::create(array('type' => 'button', 'name' => 'paypal_button', 'text' => $this->language->get('button_confirm'), 'style' => 'button btn-orange')); $this->view->batchAssign($data); $this->processTemplate('responses/default_pp_pro_uk.tpl'); }
public function review() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('product/product'); $this->loadModel('catalog/review'); $this->view->assign('text_no_reviews', $this->language->get('text_no_reviews')); if (isset($this->request->get['page'])) { $page = $this->request->get['page']; } else { $page = 1; } $reviews = array(); $results = $this->model_catalog_review->getReviewsByProductId($this->request->get['product_id'], ($page - 1) * 5, 5); foreach ($results as $result) { $reviews[] = array('author' => $result['author'], 'rating' => $result['rating'], 'text' => strip_tags($result['text']), 'stars' => sprintf($this->language->get('text_stars'), $result['rating']), 'date_added' => dateISO2Display($result['date_added'], $this->language->get('date_format_short'))); } $this->data['reviews'] = $reviews; $review_total = $this->model_catalog_review->getTotalReviewsByProductId($this->request->get['product_id']); $this->data['pagination_bootstrap'] = HtmlElementFactory::create(array('type' => 'Pagination', 'name' => 'pagination', 'text' => $this->language->get('text_pagination'), 'text_limit' => $this->language->get('text_per_page'), 'total' => $review_total, 'page' => $page, 'limit' => 5, 'url' => $this->html->getURL('product/review/review', '&product_id=' . $this->request->get['product_id'] . '&page={page}'), 'style' => 'pagination')); $this->view->batchAssign($this->data); $this->processTemplate('responses/product/review.tpl'); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); if (has_value($this->request->get['customer_id']) && (int) $this->request->get['customer_id'] > 0 && has_value($this->request->get['email'])) { $this->loadModel('account/customer'); $customer = $this->model_account_customer->getCustomer((int) $this->request->get['customer_id']); //check is customer_id exists and compare his email with given if ($customer && $customer['email'] == $this->request->get['email']) { $this->model_account_customer->editNewsletter(0, (int) $this->request->get['customer_id']); } else { //othewise - redirect to index page $this->html->redirect($this->html->getSecureURL('index/home')); } } else { $this->html->redirect($this->html->getSecureURL('index/home')); } $this->document->setTitle($this->language->get('heading_title')); $this->document->resetBreadcrumbs(); $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE)); $this->data['heading_title'] = $this->language->get('heading_title'); $this->data['text_message'] = $this->language->get('text_message'); $this->data['button_continue'] = $this->language->get('button_continue'); $this->data['continue'] = $this->html->getURL('index/home'); $continue = HtmlElementFactory::create(array('type' => 'button', 'name' => 'continue_button', 'text' => $this->language->get('button_continue'), 'style' => 'button')); $this->data['continue_button'] = $continue; $this->view->batchAssign($this->data); $this->processTemplate('common/unsubscribe.tpl'); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); unset($this->session->data['success']); }
private function _generar_inputs_form() { $campos = $this->_oConfigEntidad->campos; //echo "<hr/>" . __FILE__ . " - " . __LINE__ . "<pre>"; //echo "<hr/><pre>"; // print_r($this->input->post()); //echo "</pre><hr/>"; //die(); //$config = $this->input->post("campos[id_provincia][config]"); // $config_decode = (array) json_decode($config); // print_r($config_decode); // print_r($campos); // echo "</pre><hr/>"; //die; $html = ""; require_once APPPATH . "/libraries/Crud/HtmlElementFactory.php"; foreach ($campos as $nombre_campo => $data_campo) { if (element($data_campo, "generar_input", 0) > 0) { $tipo_input = $data_campo["tipo_campo"]; $config = $data_campo["config"]; $html .= "<div class='form-group'>" . PHP_EOL; if ($tipo_input !== "hidden") { $html .= "<label>" . element($data_campo, "label", "") . ":</label><br/>" . PHP_EOL; } $elemento_html = HtmlElementFactory::crear_elemento($tipo_input); if (!empty($config)) { $config_decode = (array) json_decode($config); $elemento_html->set_config($config_decode); } $html .= $elemento_html->render($nombre_campo) . PHP_EOL; $html .= "</div>" . PHP_EOL; } } return $html; }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->document->setTitle($this->language->get('heading_title')); $this->document->resetBreadcrumbs(); $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE)); $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/account'), 'text' => $this->language->get('text_account'), 'separator' => $this->language->get('text_separator'))); $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/success'), 'text' => $this->language->get('text_success'), 'separator' => $this->language->get('text_separator'))); $this->view->assign('heading_title', $this->language->get('heading_title')); if ($this->config->get('config_customer_email_activation')) { $this->view->assign('text_message', sprintf($this->language->get('text_activate'), $this->config->get('store_name'), $this->html->getURL('content/contact'))); } elseif ($this->config->get('config_customer_approval')) { $this->view->assign('text_message', sprintf($this->language->get('text_approval'), $this->config->get('store_name'), $this->html->getURL('content/contact'))); } else { $this->view->assign('text_message', sprintf($this->language->get('text_message'), $this->html->getURL('content/contact'))); } $this->view->assign('button_continue', $this->language->get('button_continue')); if ($this->session->data['redirect']) { $this->view->assign('continue', $this->session->data['redirect']); unset($this->session->data['redirect']); } else { if ($this->cart->hasProducts()) { $this->view->assign('continue', $this->html->getURL('checkout/cart')); } else { $this->view->assign('continue', $this->html->getURL('account/account')); } } $continue = HtmlElementFactory::create(array('type' => 'button', 'name' => 'continue_button', 'text' => $this->language->get('button_continue'), 'style' => 'button')); $this->view->assign('continue_button', $continue); $this->processTemplate('common/success.tpl'); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); unset($this->session->data['success']); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); if (isset($this->session->data['order_id'])) { $amount = $this->session->data['used_balance']; // in default currency if ($amount) { $transaction_data = array('order_id' => (int) $this->session->data['order_id'], 'amount' => $amount, 'transaction_type' => 'order', 'created_by' => $this->customer->getId(), 'description' => sprintf($this->language->get('text_applied_balance_to_order'), $this->currency->format($this->currency->convert($amount, $this->config->get('config_currency'), $this->session->data['currency']), $this->session->data['currency'], 1), (int) $this->session->data['order_id'])); $this->customer->debitTransaction($transaction_data); } // google analytics data for js-script in footer.tpl $order = new AOrder($this->registry); $order_data = $order->buildOrderData($this->session->data); $order_tax = $order_total = $order_shipping = 0.0; foreach ($order_data['totals'] as $total) { if ($total['total_type'] == 'total') { $order_total += $total['value']; } elseif ($total['total_type'] == 'tax') { $order_tax += $total['value']; } elseif ($total['total_type'] == 'shipping') { $order_shipping += $total['value']; } } $this->registry->set('google_analytics_data', array('transaction_id' => (int) $this->session->data['order_id'], 'store_name' => $this->config->get('store_name'), 'currency_code' => $order_data['currency'], 'total' => $order_total, 'tax' => $order_tax, 'shipping' => $order_shipping, 'city' => $order_data['shipping_city'], 'state' => $order_data['shipping_zone'], 'country' => $order_data['shipping_country'])); $this->cart->clear(); unset($this->session->data['shipping_method'], $this->session->data['shipping_methods'], $this->session->data['payment_method'], $this->session->data['payment_methods'], $this->session->data['guest'], $this->session->data['comment'], $this->session->data['order_id'], $this->session->data['coupon'], $this->session->data['used_balance'], $this->session->data['used_balance_full']); //Redirect back. Fix for clearing shopping cart content $this->redirect($this->html->getSecureURL('checkout/success')); } $this->document->setTitle($this->language->get('heading_title')); $this->document->resetBreadcrumbs(); $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE)); $this->document->addBreadcrumb(array('href' => $this->html->getURL('checkout/cart'), 'text' => $this->language->get('text_basket'), 'separator' => $this->language->get('text_separator'))); if ($this->customer->isLogged()) { $this->document->addBreadcrumb(array('href' => $this->html->getURL('checkout/shipping'), 'text' => $this->language->get('text_shipping'), 'separator' => $this->language->get('text_separator'))); $this->document->addBreadcrumb(array('href' => $this->html->getURL('checkout/payment'), 'text' => $this->language->get('text_payment'), 'separator' => $this->language->get('text_separator'))); $this->document->addBreadcrumb(array('href' => $this->html->getURL('checkout/confirm'), 'text' => $this->language->get('text_confirm'), 'separator' => $this->language->get('text_separator'))); } else { $this->document->addBreadcrumb(array('href' => $this->html->getURL('checkout/guest'), 'text' => $this->language->get('text_guest'), 'separator' => $this->language->get('text_separator'))); $this->document->addBreadcrumb(array('href' => $this->html->getURL('checkout/guest/confirm'), 'text' => $this->language->get('text_confirm'), 'separator' => $this->language->get('text_separator'))); } $this->document->addBreadcrumb(array('href' => $this->html->getURL('checkout/success'), 'text' => $this->language->get('text_success'), 'separator' => $this->language->get('text_separator'))); $this->view->assign('heading_title', $this->language->get('heading_title')); if ($this->session->data['account'] == 'guest') { $this->view->assign('text_message', sprintf($this->language->get('text_message_guest'), $this->html->getURL('content/contact'))); } else { $this->view->assign('text_message', sprintf($this->language->get('text_message'), $this->html->getSecureURL('account/account'), $this->html->getSecureURL('account/history'), $this->html->getURL('content/contact'))); } $this->view->assign('button_continue', $this->language->get('button_continue')); $this->view->assign('continue', $this->html->getURL('index/home')); $continue = HtmlElementFactory::create(array('type' => 'button', 'name' => 'continue_button', 'text' => $this->language->get('button_continue'), 'style' => 'button')); $this->view->assign('continue_button', $continue); $this->processTemplate('common/success.tpl'); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function main() { $this->loadLanguage('default_pp_express/default_pp_express'); if ($this->request->get['rt'] != 'checkout/guest_step_3') { $back = $this->html->getSecureURL('checkout/payment'); } else { $back = $this->html->getSecureURL('checkout/guest_step_2'); } $this->data['button_back'] = $this->html->buildElement(array('type' => 'button', 'name' => 'back', 'text' => $this->language->get('button_back'), 'href' => $back)); $this->data['button_confirm'] = HtmlElementFactory::create(array('type' => 'submit', 'name' => $this->language->get('button_confirm'), 'style' => 'button', 'href' => $this->html->getSecureURL('r/extension/default_pp_express/confirm'))); $this->view->batchAssign($this->data); $this->processTemplate('responses/default_pp_express.tpl'); }
/** * Main controller function to show order hitory */ public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); if (!$this->customer->isLogged()) { $this->session->data['redirect'] = $this->html->getSecureURL('account/history'); $this->redirect($this->html->getSecureURL('account/login')); } $this->document->setTitle($this->language->get('heading_title')); $this->document->resetBreadcrumbs(); $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE)); $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/account'), 'text' => $this->language->get('text_account'), 'separator' => $this->language->get('text_separator'))); $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/history'), 'text' => $this->language->get('text_history'), 'separator' => $this->language->get('text_separator'))); $this->loadModel('account/order'); $order_total = $this->model_account_order->getTotalOrders(); if ($order_total) { $this->data['action'] = $this->html->getURL('account/history'); if (isset($this->request->get['page'])) { $page = $this->request->get['page']; } else { $page = 1; } if (isset($this->request->get['limit'])) { $limit = (int) $this->request->get['limit']; $limit = $limit > 50 ? 50 : $limit; } else { $limit = $this->config->get('config_catalog_limit'); } $orders = array(); $results = $this->model_account_order->getOrders(($page - 1) * $limit, $limit); foreach ($results as $result) { $product_total = $this->model_account_order->getTotalOrderProductsByOrderId($result['order_id']); $button = HtmlElementFactory::create(array('type' => 'button', 'name' => 'button_edit', 'text' => $this->language->get('button_view'), 'style' => 'btn-default', 'icon' => 'fa fa-info', 'attr' => ' onclick = "viewOrder(' . $result['order_id'] . ');" ')); $orders[] = array('order_id' => $result['order_id'], 'name' => $result['firstname'] . ' ' . $result['lastname'], 'status' => $result['status'], 'date_added' => dateISO2Display($result['date_added'], $this->language->get('date_format_short')), 'products' => $product_total, 'total' => $this->currency->format($result['total'], $result['currency'], $result['value']), 'href' => $this->html->getSecureURL('account/invoice', '&order_id=' . $result['order_id']), 'button' => $button->getHtml()); } $this->data['order_url'] = $this->html->getSecureURL('account/invoice'); $this->data['orders'] = $orders; $this->data['pagination_bootstrap'] = HtmlElementFactory::create(array('type' => 'Pagination', 'name' => 'pagination', 'text' => $this->language->get('text_pagination'), 'text_limit' => $this->language->get('text_per_page'), 'total' => $order_total, 'page' => $page, 'limit' => $limit, 'url' => $this->html->getURL('account/history', '&limit=' . $limit . '&page={page}'), 'style' => 'pagination')); $this->data['continue'] = $this->html->getSecureURL('account/account'); $this->view->setTemplate('pages/account/history.tpl'); } else { $this->data['continue'] = $this->html->getSecureURL('account/account'); $this->view->setTemplate('pages/error/not_found.tpl'); } $this->data['button_continue'] = HtmlElementFactory::create(array('type' => 'button', 'name' => 'continue_button', 'text' => $this->language->get('button_continue'), 'style' => 'button')); $this->view->batchAssign($this->data); $this->processTemplate(); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function main() { $item = HtmlElementFactory::create(array('type' => 'button', 'name' => 'back', 'style' => 'button mr10', 'text' => $this->language->get('button_back'), 'icon' => 'fa fa-arrow-left')); $this->view->assign('button_back', $item); $item = HtmlElementFactory::create(array('type' => 'button', 'name' => 'checkout', 'style' => 'button btn-orange pull-right', 'text' => $this->language->get('button_confirm'), 'icon' => 'fa fa-check')); $this->view->assign('button_confirm', $item); $this->view->assign('continue', $this->html->getSecureURL('checkout/success')); if ($this->request->get['rt'] != 'checkout/guest_step_3') { $this->view->assign('back', $this->html->getSecureURL('checkout/cart')); } else { $this->view->assign('back', $this->html->getSecureURL('checkout/guest_step_2')); } $this->processTemplate('responses/checkout/no_payment.tpl'); }
/** * Main Controller function to show transaction hitory. * Note: Regular orders are considered in the transactions. */ public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); if (!$this->customer->isLogged()) { $this->session->data['redirect'] = $this->html->getSecureURL('account/transactions'); $this->redirect($this->html->getSecureURL('account/login')); } $this->document->setTitle($this->language->get('heading_title')); $this->document->resetBreadcrumbs(); $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE)); $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/account'), 'text' => $this->language->get('text_account'), 'separator' => $this->language->get('text_separator'))); $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/transactions'), 'text' => $this->language->get('text_transactions'), 'separator' => $this->language->get('text_separator'))); $this->loadModel('account/customer'); $trans_total = $this->model_account_customer->getTotalTransactions(); $balance = $this->customer->getBalance(); $this->data['balance_amount'] = $this->currency->format($balance); if ($trans_total) { $this->data['action'] = $this->html->getURL('account/transactions'); if (isset($this->request->get['page'])) { $page = $this->request->get['page']; } else { $page = 1; } if (isset($this->request->get['limit'])) { $limit = (int) $this->request->get['limit']; $limit = $limit > 50 ? 50 : $limit; } else { $limit = $this->config->get('config_catalog_limit'); } $trans = array(); $results = $this->model_account_customer->getTransactions(($page - 1) * $limit, $limit); foreach ($results as $result) { $trans[] = array('customer_transaction_id' => $result['customer_transaction_id'], 'order_id' => $result['order_id'], 'section' => $result['section'], 'credit' => $this->currency->format($result['credit']), 'debit' => $this->currency->format($result['debit']), 'transaction_type' => $result['transaction_type'], 'description' => $result['description'], 'create_date' => dateISO2Display($result['create_date'], $this->language->get('date_format_short'))); } $this->data['transactions'] = $trans; $this->data['pagination_bootstrap'] = HtmlElementFactory::create(array('type' => 'Pagination', 'name' => 'pagination', 'text' => $this->language->get('text_pagination'), 'text_limit' => $this->language->get('text_per_page'), 'total' => $trans_total, 'page' => $page, 'limit' => $limit, 'url' => $this->html->getURL('account/transactions', '&limit=' . $limit . '&page={page}'), 'style' => 'pagination')); $this->data['continue'] = $this->html->getSecureURL('account/account'); $this->view->setTemplate('pages/account/transactions.tpl'); } else { $this->data['continue'] = $this->html->getSecureURL('account/account'); $this->view->setTemplate('pages/account/transactions.tpl'); } $this->data['button_continue'] = HtmlElementFactory::create(array('type' => 'button', 'name' => 'continue_button', 'text' => $this->language->get('button_continue'), 'style' => 'button')); $this->view->batchAssign($this->data); $this->processTemplate(); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function main() { $item = HtmlElementFactory::create(array('type' => 'button', 'name' => 'back', 'style' => 'button', 'text' => $this->language->get('button_back'))); $this->view->assign('button_back', $item); $item = HtmlElementFactory::create(array('type' => 'button', 'name' => 'checkout', 'style' => 'button btn-primary', 'text' => $this->language->get('button_confirm'))); $this->view->assign('button_confirm', $item); $this->view->assign('continue', $this->html->getSecureURL('checkout/success')); if ($this->request->get['rt'] != 'checkout/guest_step_3') { $this->view->assign('back', $this->html->getSecureURL('checkout/payment', '&mode=edit', true)); // to prevent coming back when payment method only one } else { $this->view->assign('back', $this->html->getSecureURL('checkout/guest_step_2')); } $this->processTemplate('responses/default_cod.tpl'); }
public function main() { $this->loadLanguage('default_pp_pro/default_pp_pro'); $this->load->model('checkout/order'); $this->load->model('extension/default_pp_pro'); $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); $data['cc_owner'] = HtmlElementFactory::create(array('type' => 'input', 'name' => 'cc_owner', 'value' => $order_info['payment_firstname'] . ' ' . $order_info['payment_lastname'], 'style' => 'input-medium')); //load accepted card types $cardtypes = $this->model_extension_default_pp_pro->getCreditCardTypes(); $cards = unserialize($this->config->get('default_pp_pro_creditcard_types')); $options = array(''); foreach ($cards as $card) { if ($card && isset($cardtypes[$card])) { $options[$card] = $cardtypes[$card]; } } $data['accepted_cards'] = $options; $data['cc_type'] = HtmlElementFactory::create(array('type' => 'selectbox', 'name' => 'cc_type', 'value' => '', 'options' => $options, 'style' => 'input-medium')); $data['cc_number'] = HtmlElementFactory::create(array('type' => 'input', 'name' => 'cc_number', 'value' => '', 'style' => 'input-medium', 'attr' => 'autocomplete="off"')); $months = array(); for ($i = 1; $i <= 12; $i++) { $months[sprintf('%02d', $i)] = strftime('%B', mktime(0, 0, 0, $i, 1, 2000)); } $data['cc_expire_date_month'] = HtmlElementFactory::create(array('type' => 'selectbox', 'name' => 'cc_expire_date_month', 'value' => sprintf('%02d', date('m')), 'options' => $months, 'style' => 'short input-small')); $today = getdate(); $years = array(); for ($i = $today['year']; $i < $today['year'] + 11; $i++) { $years[strftime('%Y', mktime(0, 0, 0, 1, 1, $i))] = strftime('%Y', mktime(0, 0, 0, 1, 1, $i)); } $data['cc_expire_date_year'] = HtmlElementFactory::create(array('type' => 'selectbox', 'name' => 'cc_expire_date_year', 'value' => sprintf('%02d', date('Y') + 1), 'options' => $years, 'style' => 'short input-small')); $data['cc_start_date_month'] = HtmlElementFactory::create(array('type' => 'selectbox', 'name' => 'cc_start_date_month', 'value' => sprintf('%02d', date('m')), 'options' => $months, 'style' => 'short input-small')); $years = array(); for ($i = $today['year'] - 10; $i < $today['year'] + 2; $i++) { $years[strftime('%Y', mktime(0, 0, 0, 1, 1, $i))] = strftime('%Y', mktime(0, 0, 0, 1, 1, $i)); } $data['cc_start_date_year'] = HtmlElementFactory::create(array('type' => 'selectbox', 'name' => 'cc_start_date_year', 'value' => sprintf('%02d', date('Y')), 'options' => $years, 'style' => 'short input-small')); $data['cc_cvv2'] = HtmlElementFactory::create(array('type' => 'input', 'name' => 'cc_cvv2', 'value' => '', 'style' => 'short', 'attr' => ' size="3" maxlength="4" autocomplete="off"')); $data['cc_issue'] = HtmlElementFactory::create(array('type' => 'input', 'name' => 'cc_issue', 'value' => '', 'style' => 'short', 'attr' => ' size="1" maxlength="2" autocomplete="off"')); $back = $this->request->get['rt'] != 'checkout/guest_step_3' ? $this->html->getSecureURL('checkout/payment') : $this->html->getSecureURL('checkout/guest_step_2'); $data['back'] = HtmlElementFactory::create(array('type' => 'button', 'name' => 'back', 'text' => $this->language->get('button_back'), 'style' => 'button', 'href' => $back)); $data['submit'] = HtmlElementFactory::create(array('type' => 'button', 'name' => 'paypal_button', 'text' => $this->language->get('button_confirm'), 'style' => 'button btn-orange')); //load creditcard input validation $this->document->addScriptBottom($this->view->templateResource('/javascript/credit_card_validation.js')); $this->view->batchAssign($data); $this->processTemplate('responses/default_pp_pro.tpl'); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); if ($this->customer->isLogged() || $this->customer->isUnauthCustomer()) { $this->customer->logout(); $this->cart->clear(); unset($this->session->data['shipping_address_id']); unset($this->session->data['shipping_method']); unset($this->session->data['shipping_methods']); unset($this->session->data['payment_address_id']); unset($this->session->data['payment_method']); unset($this->session->data['payment_methods']); unset($this->session->data['comment']); unset($this->session->data['order_id']); unset($this->session->data['coupon']); unset($this->session->data['merchant']); if ($this->config->get('config_tax_store')) { $country_id = $this->config->get('config_country_id'); $zone_id = $this->config->get('config_zone_id'); } else { $country_id = $zone_id = 0; } $this->tax->setZone($country_id, $zone_id); $this->redirect($this->html->getSecureURL('account/logout')); } $this->document->setTitle($this->language->get('heading_title')); $this->document->resetBreadcrumbs(); $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE)); $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/account'), 'text' => $this->language->get('text_account'), 'separator' => $this->language->get('text_separator'))); $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/logout'), 'text' => $this->language->get('text_logout'), 'separator' => $this->language->get('text_separator'))); $this->view->assign('continue', $this->html->getURL('index/home')); $continue = HtmlElementFactory::create(array('type' => 'button', 'name' => 'continue_button', 'text' => $this->language->get('button_continue'), 'style' => 'button')); $this->view->assign('continue_button', $continue); if ($this->config->get('embed_mode') == true) { //load special headers $this->addChild('responses/embed/head', 'head'); $this->addChild('responses/embed/footer', 'footer'); $this->processTemplate('embed/common/success.tpl'); } else { $this->processTemplate('common/success.tpl'); } //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function main() { $this->loadLanguage('default_cheque/default_cheque'); $this->view->batchAssign($this->language->getASet()); $this->view->assign('payable', $this->config->get('default_cheque_payable')); $this->view->assign('address', $this->config->get('config_address')); $this->view->assign('continue', $this->html->getSecureURL('checkout/success')); $item = HtmlElementFactory::create(array('type' => 'button', 'name' => 'back', 'style' => 'button', 'text' => $this->language->get('button_back'))); $this->view->assign('button_back', $item); $item = HtmlElementFactory::create(array('type' => 'button', 'name' => 'checkout', 'style' => 'button', 'text' => $this->language->get('button_confirm'))); $this->view->assign('button_confirm', $item); if ($this->request->get['rt'] != 'checkout/guest_step_3') { $this->view->assign('back', $this->html->getSecureURL('checkout/payment')); } else { $this->view->assign('back', $this->html->getSecureURL('checkout/guest_step_2')); } $this->processTemplate('responses/default_cheque.tpl'); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('default_stripe/default_stripe'); //neeed an order details $this->loadModel('checkout/order'); $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); $data['payment_address'] = $order_info['payment_address_1'] . " " . $order_info['payment_address_2']; $data['edit_address'] = $this->html->getSecureURL('checkout/address/payment'); $data['text_credit_card'] = $this->language->get('text_credit_card'); $data['text_wait'] = $this->language->get('text_wait'); $data['entry_cc_owner'] = $this->language->get('entry_cc_owner'); $data['cc_owner'] = HtmlElementFactory::create(array('type' => 'input', 'name' => 'cc_owner', 'placeholder' => $this->language->get('entry_cc_owner'), 'value' => $order_info['payment_firstname'] . ' ' . $order_info['payment_lastname'])); $data['entry_cc_number'] = $this->language->get('entry_cc_number'); $data['cc_number'] = HtmlElementFactory::create(array('type' => 'input', 'name' => 'cc_number', 'attr' => 'autocomplete="off"', 'placeholder' => $this->language->get('entry_cc_number'), 'value' => '')); $data['entry_cc_expire_date'] = $this->language->get('entry_cc_expire_date'); $data['entry_cc_cvv2'] = $this->language->get('entry_cc_cvv2'); $data['entry_cc_cvv2_short'] = $this->language->get('entry_cc_cvv2_short'); $data['cc_cvv2_help_url'] = $this->html->getURL('r/extension/default_stripe/cvv2_help'); $data['cc_cvv2'] = HtmlElementFactory::create(array('type' => 'input', 'name' => 'cc_cvv2', 'value' => '', 'style' => 'short', 'attr' => ' autocomplete="off" ')); $data['button_confirm'] = $this->language->get('button_confirm'); $data['button_back'] = $this->language->get('button_back'); $months = array(); for ($i = 1; $i <= 12; $i++) { $months[sprintf('%02d', $i)] = sprintf('%02d - ', $i) . strftime('%B', mktime(0, 0, 0, $i, 1, 2000)); } $data['cc_expire_date_month'] = HtmlElementFactory::create(array('type' => 'selectbox', 'name' => 'cc_expire_date_month', 'value' => sprintf('%02d', date('m')), 'options' => $months, 'style' => 'input-medium short')); $today = getdate(); $years = array(); for ($i = $today['year']; $i < $today['year'] + 11; $i++) { $years[strftime('%Y', mktime(0, 0, 0, 1, 1, $i))] = strftime('%Y', mktime(0, 0, 0, 1, 1, $i)); } $data['cc_expire_date_year'] = HtmlElementFactory::create(array('type' => 'selectbox', 'name' => 'cc_expire_date_year', 'value' => sprintf('%02d', date('Y') + 1), 'options' => $years, 'style' => 'short')); $back = $this->request->get['rt'] != 'checkout/guest_step_3' ? $this->html->getSecureURL('checkout/payment') : $this->html->getSecureURL('checkout/guest_step_2'); $data['back'] = HtmlElementFactory::create(array('type' => 'button', 'name' => 'back', 'text' => $this->language->get('button_back'), 'style' => 'button', 'href' => $back, 'icon' => 'icon-arrow-left')); $data['submit'] = HtmlElementFactory::create(array('type' => 'button', 'name' => 'strype_button', 'text' => $this->language->get('button_confirm'), 'style' => 'button btn-orange pull-right', 'icon' => 'icon-ok icon-white')); $this->view->batchAssign($data); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); //load creditcard input validation $this->document->addScriptBottom($this->view->templateResource('/javascript/credit_card_validation.js')); $this->processTemplate('responses/default_stripe.tpl'); }
public function main() { $this->loadLanguage('default_cashflows/default_cashflows'); $data['text_credit_card'] = $this->language->get('text_credit_card'); $data['text_start_date'] = $this->language->get('text_start_date'); $data['text_issue'] = $this->language->get('text_issue'); $data['text_wait'] = $this->language->get('text_wait'); $data['entry_cc_number'] = $this->language->get('entry_cc_number'); $data['entry_cc_start_date'] = $this->language->get('entry_cc_start_date'); $data['entry_cc_expire_date'] = $this->language->get('entry_cc_expire_date'); $data['entry_cc_cvv2'] = $this->language->get('entry_cc_cvv2'); $data['entry_cc_issue'] = $this->language->get('entry_cc_issue'); $data['button_confirm'] = $this->language->get('button_confirm'); $data['button_back'] = $this->language->get('button_back'); $data['cc_owner'] = HtmlElementFactory::create(array('type' => 'input', 'name' => 'cc_owner', 'value' => $order_info['payment_firstname'] . ' ' . $order_info['payment_lastname'], 'style' => 'input-medium')); $data['cc_number'] = HtmlElementFactory::create(array('type' => 'input', 'name' => 'cc_number', 'value' => '', 'style' => 'input-medium')); $months = array(); for ($i = 1; $i <= 12; $i++) { $months[sprintf('%02d', $i)] = strftime('%B', mktime(0, 0, 0, $i, 1, 2000)); } $data['cc_expire_date_month'] = $this->html->buildElement(array('type' => 'selectbox', 'name' => 'cc_expire_date_month', 'value' => sprintf('%02d', date('m')), 'options' => $months, 'style' => 'short input-small')); $data['cc_start_date_month'] = $this->html->buildElement(array('type' => 'selectbox', 'name' => 'cc_start_date_month', 'value' => sprintf('%02d', date('m')), 'options' => $months, 'style' => 'short input-small')); $today = getdate(); $years = array(); for ($i = $today['year']; $i < $today['year'] + 11; $i++) { $years[strftime('%Y', mktime(0, 0, 0, 1, 1, $i))] = strftime('%Y', mktime(0, 0, 0, 1, 1, $i)); } $data['cc_expire_date_year'] = HtmlElementFactory::create(array('type' => 'selectbox', 'name' => 'cc_expire_date_year', 'value' => sprintf('%02d', date('Y') + 1), 'options' => $years, 'style' => 'short input-small')); $data['cc_start_date_year'] = HtmlElementFactory::create(array('type' => 'selectbox', 'name' => 'cc_start_date_year', 'value' => sprintf('%02d', date('Y') + 1), 'options' => $years, 'style' => 'short input-small')); $data['cc_cvv2'] = HtmlElementFactory::create(array('type' => 'input', 'name' => 'cc_cvv2', 'value' => '', 'style' => 'short', 'attr' => ' size="3" maxlength="4" ')); $data['cc_issue'] = HtmlElementFactory::create(array('type' => 'input', 'name' => 'cc_issue', 'value' => '', 'style' => 'short', 'attr' => ' size="1" maxlength="2" ')); if ($this->request->get['rt'] != 'checkout/guest_step_3') { $back = $this->html->getSecureURL('checkout/payment'); } else { $back = $this->html->getSecureURL('checkout/guest_step_2'); } $data['back'] = HtmlElementFactory::create(array('type' => 'button', 'name' => 'back', 'text' => $this->language->get('button_back'), 'style' => 'button', 'href' => $back)); $data['submit'] = HtmlElementFactory::create(array('type' => 'button', 'name' => 'pp_button', 'text' => $this->language->get('button_confirm'), 'style' => 'button btn-orange')); $this->view->batchAssign($data); //load creditcard input validation $this->document->addScriptBottom($this->view->templateResource('/javascript/credit_card_validation.js')); $this->processTemplate('responses/default_cashflows.tpl'); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('default_authorizenet_aim/default_authorizenet_aim'); $data['text_credit_card'] = $this->language->get('text_credit_card'); $data['text_wait'] = $this->language->get('text_wait'); $data['entry_cc_owner'] = $this->language->get('entry_cc_owner'); $data['cc_owner'] = HtmlElementFactory::create(array('type' => 'input', 'name' => 'cc_owner', 'value' => '')); $data['cc_owner'] = $data['cc_owner']->getHtml(); $data['entry_cc_number'] = $this->language->get('entry_cc_number'); $data['cc_number'] = HtmlElementFactory::create(array('type' => 'input', 'name' => 'cc_number', 'value' => '')); $data['cc_number'] = $data['cc_number']->getHtml(); $data['entry_cc_expire_date'] = $this->language->get('entry_cc_expire_date'); $data['entry_cc_cvv2'] = $this->language->get('entry_cc_cvv2'); $data['entry_cc_cvv2_short'] = $this->language->get('entry_cc_cvv2_short'); $data['cc_cvv2_help_url'] = $this->html->getURL('r/extension/default_authorizenet_aim/cvv2_help'); $data['cc_cvv2'] = HtmlElementFactory::create(array('type' => 'input', 'name' => 'cc_cvv2', 'value' => '', 'style' => 'short input-mini', 'attr' => ' size="3" ')); $data['cc_cvv2'] = $data['cc_cvv2']->getHtml(); $data['button_confirm'] = $this->language->get('button_confirm'); $data['button_back'] = $this->language->get('button_back'); $months = array(); for ($i = 1; $i <= 12; $i++) { $months[sprintf('%02d', $i)] = strftime('%B', mktime(0, 0, 0, $i, 1, 2000)); } $data['cc_expire_date_month'] = HtmlElementFactory::create(array('type' => 'selectbox', 'name' => 'cc_expire_date_month', 'value' => sprintf('%02d', date('m')), 'options' => $months, 'style' => 'short input-small')); $data['cc_expire_date_month'] = $data['cc_expire_date_month']->getHtml(); $today = getdate(); $years = array(); for ($i = $today['year']; $i < $today['year'] + 11; $i++) { $years[strftime('%Y', mktime(0, 0, 0, 1, 1, $i))] = strftime('%Y', mktime(0, 0, 0, 1, 1, $i)); } $data['cc_expire_date_year'] = HtmlElementFactory::create(array('type' => 'selectbox', 'name' => 'cc_expire_date_year', 'value' => sprintf('%02d', date('Y') + 1), 'options' => $years, 'style' => 'short input-small')); $data['cc_expire_date_year'] = $data['cc_expire_date_year']->getHtml(); $back = $this->request->get['rt'] != 'checkout/guest_step_3' ? $this->html->getSecureURL('checkout/payment') : $this->html->getSecureURL('checkout/guest_step_2'); $data['back'] = HtmlElementFactory::create(array('type' => 'button', 'name' => 'back', 'text' => $this->language->get('button_back'), 'style' => 'button', 'href' => $back)); $data['submit'] = HtmlElementFactory::create(array('type' => 'button', 'name' => 'authorizenet_button', 'text' => $this->language->get('button_confirm'), 'style' => 'button')); $this->view->batchAssign($data); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->processTemplate('responses/default_authorizenet_aim.tpl'); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); if (!$this->customer->isLogged()) { $this->session->data['redirect'] = $this->html->getSecureURL('account/password'); $this->redirect($this->html->getSecureURL('account/login')); } $this->document->setTitle($this->language->get('heading_title')); if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->_validate()) { $this->loadModel('account/customer'); $this->model_account_customer->editPassword($this->customer->getLoginName(), $this->request->post['password']); $this->session->data['success'] = $this->language->get('text_success'); $this->redirect($this->html->getSecureURL('account/account')); } $this->document->resetBreadcrumbs(); $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE)); $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/account'), 'text' => $this->language->get('text_account'), 'separator' => $this->language->get('text_separator'))); $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/password'), 'text' => $this->language->get('heading_title'), 'separator' => $this->language->get('text_separator'))); $this->view->assign('error_warning', $this->error['warning']); $this->view->assign('error_current_password', $this->error['current_password']); $this->view->assign('error_password', $this->error['password']); $this->view->assign('error_confirm', $this->error['confirm']); $form = new AForm(); $form->setForm(array('form_name' => 'PasswordFrm')); $form_open = $form->getFieldHtml(array('type' => 'form', 'name' => 'PasswordFrm', 'action' => $this->html->getSecureURL('account/password'))); $this->view->assign('form_open', $form_open); $current_password = $form->getFieldHtml(array('type' => 'password', 'name' => 'current_password', 'value' => '', 'required' => true)); $password = $form->getFieldHtml(array('type' => 'password', 'name' => 'password', 'value' => '', 'required' => true)); $confirm = $form->getFieldHtml(array('type' => 'password', 'name' => 'confirm', 'value' => '', 'required' => true)); $submit = $form->getFieldHtml(array('type' => 'submit', 'name' => $this->language->get('button_continue'), 'icon' => 'icon-check')); $this->view->assign('current_password', $current_password); $this->view->assign('password', $password); $this->view->assign('submit', $submit); $this->view->assign('confirm', $confirm); $this->view->assign('back', $this->html->getSecureURL('account/account')); $back = HtmlElementFactory::create(array('type' => 'button', 'name' => 'back', 'text' => $this->language->get('button_back'), 'icon' => 'icon-arrow-left', 'style' => 'button')); $this->view->assign('button_back', $back); $this->processTemplate('pages/account/password.tpl'); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . '/1.1 404 Not Found'); $this->document->setTitle($this->language->get('heading_title')); $this->document->resetBreadcrumbs(); $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE)); if (isset($this->request->get['rt'])) { $this->document->addBreadcrumb(array('href' => $this->html->getURL($this->request->get['rt']), 'text' => $this->language->get('text_error'), 'separator' => $this->language->get('text_separator'))); } $this->view->assign('heading_title', $this->language->get('heading_title')); $this->view->assign('text_error', $this->language->get('text_error')); $continue = HtmlElementFactory::create(array('type' => 'button', 'name' => 'continue_button', 'text' => $this->language->get('button_continue'), 'style' => 'button')); $this->view->assign('button_continue', $continue); $this->view->assign('continue', $this->html->getURL('index/home')); $this->processTemplate('pages/error/not_found.tpl'); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function details() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('common/header'); $this->loadLanguage('common/home'); $this->loadLanguage('banner_manager/banner_manager'); $this->document->setTitle($this->language->get('banner_manager_name_stat')); $this->loadModel('extension/banner_manager'); $info = $this->model_extension_banner_manager->getBanner((int) $this->request->get['banner_id']); $this->data['heading_title'] = $this->language->get('banner_manager_name_stat') . ': ' . $info['name']; $this->data['chart_url'] = $this->html->getSecureURL('extension/banner_manager_chart', '&banner_id=' . $this->request->get['banner_id']); $options = array('day' => $this->language->get('text_day'), 'week' => $this->language->get('text_week'), 'month' => $this->language->get('text_month'), 'year' => $this->language->get('text_year')); $this->data['select_range'] = HtmlElementFactory::create(array('type' => 'selectbox', 'name' => 'range', 'options' => $options, 'value' => 'day')); $this->data['select_range'] = $this->data['select_range']->getHtml(); $this->data['text_count'] = $this->language->get('text_count'); $this->view->batchAssign($this->data); $this->processTemplate('pages/extension/banner_manager_stat_details.tpl'); //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function main() { $request = $this->request->get; //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadModel('catalog/content'); $this->document->resetBreadcrumbs(); $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE)); if (isset($request['content_id'])) { $content_id = $request['content_id']; } else { $content_id = 0; } $content_info = $this->model_catalog_content->getContent($content_id); if ($content_info) { $this->document->setTitle($content_info['title']); $this->document->addBreadcrumb(array('href' => $this->html->getSEOURL('content/content', '&content_id=' . $request['content_id'], true), 'text' => $content_info['title'], 'separator' => $this->language->get('text_separator'))); $this->view->assign('heading_title', $content_info['title']); $this->view->assign('button_continue', $this->language->get('button_continue')); $this->view->assign('description', html_entity_decode($content_info['description'])); $this->view->assign('content', html_entity_decode($content_info['content'])); $continue = HtmlElementFactory::create(array('type' => 'button', 'name' => 'continue_button', 'text' => $this->language->get('button_continue'), 'style' => 'button')); $this->view->assign('button_continue', $continue); $this->view->assign('continue', $this->html->getURL('index/home')); $this->view->setTemplate('pages/content/content.tpl'); } else { $this->document->addBreadcrumb(array('href' => $this->html->getSEOURL('content/content', '&content_id=' . $request['content_id'], true), 'text' => $this->language->get('text_error'), 'separator' => $this->language->get('text_separator'))); $this->document->setTitle($this->language->get('text_error')); $this->view->assign('heading_title', $this->language->get('text_error')); $this->view->assign('text_error', $this->language->get('text_error')); $continue = HtmlElementFactory::create(array('type' => 'button', 'name' => 'continue_button', 'text' => $this->language->get('button_continue'), 'style' => 'button')); $this->view->assign('button_continue', $continue); $this->view->assign('continue', $this->html->getURL('index/home')); $this->view->setTemplate('pages/error/not_found.tpl'); } $this->processTemplate(); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
private function getWishList() { $cart_rt = 'checkout/cart'; //is this an embed mode if ($this->config->get('embed_mode') == true) { $cart_rt = 'r/checkout/cart/embed'; } $this->document->setTitle($this->language->get('heading_title')); $this->document->resetBreadcrumbs(); $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE)); $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/account'), 'text' => $this->language->get('text_account'), 'separator' => $this->language->get('text_separator'))); $this->document->addBreadcrumb(array('href' => $this->html->getURL('account/wishlist'), 'text' => $this->language->get('heading_title'), 'separator' => $this->language->get('text_separator'))); $whishlist = $this->customer->getWishList(); if ($whishlist) { $this->loadModel('tool/seo_url'); $this->loadModel('catalog/product'); $products = array(); $resource = new AResource('image'); foreach ($whishlist as $product_id => $timestamp) { $product_info = $this->model_catalog_product->getProduct($product_id); $thumbnail = $resource->getMainThumb('products', $product_id, (int) $this->config->get('config_image_cart_width'), (int) $this->config->get('config_image_cart_height'), true); $options = $this->model_catalog_product->getProductOptions($product_id); if ($options) { $add = $this->html->getSEOURL('product/product', '&product_id=' . $product_id, '&encode'); } else { $add = $this->html->getSecureURL($cart_rt, '&product_id=' . $product_id, '&encode'); } $products[] = array('product_id' => $product_id, 'name' => $product_info['name'], 'model' => $product_info['model'], 'thumb' => $thumbnail, 'added' => dateInt2Display($timestamp), 'price' => $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax'))), 'href' => $this->html->getSEOURL('product/product', '&product_id=' . $product_id, true), 'call_to_order' => $product_info['call_to_order'], 'add' => $add); } $this->data['products'] = $products; if (isset($this->session->data['redirect'])) { $this->data['continue'] = str_replace('&', '&', $this->session->data['redirect']); unset($this->session->data['redirect']); } else { $this->data['continue'] = $this->html->getURL('index/home'); } $this->view->assign('error', ''); if ($this->session->data['error']) { $this->view->assign('error', $this->session->data['error']); unset($this->session->data['error']); } if ($this->config->get('config_customer_price')) { $display_price = TRUE; } elseif ($this->customer->isLogged()) { $display_price = TRUE; } else { $display_price = FALSE; } $this->data['display_price'] = $display_price; $this->view->setTemplate('pages/account/wishlist.tpl'); } else { $this->data['heading_title'] = $this->language->get('heading_title'); $this->data['text_error'] = $this->language->get('text_empty_wishlist'); $this->data['button_continue'] = HtmlElementFactory::create(array('name' => 'continue', 'type' => 'button', 'text' => $this->language->get('button_continue'), 'href' => $this->html->getURL('index/home'), 'style' => 'button')); $this->view->setTemplate('pages/error/not_found.tpl'); } $this->data['cart'] = $this->html->getSecureURL($cart_rt); $this->view->batchAssign($this->data); $this->processTemplate(); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('catalog/product'); $this->document->setTitle($this->language->get('heading_title')); $this->loadModel('catalog/product'); $this->attribute_manager = new AAttribute_Manager(); if ($this->request->is_POST() && $this->_validateForm()) { $this->model_catalog_product->addProductOption($this->request->get['product_id'], $this->request->post); $this->session->data['success'] = $this->language->get('text_success'); $this->redirect($this->html->getSecureURL('catalog/product_options', '&product_id=' . $this->request->get['product_id'])); } $product_info = $this->model_catalog_product->getProduct($this->request->get['product_id']); if (!$product_info) { $this->session->data['warning'] = $this->language->get('error_product_not_found'); $this->redirect($this->html->getSecureURL('catalog/product')); } $this->data['attributes'] = array('new' => $this->language->get('text_add_new_option')); $results = $this->attribute_manager->getAttributes(array('search' => " ga.attribute_type_id = '" . $this->attribute_manager->getAttributeTypeID('product_option') . "'\n\t\t\t\tAND ga.status = 1\n\t\t\t\tAND ga.attribute_parent_id = 0 ", 'sort' => 'sort_order', 'order' => 'ASC', 'limit' => 1000), $this->session->data['content_language_id']); foreach ($results as $type) { $this->data['attributes'][$type['attribute_id']] = $type['name']; } $this->data['product_description'] = $this->model_catalog_product->getProductDescriptions($this->request->get['product_id']); $product_options = $this->model_catalog_product->getProductOptions($this->request->get['product_id']); $content_language_id = $this->language->getContentLanguageID(); $default_language_id = $this->language->getDefaultLanguageID(); foreach ($product_options as &$option) { $option_name = trim($option['language'][$content_language_id]['name']); $option['language'][$content_language_id]['name'] = $option_name ? $option_name : 'n/a'; $option_name = trim($option['language'][$default_language_id]['name']); $option['language'][$default_language_id]['name'] = $option_name ? $option_name : 'n/a'; } unset($option); $this->data['product_options'] = $product_options; $this->data['language_id'] = $this->session->data['content_language_id']; $this->data['url']['load_option'] = $this->html->getSecureURL('product/product/load_option', '&product_id=' . $this->request->get['product_id']); $this->data['url']['update_option'] = $this->html->getSecureURL('product/product/update_option', '&product_id=' . $this->request->get['product_id']); $this->data['url']['get_options_list'] = $this->html->getSecureURL('product/product/get_options_list', '&product_id=' . $this->request->get['product_id']); $this->view->assign('error', $this->error); $this->view->assign('success', $this->session->data['success']); if (isset($this->session->data['success'])) { unset($this->session->data['success']); } $this->document->initBreadcrumb(array('href' => $this->html->getSecureURL('index/home'), 'text' => $this->language->get('text_home'))); $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('catalog/product'), 'text' => $this->language->get('heading_title'))); $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('catalog/product/update', '&product_id=' . $this->request->get['product_id']), 'text' => $this->language->get('text_edit') . ' ' . $this->language->get('text_product') . ' - ' . $this->data['product_description'][$this->session->data['content_language_id']]['name'])); $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('catalog/product_options', '&product_id=' . $this->request->get['product_id']), 'text' => $this->language->get('tab_option'), 'current' => true)); $this->data['active'] = 'options'; //load tabs controller $tabs_obj = $this->dispatch('pages/catalog/product_tabs', array($this->data)); $this->data['product_tabs'] = $tabs_obj->dispatchGetOutput(); unset($tabs_obj); $results = HtmlElementFactory::getAvailableElements(); $element_types = array('' => $this->language->get('text_select')); foreach ($results as $key => $type) { // allowed field types if (in_array($key, array('I', 'T', 'S', 'M', 'R', 'C', 'G', 'H', 'U'))) { $element_types[$key] = $type['type']; } } $this->data['button_add_option'] = $this->html->buildButton(array('text' => $this->language->get('button_add_option'), 'style' => 'button1')); $this->data['button_add_option_value'] = $this->html->buildButton(array('text' => $this->language->get('button_add_option_value'), 'style' => 'button1')); $this->data['button_remove'] = $this->html->buildButton(array('text' => $this->language->get('button_remove'), 'style' => 'button1')); $this->data['button_reset'] = $this->html->buildButton(array('text' => $this->language->get('button_reset'), 'style' => 'button2')); $this->data['action'] = $this->html->getSecureURL('catalog/product_options', '&product_id=' . $this->request->get['product_id']); $this->data['form_title'] = $this->language->get('text_edit') . ' ' . $this->language->get('text_product'); $this->data['update'] = ''; $form = new AForm('HT'); $product_opt = array(); foreach ($product_options as $option) { $product_opt[$option['product_option_id']] = $option['language'][$content_language_id]['name']; } $this->data['options'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'option', 'value' => $this->data['product_option_id'], 'options' => $product_opt)); $form->setForm(array('form_name' => 'product_form', 'update' => $this->data['update'])); $this->data['form']['id'] = 'product_form'; $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'product_form', 'action' => $this->data['action'], 'attr' => 'data-confirm-exit="true" class="form-horizontal"')); $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_add'), 'style' => 'button1')); $this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'text' => $this->language->get('button_cancel'), 'style' => 'button2')); $form->setForm(array('form_name' => 'new_option_form', 'update' => '')); $this->data['attributes'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'attribute_id', 'options' => $this->data['attributes'], 'style' => 'chosen')); $this->data['option_name'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'option_name', 'required' => true)); $this->data['status'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'status', 'value' => 1, 'style' => 'btn_switch')); $this->data['sort_order'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'sort_order', 'style' => 'small-field')); $this->data['required'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'required', 'style' => 'btn_switch')); $this->data['element_type'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'element_type', 'required' => true, 'options' => $element_types)); $this->addChild('pages/catalog/product_summary', 'summary_form', 'pages/catalog/product_summary.tpl'); $object_title = $this->language->get('text_product') . ' ' . $this->language->get('text_option_value'); $params = '&object_name=product_option_value&object_title=' . $object_title; $this->data['rl_resource_library'] = $this->html->getSecureURL('common/resource_library', $params); $this->data['rl_resources'] = $this->html->getSecureURL('common/resource_library/resources', $params); $this->data['rl_resource_single'] = $this->html->getSecureURL('common/resource_library/get_resource_details', $params); $this->data['rl_delete'] = $this->html->getSecureURL('common/resource_library/delete'); $this->data['rl_unmap'] = $this->html->getSecureURL('common/resource_library/unmap', $params); $this->data['rl_map'] = $this->html->getSecureURL('common/resource_library/map', $params); $this->data['rl_download'] = $this->html->getSecureURL('common/resource_library/get_resource_preview'); $this->data['rl_upload'] = $this->html->getSecureURL('common/resource_library/upload', $params); $resources_scripts = $this->dispatch('responses/common/resource_library/get_resources_scripts', array('object_name' => 'product_option_value', 'object_id' => '', 'types' => array('image'), 'onload' => false)); if ($this->config->get('config_embed_status')) { $this->data['embed_url'] = $this->html->getSecureURL('common/do_embed/product', '&product_id=' . $this->request->get['product_id']); } $this->view->assign('resources_scripts', $resources_scripts->dispatchGetOutput()); $this->view->assign('help_url', $this->gen_help_url('product_options')); $this->view->assign('form_language_switch', $this->html->getContentLanguageSwitcher()); $this->view->batchAssign($this->data); $this->processTemplate('pages/catalog/product_options.tpl'); //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
/** * Form to edit product from order */ public function orderProductForm() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadModel('catalog/product'); $this->loadModel('sale/order'); $this->loadLanguage('catalog/product'); $this->loadLanguage('sale/order'); $this->load->library('json'); $elements_with_options = HtmlElementFactory::getElementsWithOptions(); $order_product_id = (int) $this->request->get['order_product_id']; $order_id = (int) $this->request->get['order_id']; $order_info = $this->model_sale_order->getOrder($order_id); $tax = new ATax($this->registry); $tax->setZone($order_info['country_id'], $order_info['zone_id']); $product_id = (int) $this->request->get['product_id']; $preset_values = array(); if ($order_product_id) { //if unknown product_id but order_product_id we know $order_product_info = $this->model_sale_order->getOrderProducts($order_id, $order_product_id); $preset_values['price'] = $this->currency->format($order_product_info[0]['price'], $order_info['currency'], $order_info['value'], false); $preset_values['total'] = $this->currency->format($order_product_info[0]['price'] * $order_product_info[0]['quantity'], $order_info['currency'], $order_info['value'], false); $preset_values['quantity'] = $order_product_info[0]['quantity']; if (!$product_id) { $product_id = $order_product_info[0]['product_id']; } $product_info = $this->model_catalog_product->getProduct($product_id); $order_product_options = $this->model_sale_order->getOrderOptions($order_id, $order_product_id); foreach ($order_product_options as $v) { if ($v['element_type'] == 'R') { $preset_values[$v['product_option_id']] = $v['product_option_value_id']; } elseif (in_array($v['element_type'], $elements_with_options)) { $preset_values[$v['product_option_id']][] = $v['product_option_value_id']; } else { $preset_values[$v['product_option_id']] = $v['value']; } } $this->data['text_title'] = $this->language->get('text_edit_order_product'); $form_action = $this->html->getSecureURL('sale/order/update', '&order_id=' . $order_id . '&order_product_id=' . $order_product_id); } else { $product_info = $this->model_catalog_product->getProduct($product_id); $this->data['text_title'] = sprintf($this->language->get('text_add_product_to_order'), $order_id); $preset_values['quantity'] = $product_info['minimum'] ? $product_info['minimum'] : 1; $preset_values['price'] = $this->currency->format($product_info['price'], $order_info['currency'], $order_info['value'], false); $preset_values['total'] = $this->currency->format($product_info['price'] * $preset_values['quantity'], $order_info['currency'], $order_info['value'], false); $form_action = $this->html->getSecureURL('sale/order/update', '&order_id=' . $order_id . '&product_id=' . $product_id); } $this->data['product_href'] = $this->html->getSecureURL('catalog/product/update', '&product_id=' . $product_id); $form = new AForm('HT'); $form->setForm(array('form_name' => 'orderProductFrm')); $this->data['form']['id'] = 'orderProductFrm'; $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'orderProductFrm', 'attr' => 'data-confirm-exit="true" class="aform form-horizontal"', 'action' => $form_action)); $this->data['text_title'] .= ' - ' . $product_info['name']; // Prepare options and values for display $product_options = $this->model_catalog_product->getOrderProductOptions($product_id); $option_values_prices = array(); foreach ($product_options as $option) { if (in_array($option['element_type'], array('U'))) { continue; } //skip files for now. TODO: add edit file-option in the future $values = $prices = array(); $price = $preset_value = $default_value = ''; foreach ($option['option_value'] as $option_value) { //default value $default_value = $option_value['default'] && !$order_product_id ? $option_value['product_option_value_id'] : $default_value; //early saved value $preset_value = $preset_values[$option['product_option_id']]; //when adds new product in the order if (!$order_product_id) { if ($option_value['default'] == 1) { $preset_value = $option_value['product_option_value_id']; } elseif (!in_array($option['element_type'], $elements_with_options)) { $preset_value = $option_value['name']; } } //Apply option price modifier if ($option_value['prefix'] == '%') { $price = $tax->calculate($product_info['price'] * $option_value['price'] / 100, $product_info['tax_class_id'], (bool) $this->config->get('config_tax')); } else { $price = $tax->calculate($option_value['price'], $product_info['tax_class_id'], (bool) $this->config->get('config_tax')); } if ($price != 0) { $price = $this->currency->format($price); } else { $price = ''; } //Check stock and status $opt_stock_message = ''; if ($option_value['subtract']) { if ($option_value['quantity'] <= 0) { //show out of stock message $opt_stock_message = ' (' . $this->language->get('text_product_out_of_stock') . ')'; } else { if ($this->config->get('config_stock_display')) { $opt_stock_message = ' (' . $option_value['quantity'] . " " . $this->language->get('text_product_in_stock') . ')'; } } } $values[$option_value['product_option_value_id']] = $option_value['name'] . ' ' . $price . ' ' . $opt_stock_message; } //if not values are build, nothing to show if (count($values)) { //add price to option name if it is not element with options if (!in_array($option['element_type'], $elements_with_options)) { $option['name'] .= ' <small>' . $price . '</small>'; if ($opt_stock_message) { $option['name'] .= '<br />' . $opt_stock_message; } } //set default selection is nothing selected if (!has_value($preset_value) && $option['element_type'] != 'C') { if (has_value($default_value)) { $preset_value = $default_value; } } //show hidden option for admin if ($option['html_type'] == 'hidden') { $option['html_type'] = 'input'; } $value = $preset_value; //for checkbox with empty value if ($value == '' && $option['element_type'] == 'C') { $value = $default_value; $value = $value == '' ? 1 : $value; } $option_data = array('type' => $option['html_type'], 'name' => !in_array($option['element_type'], HtmlElementFactory::getMultivalueElements()) ? 'product[0][option][' . $option['product_option_id'] . ']' : 'product[0][option][' . $option['product_option_id'] . '][]', 'value' => $value, 'options' => $values, 'placeholder' => $option['option_placeholder'], 'regexp_pattern' => $option['regexp_pattern'], 'error_text' => $option['error_text'], 'attr' => ' data-option-id ="' . $option['product_option_id'] . '"'); if ($option['element_type'] == 'C') { // note: 0 and 1 must be stirng to prevent collision with 'yes'. (in php 'yes'==1) ;-) $option_data['label_text'] = !in_array($value, array('0', '1')) ? $value : ''; $option_data['checked'] = $preset_value ? true : false; } $options[] = array('name' => $option['name'], 'html' => $form->getFieldHtml($option_data)); } } $this->data['options'] = $options; // main product image $resource = new AResource('image'); $thumbnail = $resource->getMainThumb('products', $product_id, $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'), true); $this->data['image'] = $thumbnail; $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $order_product_id ? $this->language->get('button_save') : $this->language->get('button_add'))); $this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'text' => $this->language->get('button_cancel'))); $this->data['form']['fields']['price'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'product[0][price]', 'value' => $preset_values['price'], 'attr' => ' readonly')); if (!$options && $product_info['subtract']) { if ($product_info['quantity']) { $this->data['column_quantity'] = $this->language->get('column_quantity') . ' (' . $this->language->get('text_product_in_stock') . ': ' . $product_info['quantity'] . ')'; } else { $this->data['column_quantity'] = $this->language->get('column_quantity') . ' (' . $this->language->get('text_product_out_of_stock') . ')'; } } $this->data['form']['fields']['quantity'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'product[0][quantity]', 'value' => $preset_values['quantity'], 'attr' => ' size="4"')); $this->data['form']['fields']['total'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'product[0][total]', 'value' => $preset_values['total'], 'attr' => 'readonly')); $this->data['form']['fields']['product_id'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'product_id', 'value' => $product_id)); $this->data['form']['fields']['order_product_id'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'order_product_id', 'value' => (int) $order_product_id)); //url to storefront response controller. Note: if admin under ssl - use https for url and otherwise $order_store_id = $order_info['store_id']; $this->loadModel('setting/store'); $store_info = $this->model_setting_store->getStore($order_store_id); if (HTTPS === true && $store_info['config_ssl_url']) { $total_calc_url = $store_info['config_ssl_url'] . 'index.php?rt=r/product/product/calculateTotal'; } elseif (HTTPS === true && !$store_info['config_ssl_url']) { $total_calc_url = str_replace('http://', 'https://', $store_info['config_url']) . 'index.php?rt=r/product/product/calculateTotal'; } else { $total_calc_url = $store_info['config_url'] . 'index.php?rt=r/product/product/calculateTotal'; } $this->data['total_calc_url'] = $total_calc_url; //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->view->batchAssign($this->data); $this->processTemplate('responses/product/product_form.tpl'); }
public function success() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->document->setTitle($this->language->get('heading_title')); $this->document->resetBreadcrumbs(); $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE)); $this->document->addBreadcrumb(array('href' => $this->html->getURL('content/contact'), 'text' => $this->language->get('heading_title'), 'separator' => $this->language->get('text_separator'))); $this->view->assign('continue', $this->html->getURL('index/home')); $continue = HtmlElementFactory::create(array('type' => 'button', 'name' => 'continue_button', 'text' => $this->language->get('button_continue'), 'style' => 'button')); $this->view->assign('continue_button', $continue); $this->processTemplate('common/success.tpl'); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function getOrderProductOptions($product_id) { if (!(int) $product_id) { return array(); } $language_id = $this->language->getContentLanguageID(); $elements = HtmlElementFactory::getAvailableElements(); $product_option_data = array(); $product_option_query = $this->db->query("SELECT po.*, pod.option_placeholder, pod.error_text\n\t\t\tFROM " . $this->db->table("product_options") . " po\n\t\t\tLEFT JOIN " . $this->db->table("product_option_descriptions") . " pod\n\t\t\t\tON pod.product_option_id = po.product_option_id AND pod.language_id = '" . $language_id . "'\n\t\t\tWHERE po.product_id = '" . (int) $product_id . "'\n\t\t\t\tAND po.group_id = 0\n\t\t\t\tAND po.status = 1\n\t\t\tORDER BY po.sort_order"); if ($product_option_query) { foreach ($product_option_query->rows as $product_option) { $attribute_values = array(); $product_option_value_data = array(); $product_option_value_query = $this->db->query("SELECT *\n\t\t\t\t\t\tFROM " . $this->db->table("product_option_values") . "\n\t\t\t\t\t\tWHERE product_option_id = '" . (int) $product_option['product_option_id'] . "'\n\t\t\t\t\t\tORDER BY sort_order"); if ($product_option_value_query) { foreach ($product_option_value_query->rows as $product_option_value) { if ($product_option_value['attribute_value_id']) { //skip duplicate attributes values if it is not grouped parent/child if (in_array($product_option_value['attribute_value_id'], $attribute_values)) { continue; } $attribute_values[] = $product_option_value['attribute_value_id']; } $pd_opt_val_description_qr = $this->db->query("SELECT *\n\t\t\t\t\t\t\t\tFROM " . $this->db->table("product_option_value_descriptions") . "\n\t\t\t\t\t\t\t\tWHERE product_option_value_id = '" . (int) $product_option_value['product_option_value_id'] . "'\n\t\t\t\t\t\t\t\tAND language_id = '" . (int) $language_id . "'"); $product_option_value_data[$product_option_value['product_option_value_id']] = array('product_option_value_id' => $product_option_value['product_option_value_id'], 'attribute_value_id' => $product_option_value['attribute_value_id'], 'grouped_attribute_data' => $product_option_value['grouped_attribute_data'], 'group_id' => $product_option_value['group_id'], 'name' => $pd_opt_val_description_qr->row['name'], 'option_placeholder' => $product_option['option_placeholder'], 'regexp_pattern' => $product_option['regexp_pattern'], 'error_text' => $product_option['error_text'], 'settings' => $product_option['settings'], 'children_options_names' => $pd_opt_val_description_qr->row['children_options_names'], 'sku' => $product_option_value['sku'], 'price' => $product_option_value['price'], 'prefix' => $product_option_value['prefix'], 'weight' => $product_option_value['weight'], 'weight_type' => $product_option_value['weight_type'], 'quantity' => $product_option_value['quantity'], 'subtract' => $product_option_value['subtract'], 'default' => $product_option_value['default']); } } $prd_opt_description_qr = $this->db->query("SELECT *\n\t\t\t\t\tFROM " . $this->db->table("product_option_descriptions") . "\n\t\t\t\t\tWHERE product_option_id = '" . (int) $product_option['product_option_id'] . "'\n\t\t\t\t\t\tAND language_id = '" . (int) $language_id . "'"); $product_option_data[$product_option['product_option_id']] = array('product_option_id' => $product_option['product_option_id'], 'attribute_id' => $product_option['attribute_id'], 'group_id' => $product_option['group_id'], 'name' => $prd_opt_description_qr->row['name'], 'option_placeholder' => $product_option['option_placeholder'], 'option_value' => $product_option_value_data, 'sort_order' => $product_option['sort_order'], 'element_type' => $product_option['element_type'], 'html_type' => $elements[$product_option['element_type']]['type'], 'required' => $product_option['required'], 'regexp_pattern' => $product_option['regexp_pattern'], 'error_text' => $product_option['error_text'], 'settings' => $product_option['settings']); } } return $product_option_data; }
/** * @param int $attribute_id * @param array $data */ public function updateAttribute($attribute_id, $data) { //Note: update is done per 1 language $language_id = $this->session->data['content_language_id']; $fields = array('attribute_type_id', 'attribute_group_id', 'attribute_parent_id', 'element_type', 'required', 'sort_order', 'settings', 'status', 'regexp_pattern'); $elements_with_options = HtmlElementFactory::getElementsWithOptions(); $attribute = $this->getAttribute($attribute_id, $language_id); //check if we change element type and clean options if it does not require it if (isset($data['element_type']) && $data['element_type'] != $attribute['element_type']) { if (!in_array($data['element_type'], $elements_with_options)) { $sql = "DELETE FROM `" . DB_PREFIX . "global_attributes_values`\n\t\t\t\t\t\tWHERE attribute_id = '" . (int) $attribute_id . "'"; $this->db->query($sql); $sql = "DELETE FROM `" . DB_PREFIX . "global_attributes_value_descriptions`\n\t\t\t\t\t\tWHERE attribute_id = '" . (int) $attribute_id . "'"; $this->db->query($sql); } } if (has_value($data['settings'])) { $data['settings'] = serialize($data['settings']); } $update = array(); foreach ($fields as $f) { if (isset($data[$f])) { $update[] = "{$f} = '" . $this->db->escape($data[$f]) . "'"; } } if (!empty($update)) { $sql = "UPDATE " . DB_PREFIX . "global_attributes\n SET " . implode(',', $update) . "\n WHERE attribute_id = '" . (int) $attribute_id . "'"; $this->db->query($sql); } $update = array(); if (isset($data['name'])) { $update['name'] = $data['name']; } if (isset($data['error_text'])) { $update['error_text'] = $data['error_text']; } $this->language->replaceDescriptions('global_attributes_descriptions', array('attribute_id' => (int) $attribute_id), array($language_id => $update)); //Update Attribute Values if (!empty($data['values']) && in_array($data['element_type'], $elements_with_options)) { foreach ($data['values'] as $atr_val_id => $value) { //Check if new or update if ($data['attribute_value_ids'][$atr_val_id] == 'delete') { //delete the description $this->deleteAllAttributeValueDescriptions($atr_val_id); //delete value if no other language $this->deleteAttributeValues($atr_val_id); } else { if ($data['attribute_value_ids'][$atr_val_id] == 'new') { // New need to create $attribute_value_id = $this->addAttributeValue($attribute_id, $data['sort_orders'][$atr_val_id]); if ($attribute_value_id) { $this->addAttributeValueDescription($attribute_id, $attribute_value_id, $language_id, $value); } } else { //Existing need to update $this->updateAttributeValue($atr_val_id, $data['sort_orders'][$atr_val_id]); $this->updateAttributeValueDescription($attribute_id, $atr_val_id, $language_id, $value); } } } } $this->clearCache(); }
/** * method that return part of attribute form for download attribute * @internal param array $param * @param array $params */ public function getDownloadAttributeSubform($params = array()) { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->data = array_merge($this->data, $params['data']); unset($this->data['form']['fields']); // remove form fields that do not needed here $this->data['elements_with_options'] = HtmlElementFactory::getElementsWithOptions(); $results = HtmlElementFactory::getAvailableElements(); $element_types = array('' => $this->language->get('text_select')); foreach ($results as $key => $type) { // allowed field types if (in_array($key, array('I', 'T', 'S', 'M', 'R', 'C'))) { $element_types[$key] = $type['type']; } } $form = $params['aform']; $attribute_manager = $params['attribute_manager']; $this->data['form']['fields']['element_type'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'element_type', 'value' => $this->data['element_type'], 'required' => true, 'options' => $element_types)); $this->data['form']['fields']['sort_order'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'sort_order', 'value' => $this->data['sort_order'], 'style' => 'small-field')); $this->data['form']['fields']['show_to_customer'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'settings[show_to_customer]', 'value' => 1, 'checked' => $this->data['settings'] && $this->data['settings']['show_to_customer'] ? true : false, 'style' => 'btn_switch')); //Build atribute values part of the form if ($this->request->get['attribute_id']) { $this->data['child_count'] = $attribute_manager->totalChildren($this->request->get['attribute_id']); if ($this->data['child_count'] > 0) { $children_attr = $attribute_manager->getAttributes(array(), 0, $this->request->get['attribute_id']); foreach ($children_attr as $attr) { $this->data['children'][] = array('name' => $attr['name'], 'link' => $this->html->getSecureURL('catalog/attribute/update', '&attribute_id=' . $attr['attribute_id'])); } } $attribute_values = $attribute_manager->getAttributeValues($this->request->get['attribute_id']); foreach ($attribute_values as $atr_val) { $atr_val_id = $atr_val['attribute_value_id']; $attributes_fields[$atr_val_id]['sort_order'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'sort_orders[' . $atr_val_id . ']', 'value' => $atr_val['sort_order'], 'style' => 'small-field')); $attributes_fields[$atr_val_id]['values'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'values[' . $atr_val_id . ']', 'value' => $atr_val['value'], 'style' => 'medium-field')); $attributes_fields[$atr_val_id]['attribute_value_ids'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'attribute_value_ids[' . $atr_val_id . ']', 'value' => $atr_val_id, 'style' => 'medium-field')); } } if (!$attributes_fields) { $attributes_fields[0]['sort_order'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'sort_orders[]', 'value' => '', 'style' => 'small-field no-save')); $attributes_fields[0]['values'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'values[]', 'value' => '', 'style' => 'medium-field no-save')); $attributes_fields[0]['attribute_value_ids'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'attribute_value_ids[' . $atr_val_id . ']', 'value' => 'new', 'style' => 'medium-field')); } $this->data['form']['attribute_values'] = $attributes_fields; $this->view->batchAssign($this->data); //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->processTemplate('responses/catalog/global_attribute_product_option_subform.tpl'); }
/** * Collect product information for cart based on user selections * Function can be used to get totals and other product information * (based on user selection) as it is before getting into cart or after * @param int $product_id * @param int $quantity * @param array $options * @return array */ public function buildProductDetails($product_id, $quantity = 0, $options = array()) { if (!has_value($product_id) || !is_numeric($product_id) || $quantity == 0) { return array(); } $stock = TRUE; $this->load->model('catalog/product'); $elements_with_options = HtmlElementFactory::getElementsWithOptions(); $product_query = $this->model_catalog_product->getProductDataForCart($product_id); if (count($product_query) <= 0 || $product_query['call_to_order']) { return array(); } $option_price = 0; $option_data = array(); $groups = array(); //Process each option and value foreach ($options as $product_option_id => $product_option_value_id) { //skip empty values if ($product_option_value_id == '' || is_array($product_option_value_id) && !$product_option_value_id) { continue; } //Detect option element type. If single value (text, input) process diferently. $option_attribute = $this->attribute->getAttributeByProductOptionId($product_option_id); if ($option_attribute) { $element_type = $option_attribute['element_type']; $option_query['name'] = $option_attribute['name']; } else { //Not global attribute based option, select element type from options table $option_query = $this->model_catalog_product->getProductOption($product_id, $product_option_id); $element_type = $option_query['element_type']; } if (!in_array($element_type, $elements_with_options)) { //This is single value element, get all values and expect only one $option_value_query = $this->model_catalog_product->getProductOptionValues($product_id, $product_option_id); $option_value_query = $option_value_query[0]; //Set value from input $option_value_query['name'] = $this->db->escape($options[$product_option_id]); } else { //is multivalue option type if (is_array($product_option_value_id)) { $option_value_queries = array(); foreach ($product_option_value_id as $val_id) { $option_value_queries[$val_id] = $this->model_catalog_product->getProductOptionValue($product_id, $val_id); } } else { $option_value_query = $this->model_catalog_product->getProductOptionValue($product_id, (int) $product_option_value_id); } } if ($option_value_query) { //if group option load price from parent value if ($option_value_query['group_id'] && !in_array($option_value_query['group_id'], $groups)) { $group_value_query = $this->model_catalog_product->getProductOptionValue($product_id, $option_value_query['group_id']); $option_value_query['prefix'] = $group_value_query['prefix']; $option_value_query['price'] = $group_value_query['price']; $groups[] = $option_value_query['group_id']; } $option_data[] = array('product_option_value_id' => $option_value_query['product_option_value_id'], 'name' => $option_query['name'], 'value' => $option_value_query['name'], 'prefix' => $option_value_query['prefix'], 'price' => $option_value_query['price'], 'sku' => $option_value_query['sku'], 'weight' => $option_value_query['weight'], 'weight_type' => $option_value_query['weight_type']); //check if need to track stock and we have it if ($option_value_query['subtract'] && $option_value_query['quantity'] < $quantity) { $stock = FALSE; } $op_stock_trackable += $option_value_query['subtract']; unset($option_value_query); } else { if ($option_value_queries) { foreach ($option_value_queries as $item) { $option_data[] = array('product_option_value_id' => $item['product_option_value_id'], 'name' => $option_query['name'], 'value' => $item['name'], 'prefix' => $item['prefix'], 'price' => $item['price'], 'sku' => $item['sku'], 'weight' => $item['weight'], 'weight_type' => $item['weight_type']); //check if need to track stock and we have it if ($item['subtract'] && $item['quantity'] < $quantity) { $stock = FALSE; } $op_stock_trackable += $option_value_query['subtract']; } unset($option_value_queries); } } } // end of options build //needed for promotion $discount_quantity = 0; // this is used to calculate total QTY of 1 product in the cart // check is product is in cart and calculate quantity to define item price with product discount foreach ($this->session->data['cart'] as $k => $v) { $array2 = explode(':', $k); if ($array2[0] == $product_id) { $discount_quantity += $v['qty']; } } if (!$discount_quantity) { $discount_quantity = $quantity; } //Apply group and quantity discount first and if non, reply product discount $price = $this->promotion->getProductQtyDiscount($product_id, $discount_quantity); if (!$price) { $price = $this->promotion->getProductSpecial($product_id); } //Still no special price, use regulr price if (!$price) { $price = $product_query['price']; } foreach ($option_data as $item) { if ($item['prefix'] == '%') { $option_price += $price * $item['price'] / 100; } else { $option_price += $item['price']; } } // product downloads $download_data = $this->download->getProductOrderDownloads($product_id); //check if we need to check main product stock. Do only if no stock trakable options selected if (!$op_stock_trackable && $product_query['subtract'] && $product_query['quantity'] < $quantity) { $stock = FALSE; } $result = array('product_id' => $product_query['product_id'], 'name' => $product_query['name'], 'model' => $product_query['model'], 'shipping' => $product_query['shipping'], 'option' => $option_data, 'download' => $download_data, 'quantity' => $quantity, 'minimum' => $product_query['minimum'], 'maximum' => $product_query['maximum'], 'stock' => $stock, 'price' => $price + $option_price, 'total' => ($price + $option_price) * $quantity, 'tax_class_id' => $product_query['tax_class_id'], 'weight' => $product_query['weight'], 'weight_class' => $product_query['weight_class'], 'length' => $product_query['length'], 'width' => $product_query['width'], 'height' => $product_query['height'], 'length_class' => $product_query['length_class'], 'ship_individually' => $product_query['ship_individually'], 'shipping_price' => $product_query['shipping_price'], 'free_shipping' => $product_query['free_shipping'], 'sku' => $product_query['sku']); return $result; }