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->loadModel('tool/seo_url'); $this->loadLanguage('total/total'); $this->data['heading_title'] = $this->language->get('heading_title'); $this->data['text_subtotal'] = $this->language->get('text_subtotal'); $this->data['text_empty'] = $this->language->get('text_empty'); $this->data['text_remove'] = $this->language->get('text_remove'); $this->data['text_confirm'] = $this->language->get('text_confirm'); $this->data['text_view'] = $this->language->get('text_view'); $this->data['text_checkout'] = $this->language->get('text_checkout'); $this->data['text_items'] = $this->language->get('text_items'); $this->data['text_total'] = $this->language->get('text_total'); $this->data['view'] = $this->html->getURL('checkout/cart'); $this->data['remove'] = $this->html->getURL('r/checkout/cart'); $this->data['checkout'] = $this->html->getURL('checkout/shipping'); $products = array(); $qty = 0; $resource = new AResource('image'); foreach ($this->cart->getProducts() as $result) { $option_data = array(); $thumbnail = $resource->getMainThumb('products', $result['product_id'], $this->config->get('config_image_additional_width'), $this->config->get('config_image_additional_width'), true); foreach ($result['option'] as $option) { if ($option['element_type'] == 'H') { continue; } //hide hidden options $value = $option['value']; // hide binary value for checkbox if ($option['element_type'] == 'C' && in_array($value, array(0, 1))) { $value = ''; } // strip long textarea value if ($option['element_type'] == 'T') { $title = strip_tags($value); $title = str_replace('\\r\\n', "\n", $title); $value = str_replace('\\r\\n', "\n", $value); if (mb_strlen($value) > 64) { $value = mb_substr($value, 0, 64) . '...'; } } $option_data[] = array('name' => $option['name'], 'value' => $value, 'title' => $title); } $qty += $result['quantity']; $products[] = array('key' => $result['key'], 'name' => $result['name'], 'option' => $option_data, 'quantity' => $result['quantity'], 'stock' => $result['stock'], 'price' => $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))), 'href' => $this->html->getSEOURL('product/product', '&product_id=' . $result['product_id'], true), 'thumb' => $thumbnail); } $this->data['products'] = $products; $this->data['total_qty'] = $qty; $display_totals = $this->cart->buildTotalDisplay(); $this->data['totals'] = $display_totals['total_data']; $this->data['subtotal'] = $this->currency->format($display_totals['total']); $this->data['taxes'] = $display_totals['taxes']; $this->data['ajax'] = $this->config->get('cart_ajax'); $this->view->batchAssign($this->data); $this->processTemplate(); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('catalog/product'); $this->loadModel('catalog/product'); $this->data['product'] = $product_info = $this->model_catalog_product->getProduct($this->request->get['product_id']); $this->data['product']['product_id'] = '#' . $this->data['product']['product_id']; $this->data['product']['price'] = $this->currency->format($this->data['product']['price']); $this->data['product']['condition'] = $this->model_catalog_product->getProductCondition($this->request->get['product_id']); $this->data['text_product_condition'] = $this->language->get('text_product_condition'); $this->data['text_product_available'] = $this->language->get('text_product_available'); $resource = new AResource('image'); $thumbnail = $resource->getMainThumb('products', $this->request->get['product_id'], $this->config->get('config_image_grid_width'), $this->config->get('config_image_grid_height'), true); $this->data['product']['image'] = $thumbnail; $this->data['product']['preview'] = $this->html->getCatalogURL('product/product', '&product_id=' . $product_info['product_id']); $this->loadModel('sale/order'); $this->data['product']['orders'] = $this->model_sale_order->getOrderTotalWithProduct($product_info['product_id']); $this->data['product']['orders_url'] = $this->html->getSecureURL('sale/order', '&product_id=' . $product_info['product_id']); $this->view->assign('help_url', $this->gen_help_url('product_summary')); $this->view->batchAssign($this->data); $this->processTemplate('pages/catalog/product_summary.tpl'); //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('catalog/manufacturer'); $this->loadModel('catalog/manufacturer'); $this->loadModel('tool/image'); //Prepare filter config $grid_filter_params = array('name'); $filter = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params)); $filter_data = $filter->getFilterData(); $total = $this->model_catalog_manufacturer->getTotalManufacturers($filter_data); $response = new stdClass(); $response->page = $filter->getParam('page'); $response->total = $filter->calcTotalPages($total); $response->records = $total; $results = $this->model_catalog_manufacturer->getManufacturers($filter_data); $resource = new AResource('image'); $i = 0; foreach ($results as $result) { $thumbnail = $resource->getMainThumb('manufacturers', $result['manufacturer_id'], (int) $this->config->get('config_image_grid_width'), (int) $this->config->get('config_image_grid_height'), true); $response->rows[$i]['id'] = $result['manufacturer_id']; $response->rows[$i]['cell'] = array($thumbnail['thumb_html'], $this->html->buildInput(array('name' => 'name[' . $result['manufacturer_id'] . ']', 'value' => $result['name'])), $this->html->buildInput(array('name' => 'sort_order[' . $result['manufacturer_id'] . ']', 'value' => $result['sort_order']))); $i++; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->data['heading_title'] = $this->language->get('heading_title'); $this->loadModel('catalog/product'); $this->loadModel('catalog/review'); $this->loadModel('tool/seo_url'); $this->loadModel('tool/image'); $promoton = new APromotion(); $this->data['button_add_to_cart'] = $this->language->get('button_add_to_cart'); $this->data['products'] = array(); $results = $promoton->getProductSpecials('pd.name', 'ASC', 0, $this->config->get('config_special_limit')); $resource = new AResource('image'); foreach ($results as $result) { $thumbnail = $resource->getMainThumb('products', $result['product_id'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'), true); if ($this->config->get('enable_reviews')) { $rating = $this->model_catalog_review->getAverageRating($result['product_id']); } else { $rating = false; } $special = FALSE; $discount = $promoton->getProductDiscount($result['product_id']); if ($discount) { $price = $this->currency->format($this->tax->calculate($discount, $result['tax_class_id'], $this->config->get('config_tax'))); } else { $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))); $special = $promoton->getProductSpecial($result['product_id']); if ($special) { $special = $this->currency->format($this->tax->calculate($special, $result['tax_class_id'], $this->config->get('config_tax'))); } } $options = $this->model_catalog_product->getProductOptions($result['product_id']); if ($options) { $add = $this->html->getSEOURL('product/product', '&product_id=' . $result['product_id'], '&encode'); } else { if ($this->config->get('config_cart_ajax')) { $add = '#'; } else { $add = $this->html->getSecureURL('checkout/cart', '&product_id=' . $result['product_id'], '&encode'); } } $this->data['products'][] = array('product_id' => $result['product_id'], 'name' => $result['name'], 'model' => $result['model'], 'rating' => $rating, 'stars' => sprintf($this->language->get('text_stars'), $rating), 'price' => $price, 'call_to_order' => $result['call_to_order'], 'options' => $options, 'special' => $special, 'thumb' => $thumbnail, 'href' => $this->html->getSEOURL('product/product', '&product_id=' . $result['product_id'], '&encode'), 'add' => $add); } if ($this->config->get('config_customer_price')) { $this->data['display_price'] = TRUE; } elseif ($this->customer->isLogged()) { $this->data['display_price'] = TRUE; } else { $this->data['display_price'] = FALSE; } $this->data['review_status'] = $this->config->get('enable_reviews'); // framed needs to show frames for generic block. //If tpl used by listing block framed was set by listing block settings $this->data['block_framed'] = true; $this->view->batchAssign($this->data); $this->processTemplate(); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('catalog/review'); $this->loadModel('catalog/review'); $this->loadModel('tool/image'); //Prepare filter config $filter_params = array('product_id', 'status'); $grid_filter_params = array('name', 'author'); $filter_form = new AFilter(array('method' => 'get', 'filter_params' => $filter_params)); $filter_grid = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params)); $total = $this->model_catalog_review->getTotalReviews(array_merge($filter_form->getFilterData(), $filter_grid->getFilterData())); $response = new stdClass(); $response->page = $filter_grid->getParam('page'); $response->total = $filter_grid->calcTotalPages($total); $response->records = $total; $results = $this->model_catalog_review->getReviews(array_merge($filter_form->getFilterData(), $filter_grid->getFilterData())); $resource = new AResource('image'); $i = 0; foreach ($results as $result) { $thumbnail = $resource->getMainThumb('products', $result['product_id'], $this->config->get('config_image_grid_width'), $this->config->get('config_image_grid_height'), true); $response->rows[$i]['id'] = $result['review_id']; $response->rows[$i]['cell'] = array($thumbnail['thumb_html'], $result['name'], $result['author'], $result['rating'], $this->html->buildCheckbox(array('name' => 'status[' . $result['review_id'] . ']', 'value' => $result['status'], 'style' => 'btn_switch')), dateISO2Display($result['date_added'], $this->language->get('date_format_short'))); $i++; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('catalog/category'); $this->loadModel('catalog/category'); $this->loadModel('catalog/product'); $this->loadModel('tool/image'); //Prepare filter config $grid_filter_params = array('name'); $filter = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params)); $filter_data = $filter->getFilterData(); //Add custom params $filter_data['parent_id'] = isset($this->request->get['parent_id']) ? $this->request->get['parent_id'] : 0; $new_level = 0; //get all leave categories $leafnodes = $this->model_catalog_category->getLeafCategories(); if ($this->request->post['nodeid']) { $sort = $filter_data['sort']; $order = $filter_data['order']; //reset filter to get only parent category $filter_data = array(); $filter_data['sort'] = $sort; $filter_data['order'] = $order; $filter_data['parent_id'] = (int) $this->request->post['nodeid']; $new_level = (int) $this->request->post["n_level"] + 1; } $total = $this->model_catalog_category->getTotalCategories($filter_data); $response = new stdClass(); $response->page = $filter->getParam('page'); $response->total = $filter->calcTotalPages($total); $response->records = $total; $response->userdata = new stdClass(); $results = $this->model_catalog_category->getCategoriesData($filter_data); $i = 0; $resource = new AResource('image'); foreach ($results as $result) { $thumbnail = $resource->getMainThumb('categories', $result['category_id'], (int) $this->config->get('config_image_grid_width'), (int) $this->config->get('config_image_grid_height'), true); $response->rows[$i]['id'] = $result['category_id']; $cnt = $this->model_catalog_category->getCategoriesData(array('parent_id' => $result['category_id']), 'total_only'); if (!$result['products_count']) { $products_count = $result['products_count']; } else { $products_count = $this->html->buildButton(array('name' => 'view products', 'text' => $result['products_count'], 'style' => 'button2', 'href' => $this->html->getSecureURL('catalog/product', '&category=' . $result['category_id']), 'title' => $this->language->get('text_view') . ' ' . $this->language->get('tab_product'), 'target' => '_blank')); } //tree grid structure if ($this->config->get('config_show_tree_data')) { $name_lable = '<label style="white-space: nowrap;">' . $result['basename'] . '</label>'; } else { $name_lable = '<label style="white-space: nowrap;">' . str_replace($result['basename'], '', $result['name']) . '</label>' . $this->html->buildInput(array('name' => 'category_description[' . $result['category_id'] . '][' . $this->session->data['content_language_id'] . '][name]', 'value' => $result['basename'], 'attr' => ' maxlength="32" ')); } $response->rows[$i]['cell'] = array($thumbnail['thumb_html'], $name_lable, $this->html->buildInput(array('name' => 'sort_order[' . $result['category_id'] . ']', 'value' => $result['sort_order'])), $this->html->buildCheckbox(array('name' => 'status[' . $result['category_id'] . ']', 'value' => $result['status'], 'style' => 'btn_switch')), $products_count, $cnt . ($cnt ? ' <a class="btn_action btn_grid grid_action_expand" href="#" rel="parent_id=' . $result['category_id'] . '" title="' . $this->language->get('text_view') . '">' . '<img src="' . RDIR_TEMPLATE . 'image/icons/icon_grid_expand.png" alt="' . $this->language->get('text_view') . '" /></a>' : ''), 'action', $new_level, $filter_data['parent_id'] ? $filter_data['parent_id'] : NULL, $result['category_id'] == $leafnodes[$result['category_id']] ? true : false, false); $i++; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('blocks/latest'); $this->view->assign('heading_title', $this->language->get('heading_title')); $this->loadModel('catalog/product'); $this->loadModel('catalog/review'); $this->loadModel('tool/image'); $this->view->assign('button_add_to_cart', $this->language->get('button_add_to_cart')); $this->data['products'] = array(); $results = $this->model_catalog_product->getLatestProducts($this->config->get('config_latest_limit')); foreach ($results as $result) { $product_ids[] = $result['product_id']; } $products_info = $this->model_catalog_product->getProductsAllInfo($product_ids); $resource = new AResource('image'); foreach ($results as $result) { $thumbnail = $resource->getMainThumb('products', $result['product_id'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'), true); $rating = $products_info[$result['product_id']]['rating']; $special = FALSE; $discount = $products_info[$result['product_id']]['discount']; if ($discount) { $price = $this->currency->format($this->tax->calculate($discount, $result['tax_class_id'], $this->config->get('config_tax'))); } else { $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))); $special = $products_info[$result['product_id']]['special']; if ($special) { $special = $this->currency->format($this->tax->calculate($special, $result['tax_class_id'], $this->config->get('config_tax'))); } } $options = $products_info[$result['product_id']]['options']; if ($options) { $add = $this->html->getSEOURL('product/product', '&product_id=' . $result['product_id'], '&encode'); } else { if ($this->config->get('config_cart_ajax')) { $add = '#'; } else { $add = $this->html->getSecureURL('checkout/cart', '&product_id=' . $result['product_id'], '&encode'); } } $this->data['products'][] = array('product_id' => $result['product_id'], 'name' => $result['name'], 'model' => $result['model'], 'rating' => $rating, 'stars' => sprintf($this->language->get('text_stars'), $rating), 'price' => $price, 'call_to_order' => $result['call_to_order'], 'options' => $options, 'special' => $special, 'thumb' => $thumbnail, 'href' => $this->html->getSEOURL('product/product', '&product_id=' . $result['product_id'], '&encode'), 'add' => $add); } $this->view->assign('products', $this->data['products']); if ($this->config->get('config_customer_price')) { $display_price = TRUE; } elseif ($this->customer->isLogged()) { $display_price = TRUE; } else { $display_price = FALSE; } $this->view->assign('block_framed', true); $this->view->assign('display_price', $display_price); $this->view->assign('review_status', $this->config->get('enable_reviews')); $this->processTemplate(); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('blocks/manufacturer'); $this->view->assign('heading_title', $this->language->get('heading_title')); $this->view->assign('text_select', $this->language->get('text_select')); //For product page show only brand icon if (isset($this->request->get['product_id']) && is_int($this->request->get['product_id'])) { $product_id = $this->request->get['product_id']; $this->view->assign('product_id', $product_id); $result = $this->model_catalog_manufacturer->getManufacturerByProductId($product_id); $manuf_detls = $result[0]; $resource = new AResource('image'); $thumbnail = $resource->getMainThumb('manufacturers', $manuf_detls['manufacturer_id'], (int) $this->config->get('config_image_grid_width'), (int) $this->config->get('config_image_grid_height'), true); $manufacturer = array('manufacturer_id' => $manuf_detls['manufacturer_id'], 'name' => $manuf_detls['name'], 'href' => $this->html->getSEOURL('product/manufacturer', '&manufacturer_id=' . $manuf_detls['manufacturer_id'], '&encode'), 'icon' => $thumbnail['thumb_url']); $this->view->assign('manufacturer', $manufacturer); } else { if (isset($this->request->get['manufacturer_id']) && is_int($this->request->get['manufacturer_id'])) { $manufacturer_id = $this->request->get['manufacturer_id']; } else { $manufacturer_id = 0; } $this->view->assign('manufacturer_id', $manufacturer_id); $this->loadModel('catalog/manufacturer'); $manufacturers = array(); $results = $this->model_catalog_manufacturer->getManufacturers(); $thumbnail_list = $this->cache->get('manufacturer.block.thumbnals', '', (int) $this->config->get('config_store_id')); $is_cache_exists = $this->cache->exists('manufacturer.block.thumbnals', '', (int) $this->config->get('config_store_id')); $resource = new AResource('image'); foreach ($results as $result) { if (!$is_cache_exists) { $thumbnail = $resource->getMainThumb('manufacturers', $result['manufacturer_id'], (int) $this->config->get('config_image_grid_width'), (int) $this->config->get('config_image_grid_height'), true); $thumbnails_cache[$result['manufacturer_id']] = $thumbnail; } else { if (has_value($thumbnail_list[$result['manufacturer_id']])) { $thumbnail = $thumbnail_list[$result['manufacturer_id']]; } } $manufacturers[] = array('manufacturer_id' => $result['manufacturer_id'], 'name' => $result['name'], 'href' => $this->html->getSEOURL('product/manufacturer', '&manufacturer_id=' . $result['manufacturer_id'], '&encode'), 'icon' => $thumbnail); } if (!$is_cache_exists) { $this->cache->set('manufacturer.block.thumbnals', $thumbnails_cache, '', (int) $this->config->get('config_store_id')); } $this->view->assign('manufacturers', $manufacturers); } // framed needs to show frames for generic block. //If tpl used by listing block framed was set by listing block settings $this->view->assign('block_framed', true); $this->processTemplate('blocks/manufacturer.tpl'); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('catalog/product'); $this->loadModel('catalog/product'); $this->loadModel('tool/image'); //Clean up parametres if needed if (isset($this->request->get['keyword']) && $this->request->get['keyword'] == $this->language->get('filter_product')) { unset($this->request->get['keyword']); } if (isset($this->request->get['pfrom']) && $this->request->get['pfrom'] == 0) { unset($this->request->get['pfrom']); } if (isset($this->request->get['pto']) && $this->request->get['pto'] == $this->language->get('filter_price_max')) { unset($this->request->get['pto']); } //Prepare filter config $filter_params = array('category', 'status', 'keyword', 'match', 'pfrom', 'pto'); $grid_filter_params = array('name', 'sort_order', 'model'); $filter_form = new AFilter(array('method' => 'get', 'filter_params' => $filter_params)); $filter_grid = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params)); $data = array_merge($filter_form->getFilterData(), $filter_grid->getFilterData()); $total = $this->model_catalog_product->getTotalProducts($data); $response = new stdClass(); $response->page = $filter_grid->getParam('page'); $response->total = $filter_grid->calcTotalPages($total); $response->records = $total; $response->userdata = new stdClass(); $response->userdata->classes = array(); $results = $this->model_catalog_product->getProducts($data); $resource = new AResource('image'); $i = 0; foreach ($results as $result) { $thumbnail = $resource->getMainThumb('products', $result['product_id'], (int) $this->config->get('config_image_grid_width'), (int) $this->config->get('config_image_grid_height'), true); $response->rows[$i]['id'] = $result['product_id']; if (dateISO2Int($result['date_available']) > time()) { $response->userdata->classes[$result['product_id']] = 'warning'; } if ($result['call_to_order'] > 0) { $price = $this->language->get('text_call_to_order'); } else { $price = $this->html->buildInput(array('name' => 'price[' . $result['product_id'] . ']', 'value' => moneyDisplayFormat($result['price']))); } $response->rows[$i]['cell'] = array($thumbnail['thumb_html'], $this->html->buildInput(array('name' => 'product_description[' . $result['product_id'] . '][name]', 'value' => $result['name'])), $this->html->buildInput(array('name' => 'model[' . $result['product_id'] . ']', 'value' => $result['model'])), $price, $this->html->buildInput(array('name' => 'quantity[' . $result['product_id'] . ']', 'value' => $result['quantity'])), $this->html->buildCheckbox(array('name' => 'status[' . $result['product_id'] . ']', 'value' => $result['status'], 'style' => 'btn_switch'))); $i++; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); }
public function getCategories($parent_categ_id = 0) { $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadModel('catalog/category'); $resource = new AResource('image'); $results = $this->model_catalog_category->getCategories($parent_categ_id); foreach ($results as $result) { $thumbnail = $resource->getMainThumb('categories', $result['category_id'], $this->config->get('config_image_category_width'), $this->config->get('config_image_category_height'), true); $categories[] = array('name' => $result['name'], 'category_id' => $result['category_id'], 'sort_order' => $result['sort_order'], 'thumb' => $thumbnail['thumb_url']); } $this->extensions->hk_UpdateData($this, __FUNCTION__); return $categories; }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadModel('tool/seo_url'); $this->loadLanguage('total/total'); $this->data['heading_title'] = $this->language->get('heading_title'); $this->data['text_subtotal'] = $this->language->get('text_subtotal'); $this->data['text_empty'] = $this->language->get('text_empty'); $this->data['text_remove'] = $this->language->get('text_remove'); $this->data['text_confirm'] = $this->language->get('text_confirm'); $this->data['text_view'] = $this->language->get('text_view'); $this->data['text_checkout'] = $this->language->get('text_checkout'); $this->data['text_items'] = $this->language->get('text_items'); $this->data['text_total'] = $this->language->get('text_total'); $this->data['view'] = $this->html->getURL('checkout/cart'); $this->data['remove'] = $this->html->getURL('r/checkout/cart'); $this->data['checkout'] = $this->html->getURL('checkout/shipping'); $products = array(); $qty = 0; $resource = new AResource('image'); foreach ($this->cart->getProducts() as $result) { $option_data = array(); $thumbnail = $resource->getMainThumb('products', $result['product_id'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'), true); foreach ($result['option'] as $option) { $option_data[] = array('name' => $option['name'], 'value' => $option['value']); } $qty += $result['quantity']; $products[] = array('key' => $result['key'], 'name' => $result['name'], 'option' => $option_data, 'quantity' => $result['quantity'], 'stock' => $result['stock'], 'price' => $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))), 'href' => $this->html->getSEOURL('product/product', '&product_id=' . $result['product_id'], true), 'thumb' => $thumbnail); } $this->data['products'] = $products; $this->data['total_qty'] = $qty; $display_totals = $this->cart->buildTotalDisplay(); $this->data['totals'] = $display_totals['total_data']; $this->data['subtotal'] = $this->currency->format($this->tax->calculate($display_totals['total'], $result['tax_class_id'], $this->config->get('config_tax'))); $this->data['taxes'] = $display_totals['taxes']; $this->data['ajax'] = $this->config->get('cart_ajax'); $this->view->batchAssign($this->data); $this->processTemplate(); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function getCategoryDetails($category_id) { $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadModel('catalog/category'); $this->loadModel('catalog/product'); $this->loadModel('tool/image'); $category_info = $this->model_catalog_category->getCategory($category_id); if (!$category_info) { return array('message' => 'category not found'); } $resource = new AResource('image'); $thumbnail = $resource->getMainThumb('categories', $category_id, $this->config->get('config_image_category_width'), $this->config->get('config_image_category_height')); $category_info['thumbnail'] = $category_info['tumbnail'] = $thumbnail['thumb_url']; //Process data for category $category_info['description'] = html_entity_decode($category_info['description'], ENT_QUOTES, 'UTF-8'); $category_info['total_products'] = $this->model_catalog_product->getTotalProductsByCategoryId($category_id); $category_info['total_subcategories'] = $this->model_catalog_category->getTotalCategoriesByCategoryId($category_id); if ($category_info['total_products']) { $category_info['subcategories'] = $this->getCategories($category_id); } $this->extensions->hk_UpdateData($this, __FUNCTION__); return $category_info; }
public function get() { $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadModel('catalog/product'); $filter_data = array('method' => 'get'); $filter = new AFilter($filter_data); $filters = $filter->getFilterData(); $results = $this->model_catalog_product->getLatestProducts($filters['limit']); $response = new stdClass(); $response->page = $filter->getParam('page'); $response->total = $total_pages; $response->records = $filters['limit']; $response->limit = $filters['limit']; $response->sidx = $filters['sort']; $response->sord = $filters['order']; $response->params = $filters; $i = 0; if ($results) { $resource = new AResource('image'); foreach ($results as $result) { $thumbnail = $resource->getMainThumb('products', $result['product_id'], $this->config->get('config_image_thumb_width'), $this->config->get('config_image_thumb_height'), true); $response->rows[$i]['id'] = $result['product_id']; $response->rows[$i]['cell']['thumb'] = $thumbnail['thumb_url']; $response->rows[$i]['cell']['name'] = $result['name']; $response->rows[$i]['cell']['description'] = $result['description']; $response->rows[$i]['cell']['model'] = $result['model']; $response->rows[$i]['cell']['price'] = $this->currency->convert($result['final_price'], $this->config->get('config_currency'), $this->currency->getCode()); $response->rows[$i]['cell']['currency_code'] = $this->currency->getCode(); $response->rows[$i]['cell']['rating'] = $result['rating']; $i++; } } $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->rest->setResponseData($response); $this->rest->sendResponse(200); }
public function main() { $error_msg = array(); //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); if ($this->request->server['REQUEST_METHOD'] == 'GET' && isset($this->request->get['product_id'])) { if (isset($this->request->get['option'])) { $option = $this->request->get['option']; } else { $option = array(); } if (isset($this->request->get['quantity'])) { $quantity = $this->request->get['quantity']; } else { $quantity = 1; } unset($this->session->data['shipping_methods']); unset($this->session->data['shipping_method']); unset($this->session->data['payment_methods']); unset($this->session->data['payment_method']); $this->cart->add($this->request->get['product_id'], $quantity, $option); $this->redirect($this->html->getSecureURL('checkout/cart')); } else { if ($this->request->server['REQUEST_METHOD'] == 'POST') { //if this is coupon, validate and apply if (isset($this->request->post['coupon']) && $this->_validateCoupon()) { $this->session->data['coupon'] = $this->request->post['coupon']; $this->data['success'] = $this->session->data['success'] = $this->language->get('text_coupon_success'); //process data $this->extensions->hk_ProcessData($this); } if ($this->error['error_warning']) { $error_msg[] = $this->error['error_warning']; } if (isset($this->request->post['quantity'])) { if (!is_array($this->request->post['quantity'])) { $this->loadModel('catalog/product'); $product_id = $this->request->post['product_id']; if (isset($this->request->post['option'])) { $options = $this->request->post['option']; } else { $options = array(); } if (has_value($this->request->files['option']['name'])) { $am = new AAttribute('product_option'); $fm = new AFile(); foreach ($this->request->files['option']['name'] as $id => $name) { $attribute_data = $am->getAttributeByProductOptionId($id); $file_path_info = $fm->getUploadFilePath($attribute_data['settings']['directory'], $name); $options[$id] = $file_path_info['name']; if ($text_errors = $this->model_catalog_product->validateProductOptions($product_id, $options)) { $this->session->data['error'] = implode('<br>', $text_errors); $this->redirect($_SERVER['HTTP_REFERER']); } elseif (!has_value($name)) { continue; } $file_data = array('option_id' => $id, 'name' => $file_path_info['name'], 'path' => $file_path_info['path'], 'type' => $this->request->files['option']['type'][$id], 'tmp_name' => $this->request->files['option']['tmp_name'][$id], 'error' => $this->request->files['option']['error'][$id], 'size' => $this->request->files['option']['size'][$id]); $file_errors = $fm->validateFileOption($attribute_data['settings'], $file_data); if (has_value($file_errors)) { $this->session->data['error'] = implode('<br/>', $file_errors); $this->redirect($_SERVER['HTTP_REFERER']); } else { $result = move_uploaded_file($file_data['tmp_name'], $file_path_info['path']); if (!$result || $this->request->files['package_file']['error']) { $this->session->data['error'] .= '<br>Error: ' . getTextUploadError($this->request->files['option']['error'][$id]); $this->redirect($_SERVER['HTTP_REFERER']); } } $dataset = new ADataset('file_uploads', 'admin'); $dataset->addRows(array('date_added' => date("Y-m-d H:i:s", time()), 'name' => $file_path_info['name'], 'type' => $file_data['type'], 'section' => 'product_option', 'section_id' => $attribute_data['attribute_id'], 'path' => $file_path_info['path'])); } } if ($text_errors = $this->model_catalog_product->validateProductOptions($product_id, $options)) { $this->session->data['error'] = $text_errors; //send options values back via _GET $url = '&' . http_build_query(array('option' => $this->request->post['option'])); $this->redirect($this->html->getSecureURL('product/product', '&product_id=' . $this->request->post['product_id'] . $url)); } $this->cart->add($this->request->post['product_id'], $this->request->post['quantity'], $options); } else { foreach ($this->request->post['quantity'] as $key => $value) { $this->cart->update($key, $value); } } unset($this->session->data['shipping_methods']); unset($this->session->data['shipping_method']); unset($this->session->data['payment_methods']); unset($this->session->data['payment_method']); #upate min and max $this->cart->setMinQty(); $this->cart->setMaxQty(); } if (isset($this->request->post['remove'])) { foreach (array_keys($this->request->post['remove']) as $key) { $this->cart->remove($key); } } if (isset($this->request->post['redirect'])) { $this->session->data['redirect'] = $this->request->post['redirect']; } if (isset($this->request->post['quantity']) || isset($this->request->post['remove'])) { unset($this->session->data['shipping_methods']); unset($this->session->data['shipping_method']); unset($this->session->data['payment_methods']); unset($this->session->data['payment_method']); $this->redirect($this->html->getSecureURL('checkout/cart')); } } } $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->cart->hasProducts()) { if (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout')) { $error_msg[] = $this->language->get('error_stock'); } $this->loadModel('tool/seo_url'); $products = array(); $resource = new AResource('image'); $form = new AForm(); $form->setForm(array('form_name' => 'cart')); $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'cart', 'action' => $this->html->getSecureURL('checkout/cart'))); $cart_products = $this->cart->getProducts(); foreach ($cart_products as $result) { $option_data = array(); $thumbnail = $resource->getMainThumb('products', $result['product_id'], (int) $this->config->get('config_image_cart_width'), (int) $this->config->get('config_image_cart_height'), true); foreach ($result['option'] as $option) { $option_data[] = array('name' => $option['name'], 'value' => $option['value']); } $products[] = array('remove' => $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'remove[' . $result['key'] . ']')), 'key' => $result['key'], 'name' => $result['name'], 'model' => $result['model'], 'thumb' => $thumbnail, 'option' => $option_data, 'quantity' => $form->getFieldHtml(array('type' => 'input', 'name' => 'quantity[' . $result['key'] . ']', 'value' => $result['quantity'], 'attr' => ' size="3" ', 'style' => 'short')), 'stock' => $result['stock'], 'price' => $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))), 'total' => $this->currency->format($this->tax->calculate($result['total'], $result['tax_class_id'], $this->config->get('config_tax'))), 'href' => $this->html->getSEOURL('product/product', '&product_id=' . $result['product_id'], true)); } $this->data['products'] = $products; $this->data['form']['update'] = $form->getFieldHtml(array('type' => 'submit', 'name' => $this->language->get('button_update'))); $this->data['form']['checkout'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'checkout', 'text' => $this->language->get('button_checkout'), 'style' => 'button')); if ($this->config->get('config_cart_weight')) { $this->data['weight'] = $this->weight->format($this->cart->getWeight(), $this->config->get('config_weight_class')); } else { $this->data['weight'] = FALSE; } $display_totals = $this->cart->buildTotalDisplay(); $this->data['totals'] = $display_totals['total_data']; 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->data['form']['continue_shopping'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'continue_shopping', 'text' => $this->language->get('button_shopping'), 'style' => 'button', 'href' => $this->data['continue'])); $this->data['checkout'] = $this->html->getSecureURL('checkout/shipping'); #Check if order total max/min is set and met $cf_total_min = $this->config->get('total_order_minimum'); $cf_total_max = $this->config->get('total_order_maximum'); if (!$this->cart->hasMinRequirement()) { $this->data['form']['checkout'] = ''; $error_msg[] = sprintf($this->language->get('error_order_minimum'), $this->currency->format($cf_total_min)); } if (!$this->cart->hasMaxRequirement()) { $this->data['form']['checkout'] = ''; $error_msg[] = sprintf($this->language->get('error_order_maximum'), $this->currency->format($cf_total_max)); } //prepare coupon display if ($this->config->get('config_coupon_on_cart_page')) { $this->view->assign('coupon_status', $this->config->get('coupon_status')); $action = $this->html->getSecureURL('checkout/cart'); $coupon_form = $this->dispatch('blocks/coupon_codes', array('action' => $action)); $this->view->assign('coupon_form', $coupon_form->dispatchGetOutput()); } if ($this->config->get('config_shipping_tax_estimate')) { $form = new AForm(); $form->setForm(array('form_name' => 'estimate')); $this->data['form_estimate']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'estimate', 'action' => $this->html->getSecureURL('checkout/cart'))); $this->data['estimates_enabled'] = true; } //try to get shipping address details if we have them $country_id = $this->config->get('config_country_id'); if ($this->session->data['shipping_address_id']) { $this->loadModel('account/address'); $shipping_address = $this->model_account_address->getAddress($this->session->data['shipping_address_id']); $postcode = $shipping_address['postcode']; $country_id = $shipping_address['country_id']; $zone_id = $shipping_address['zone_id']; } // use default address of customer for estimate form whe shipping address is unknown if (!$zone_id && $this->customer->isLogged()) { $this->loadModel('account/address'); $payment_address = $this->model_account_address->getAddress($this->customer->getAddressId()); $postcode = $payment_address['postcode']; $country_id = $payment_address['country_id']; $zone_id = $payment_address['zone_id']; } if ($this->request->post['postcode']) { $postcode = $this->request->post['postcode']; } if ($this->request->post['country'][0]) { $country_id = $this->request->post['country'][0]; } if ($this->request->post['country_zones'][0]) { $zone_id = $this->request->post['country_zones'][0]; } if ($zone_id) { $this->loadModel('localisation/zone'); $zone_data = $this->model_localisation_zone->getZone($zone_id); } $this->data['form_estimate']['postcode'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'postcode', 'value' => $postcode, 'style' => 'short')); $this->data['form_estimate']['country_zones'] = $form->getFieldHtml(array('type' => 'zones', 'name' => 'country', 'submit_mode' => 'id', 'value' => $country_id, 'zone_name' => $zone_data['name'], 'zone_value' => $zone_id)); $this->data['form_estimate']['submit'] = $form->getFieldHtml(array('type' => 'submit', 'name' => $this->language->get('button_text_estimate'))); $this->view->assign('error_warning', $error_msg); $this->view->setTemplate('pages/checkout/cart.tpl'); } else { $this->data['heading_title'] = $this->language->get('heading_title'); $this->data['text_error'] = $this->language->get('text_error'); $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->view->batchAssign($this->data); $this->processTemplate(); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function files() { $this->data = array(); //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->document->setTitle($this->language->get('heading_title')); if (has_value($this->session->data['error'])) { $this->data['error']['warning'] = $this->session->data['error']; unset($this->session->data['error']); } if (isset($this->request->get['order_id'])) { $order_id = $this->request->get['order_id']; } else { $order_id = 0; } if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->_validateForm()) { if (has_value($this->request->post['downloads'])) { $data = $this->request->post['downloads']; $this->loadModel('catalog/download'); foreach ($data as $order_download_id => $item) { if (isset($item['expire_date'])) { $item['expire_date'] = $item['expire_date'] ? dateDisplay2ISO($item['expire_date'], $this->language->get('date_format_short')) : ''; } $this->model_catalog_download->editOrderDownload($order_download_id, $item); } } //add download to order if (has_value($this->request->post['push'])) { $this->load->library('json'); foreach ($this->request->post['push'] as $order_product_id => $items) { $items = AJson::decode(html_entity_decode($items), true); if ($items) { foreach ($items as $download_id => $info) { $download_info = $this->download->getDownloadInfo($download_id); $download_info['attributes_data'] = serialize($this->download->getDownloadAttributesValues($download_id)); $this->download->addProductDownloadToOrder($order_product_id, $order_id, $download_info); } } } } $this->session->data['success'] = $this->language->get('text_success'); $this->redirect($this->html->getSecureURL('sale/order/files', '&order_id=' . $this->request->get['order_id'])); } $order_info = $this->model_sale_order->getOrder($order_id); $this->data['order_info'] = $order_info; //set content language to order language ID. if ($this->language->getContentLanguageID() != $order_info['language_id']) { //reset content language $this->language->setCurrentContentLanguage($order_info['language_id']); } if (empty($order_info)) { $this->session->data['error'] = $this->language->get('error_order_load'); $this->redirect($this->html->getSecureURL('sale/order')); } $this->document->initBreadcrumb(array('href' => $this->html->getSecureURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE)); $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('sale/order'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: ')); $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('sale/order/files', '&order_id=' . $this->request->get['order_id']), 'text' => $this->language->get('heading_title') . ' #' . $order_info['order_id'], 'separator' => ' :: ')); if (isset($this->session->data['success'])) { $this->data['success'] = $this->session->data['success']; unset($this->session->data['success']); } else { $this->data['success'] = ''; } $this->data['heading_title'] = $this->language->get('heading_title') . ' #' . $order_info['order_id']; $this->data['token'] = $this->session->data['token']; $this->data['invoice'] = $this->html->getSecureURL('sale/invoice', '&order_id=' . (int) $this->request->get['order_id']); $this->data['button_invoice'] = $this->html->buildButton(array('name' => 'btn_invoice', 'text' => $this->language->get('text_invoice'), 'style' => 'button3')); $this->data['invoice_generate'] = $this->html->getSecureURL('sale/invoice/generate'); $this->data['category_products'] = $this->html->getSecureURL('product/product/category'); $this->data['product_update'] = $this->html->getSecureURL('catalog/product/update'); $this->data['order_id'] = $this->request->get['order_id']; $this->data['action'] = $this->html->getSecureURL('sale/order/files', '&order_id=' . $this->request->get['order_id']); $this->data['cancel'] = $this->html->getSecureURL('sale/order'); $this->_initTabs('files'); $this->loadModel('localisation/order_status'); $status = $this->model_localisation_order_status->getOrderStatus($order_info['order_status_id']); if ($status) { $this->data['order_status'] = $status['name']; } else { $this->data['order_status'] = ''; } $this->loadModel('sale/customer_group'); $customer_group_info = $this->model_sale_customer_group->getCustomerGroup($order_info['customer_group_id']); if ($customer_group_info) { $this->data['customer_group'] = $customer_group_info['name']; } else { $this->data['customer_group'] = ''; } $this->data['form_title'] = $this->language->get('edit_title_files'); $this->data['update'] = $this->html->getSecureURL('listing_grid/order/update_field', '&id=' . $this->request->get['order_id']); $form = new AForm('HS'); $form->setForm(array('form_name' => 'orderFrm', 'update' => $this->data['update'])); $this->data['form']['id'] = 'orderFrm'; $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'orderFrm', 'attr' => 'confirm-exit="true"', 'action' => $this->data['action'])); $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_save'), 'style' => 'button1')); $this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'text' => $this->language->get('button_cancel'), 'style' => 'button2')); $this->addChild('pages/sale/order_summary', 'summary_form', 'pages/sale/order_summary.tpl'); /** ORDER DOWNLOADS */ $this->data['downloads'] = array(); $order_downloads = $this->model_sale_order->getOrderDownloads($this->request->get['order_id']); if ($order_downloads) { $rl = new AResource('image'); if (!$this->registry->has('jqgrid_script')) { $locale = $this->session->data['language']; if (!file_exists(DIR_ROOT . '/' . RDIR_TEMPLATE . 'javascript/jqgrid/js/i18n/grid.locale-' . $locale . '.js')) { $locale = 'en'; } $this->document->addScript(RDIR_TEMPLATE . 'javascript/jqgrid/js/i18n/grid.locale-' . $locale . '.js'); $this->document->addScript(RDIR_TEMPLATE . 'javascript/jqgrid/js/jquery.jqGrid.min.js'); $this->document->addScript(RDIR_TEMPLATE . 'javascript/jqgrid/plugins/jquery.grid.fluid.js'); $this->document->addScript(RDIR_TEMPLATE . 'javascript/jqgrid/js/jquery.ba-bbq.min.js'); $this->document->addScript(RDIR_TEMPLATE . 'javascript/jqgrid/js/grid.history.js'); //set flag to not include scripts/css twice $this->registry->set('jqgrid_script', true); } $this->session->data['multivalue_excludes'] = array(); $this->loadModel('catalog/download'); foreach ($order_downloads as $product_id => $order_download) { $downloads = (array) $order_download['downloads']; $this->data['order_downloads'][$product_id]['product_name'] = $order_download['product_name']; $this->data['order_downloads'][$product_id]['product_thumbnail'] = $rl->getMainThumb('products', $product_id, $this->config->get('config_image_grid_width'), $this->config->get('config_image_grid_height')); foreach ($downloads as $download_info) { $download_info['order_status_id'] = $order_info['order_status_id']; $attributes = $this->download->getDownloadAttributesValuesForDisplay($download_info['download_id']); $order_product_id = $download_info['order_product_id']; $is_file = $this->download->isFileAvailable($download_info['filename']); foreach ($download_info['download_history'] as &$h) { $h['time'] = dateISO2Display($h['time'], $this->language->get('date_format_short') . ' ' . $this->language->get('time_format')); } unset($h); $status_text = $this->model_catalog_download->getTextStatusForOrderDownload($download_info); if ($status_text) { $status = $status_text; } else { $status = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'downloads[' . (int) $download_info['order_download_id'] . '][status]', 'value' => $download_info['status'], 'style' => 'btn_switch')); } $this->data['order_downloads'][$product_id]['downloads'][] = array('name' => $download_info['name'], 'attributes' => $attributes, 'href' => $this->html->getSecureURL('catalog/product_files', '&product_id=' . $product_id . '&download_id=' . $download_info['download_id']), 'resource' => $download_info['filename'], 'is_file' => $is_file, 'mask' => $download_info['mask'], 'status' => $status, 'remaining' => $form->getFieldHtml(array('type' => 'input', 'name' => 'downloads[' . (int) $download_info['order_download_id'] . '][remaining_count]', 'value' => $download_info['remaining_count'], 'placeholder' => '-', 'style' => 'small-field')), 'expire_date' => $form->getFieldHtml(array('type' => 'date', 'name' => 'downloads[' . (int) $download_info['order_download_id'] . '][expire_date]', 'value' => $download_info['expire_date'] ? dateISO2Display($download_info['expire_date']) : '', 'default' => '', 'dateformat' => format4Datepicker($this->language->get('date_format_short')), 'highlight' => 'future', 'style' => 'medium-field')), 'download_history' => $download_info['download_history']); // exclude downloads from multivalue list. why we need relate recursion? $this->session->data['multivalue_excludes'][] = $download_info['download_id']; } $this->data['order_downloads'][$product_id]['push'] = $form->getFieldHtml(array('id' => 'popup' . $product_id, 'type' => 'multivalue', 'name' => 'popup' . $product_id, 'title' => $this->language->get('text_select_from_list'), 'selected_name' => 'push[' . $order_product_id . ']', 'selected' => "{}", 'content_url' => $this->html->getSecureUrl('catalog/download_listing', '&form_name=orderFrm&multivalue_hidden_id=popup' . $product_id), 'postvars' => '', 'return_to' => '', 'popup_height' => 708, 'text' => array('selected' => $this->language->get('text_count_selected'), 'edit' => $this->language->get('text_save_edit'), 'apply' => $this->language->get('text_apply'), 'save' => $this->language->get('text_add'), 'reset' => $this->language->get('button_reset')))); } } $this->view->batchAssign($this->data); $this->view->assign('help_url', $this->gen_help_url('order_files')); $this->processTemplate('pages/sale/order_files.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 main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); //is this an embed mode $cart_rt = 'checkout/cart'; if ($this->config->get('embed_mode') == true) { $cart_rt = 'r/checkout/cart/embed'; } if (!$this->cart->hasProducts() || !$this->cart->hasStock() && !$this->config->get('config_stock_checkout')) { $this->redirect($this->html->getSecureURL($cart_rt)); } //validate if order min/max are met if (!$this->cart->hasMinRequirement() || !$this->cart->hasMaxRequirement()) { $this->redirect($this->html->getSecureURL($cart_rt)); } if ($this->customer->isLogged()) { $this->redirect($this->html->getSecureURL('checkout/shipping')); } if (!isset($this->session->data['guest'])) { $this->redirect($this->html->getSecureURL('checkout/guest_step_1')); } if ($this->cart->hasShipping()) { if (!isset($this->session->data['shipping_method'])) { $this->redirect($this->html->getSecureURL('checkout/guest_step_2')); } } else { unset($this->session->data['shipping_method']); unset($this->session->data['shipping_methods']); //$this->tax->setZone($this->config->get('config_country_id'), $this->config->get('config_zone_id')); $this->tax->setZone($this->session->data['country_id'], $this->session->data['zone_id']); } if (!isset($this->session->data['payment_method'])) { $this->redirect($this->html->getSecureURL('checkout/guest_step_2')); } $this->loadLanguage('checkout/confirm'); $this->document->setTitle($this->language->get('heading_title')); //build and save order $this->data = array(); $order = new AOrder($this->registry); $this->data = $order->buildOrderData($this->session->data); $this->session->data['order_id'] = $order->saveOrder(); $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($cart_rt), 'text' => $this->language->get('text_basket'), 'separator' => $this->language->get('text_separator'))); $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('checkout/guest_step_1'), 'text' => $this->language->get('text_guest_step_1'), 'separator' => $this->language->get('text_separator'))); $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('checkout/guest_step_2'), 'text' => $this->language->get('text_guest_step_2'), 'separator' => $this->language->get('text_separator'))); $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('checkout/guest_step_3'), 'text' => $this->language->get('text_confirm'), 'separator' => $this->language->get('text_separator'))); $this->view->assign('error_warning', $this->error['warning']); $this->view->assign('success', $this->session->data['success']); if (isset($this->session->data['success'])) { unset($this->session->data['success']); } if ($this->cart->hasShipping()) { if (isset($this->session->data['guest']['shipping'])) { $shipping_address = $this->session->data['guest']['shipping']; } else { $shipping_address = $this->session->data['guest']; } $this->data['shipping_address'] = $this->customer->getFormatedAdress($shipping_address, $shipping_address['address_format']); } else { $this->data['shipping_address'] = ''; } if (isset($this->session->data['shipping_method']['title'])) { $this->data['shipping_method'] = $this->session->data['shipping_method']['title']; } else { $this->data['shipping_method'] = ''; } $this->data['checkout_shipping'] = $this->html->getSecureURL('checkout/guest_step_2'); $this->data['checkout_shipping_edit'] = $this->html->getSecureURL('checkout/guest_step_2', '&mode=edit', true); $this->data['checkout_shipping_address'] = $this->html->getSecureURL('checkout/guest_step_1'); $payment_address = $this->session->data['guest']; if ($payment_address) { $this->data['payment_address'] = $this->customer->getFormatedAdress($payment_address, $payment_address['address_format']); } else { $this->data['payment_address'] = ''; } if ($this->session->data['payment_method']['id'] != 'no_payment_required') { $this->data['payment_method'] = $this->session->data['payment_method']['title']; } else { $this->data['payment_method'] = ''; } $this->data['checkout_payment'] = $this->html->getSecureURL('checkout/guest_step_2'); $this->data['checkout_payment_edit'] = $this->html->getSecureURL('checkout/guest_step_2', '&mode=edit', true); $this->data['cart'] = $this->html->getSecureURL($cart_rt); $this->data['checkout_payment_address'] = $this->html->getSecureURL('checkout/guest_step_1'); $this->loadModel('tool/seo_url'); $this->loadModel('tool/image'); //Format product data specific for confirmation page $resource = new AResource('image'); for ($i = 0; $i < sizeof($this->data['products']); $i++) { $product_id = $this->data['products'][$i]['product_id']; $thumbnail = $resource->getMainThumb('products', $product_id, $this->config->get('config_image_cart_width'), $this->config->get('config_image_cart_height'), true); $tax = $this->tax->calcTotalTaxAmount($this->data['products'][$i]['total'], $this->data['products'][$i]['tax_class_id']); $this->data['products'][$i] = array_merge($this->data['products'][$i], array('thumb' => $thumbnail, 'tax' => $this->currency->format($tax), 'price' => $this->currency->format($this->data['products'][$i]['price']), 'total' => $this->currency->format($this->data['products'][$i]['total']), 'href' => $this->html->getSEOURL('product/product', '&product_id=' . $product_id, true))); } if ($this->config->get('config_checkout_id')) { $this->loadModel('catalog/content'); $content_info = $this->model_catalog_content->getContent($this->config->get('config_checkout_id')); if ($content_info) { $this->data['text_accept_agree'] = $this->language->get('text_accept_agree'); $this->data['text_accept_agree_href'] = $this->html->getSEOURL('r/content/content/loadInfo', '&content_id=' . $this->config->get('config_checkout_id'), true); $this->data['text_accept_agree_href_link'] = $content_info['title']; } else { $this->data['text_accept_agree'] = ''; } } else { $this->data['text_accept_agree'] = ''; } if ($this->session->data['payment_method']['id'] != 'no_payment_required') { $this->addChild('responses/extension/' . $this->session->data['payment_method']['id'], 'payment'); } else { $this->addChild('responses/checkout/no_payment', 'payment'); } $this->view->batchAssign($this->data); $this->processTemplate('pages/checkout/confirm.tpl'); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
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'); if (isset($this->request->get['product_id']) && $this->request->is_GET()) { $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')); } } if ($this->request->is_POST()) { $this->model_catalog_product->updateProductLinks($this->request->get['product_id'], $this->request->post); $this->session->data['success'] = $this->language->get('text_success'); $this->redirect($this->html->getSecureURL('catalog/product_relations', '&product_id=' . $this->request->get['product_id'])); } $this->data['product_description'] = $this->model_catalog_product->getProductDescriptions($this->request->get['product_id']); $this->view->assign('error_warning', $this->error['warning']); $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'), 'separator' => FALSE)); $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('catalog/product'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: ')); $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'], 'separator' => ' :: ')); $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('catalog/product_relations', '&product_id=' . $this->request->get['product_id']), 'text' => $this->language->get('tab_relations'), 'separator' => ' :: ', 'current' => true)); $this->loadModel('catalog/category'); $this->data['categories'] = array(); $results = $this->model_catalog_category->getCategories(0); foreach ($results as $r) { $this->data['categories'][$r['category_id']] = $r['name']; } $this->loadModel('setting/store'); $this->data['stores'] = array(0 => $this->language->get('text_default')); $results = $this->model_setting_store->getStores(); foreach ($results as $r) { $this->data['stores'][$r['store_id']] = $r['name']; } $this->data['product_category'] = $this->model_catalog_product->getProductCategories($this->request->get['product_id']); $this->data['product_store'] = $this->model_catalog_product->getProductStores($this->request->get['product_id']); $this->data['product_related'] = $this->model_catalog_product->getProductRelated($this->request->get['product_id']); $this->data['active'] = 'relations'; //load tabs controller $tabs_obj = $this->dispatch('pages/catalog/product_tabs', array($this->data)); $this->data['product_tabs'] = $tabs_obj->dispatchGetOutput(); unset($tabs_obj); $this->data['category_products'] = $this->html->getSecureURL('product/product/category'); $this->data['related_products'] = $this->html->getSecureURL('product/product/related'); $this->data['action'] = $this->html->getSecureURL('catalog/product_relations', '&product_id=' . $this->request->get['product_id']); $this->data['form_title'] = $this->language->get('text_edit') . ' ' . $this->language->get('text_product'); $this->data['update'] = $this->html->getSecureURL('listing_grid/product/update_relations_field', '&id=' . $this->request->get['product_id']); $form = new AForm('HS'); $form->setForm(array('form_name' => 'productFrm', 'update' => $this->data['update'])); $this->data['form']['id'] = 'productFrm'; $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'productFrm', 'action' => $this->data['action'], 'attr' => 'data-confirm-exit="true" class="aform form-horizontal"')); $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_save'), 'style' => 'button1')); $this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'href' => $this->html->getSecureURL('catalog/product/update', '&product_id=' . $this->request->get['product_id']), 'name' => 'cancel', 'text' => $this->language->get('button_cancel'), 'style' => 'button2')); $this->data['cancel'] = $this->html->getSecureURL('catalog/product'); $this->loadModel('catalog/category'); $this->data['categories'] = array(); $results = $this->model_catalog_category->getCategories(0); foreach ($results as $r) { $this->data['categories'][$r['category_id']] = $r['name']; } $this->data['form']['fields']['category'] = $form->getFieldHtml(array('type' => 'checkboxgroup', 'name' => 'product_category[]', 'value' => $this->data['product_category'], 'options' => $this->data['categories'], 'style' => 'chosen', 'placeholder' => $this->language->get('text_select_category'))); //load only prior saved products $resource = new AResource('image'); $this->data['products'] = array(); if (count($this->data['product_related'])) { $this->loadModel('catalog/product'); $filter = array('subsql_filter' => 'p.product_id in (' . implode(',', $this->data['product_related']) . ')'); $results = $this->model_catalog_product->getProducts($filter); foreach ($results as $r) { $thumbnail = $resource->getMainThumb('products', $r['product_id'], (int) $this->config->get('config_image_grid_width'), (int) $this->config->get('config_image_grid_height'), true); $this->data['products'][$r['product_id']]['name'] = $r['name'] . " (" . $r['model'] . ")"; $this->data['products'][$r['product_id']]['image'] = $thumbnail['thumb_html']; } } $this->data['form']['fields']['related'] = $form->getFieldHtml(array('type' => 'multiselectbox', 'name' => 'product_related[]', 'value' => $this->data['product_related'], 'options' => $this->data['products'], 'style' => 'chosen', 'ajax_url' => $this->html->getSecureURL('r/product/product/products'), 'placeholder' => $this->language->get('text_select_from_lookup'))); $this->data['form']['fields']['store'] = $form->getFieldHtml(array('type' => 'checkboxgroup', 'name' => 'product_store[]', 'value' => $this->data['product_store'], 'options' => $this->data['stores'], 'style' => 'chosen')); 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->addChild('pages/catalog/product_summary', 'summary_form', 'pages/catalog/product_summary.tpl'); $this->view->assign('help_url', $this->gen_help_url('?p=62')); $this->view->batchAssign($this->data); $this->processTemplate('pages/catalog/product_relations.tpl'); //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function files() { $this->data = array(); //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->document->setTitle($this->language->get('heading_title')); if (has_value($this->session->data['error'])) { $this->data['error']['warning'] = $this->session->data['error']; unset($this->session->data['error']); } if (isset($this->request->get['order_id'])) { $order_id = $this->request->get['order_id']; } else { $order_id = 0; } if ($this->request->is_POST() && $this->_validateForm()) { if (has_value($this->request->post['downloads'])) { $data = $this->request->post['downloads']; $this->loadModel('catalog/download'); foreach ($data as $order_download_id => $item) { if (isset($item['expire_date'])) { $item['expire_date'] = $item['expire_date'] ? dateDisplay2ISO($item['expire_date'], $this->language->get('date_format_short')) : ''; } $this->model_catalog_download->editOrderDownload($order_download_id, $item); } } //add download to order if (has_value($this->request->post['push'])) { $this->load->library('json'); foreach ($this->request->post['push'] as $order_product_id => $download_id) { if ($download_id) { $download_info = $this->download->getDownloadInfo($download_id); $download_info['attributes_data'] = serialize($this->download->getDownloadAttributesValues($download_id)); $this->download->addProductDownloadToOrder($order_product_id, $order_id, $download_info); } } } $this->session->data['success'] = $this->language->get('text_success'); $this->redirect($this->html->getSecureURL('sale/order/files', '&order_id=' . $this->request->get['order_id'])); } $order_info = $this->model_sale_order->getOrder($order_id); $this->data['order_info'] = $order_info; //set content language to order language ID. if ($this->language->getContentLanguageID() != $order_info['language_id']) { //reset content language $this->language->setCurrentContentLanguage($order_info['language_id']); } if (empty($order_info)) { $this->session->data['error'] = $this->language->get('error_order_load'); $this->redirect($this->html->getSecureURL('sale/order')); } $this->document->initBreadcrumb(array('href' => $this->html->getSecureURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => false)); $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('sale/order'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: ')); $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('sale/order/files', '&order_id=' . $this->request->get['order_id']), 'text' => $this->language->get('heading_title') . ' #' . $order_info['order_id'], 'separator' => ' :: ', 'current' => true)); if (isset($this->session->data['success'])) { $this->data['success'] = $this->session->data['success']; unset($this->session->data['success']); } else { $this->data['success'] = ''; } $this->data['heading_title'] = $this->language->get('heading_title') . ' #' . $order_info['order_id']; $this->data['token'] = $this->session->data['token']; $this->data['invoice_url'] = $this->html->getSecureURL('sale/invoice', '&order_id=' . (int) $this->request->get['order_id']); $this->data['button_invoice'] = $this->html->buildButton(array('name' => 'btn_invoice', 'text' => $this->language->get('text_invoice'))); $this->data['invoice_generate'] = $this->html->getSecureURL('sale/invoice/generate'); $this->data['category_products'] = $this->html->getSecureURL('product/product/category'); $this->data['product_update'] = $this->html->getSecureURL('catalog/product/update'); $this->data['order_id'] = $this->request->get['order_id']; $this->data['action'] = $this->html->getSecureURL('sale/order/files', '&order_id=' . $this->request->get['order_id']); $this->data['cancel'] = $this->html->getSecureURL('sale/order'); $this->_initTabs('files'); $this->loadModel('localisation/order_status'); $status = $this->model_localisation_order_status->getOrderStatus($order_info['order_status_id']); if ($status) { $this->data['order_status'] = $status['name']; } else { $this->data['order_status'] = ''; } $this->loadModel('sale/customer_group'); $customer_group_info = $this->model_sale_customer_group->getCustomerGroup($order_info['customer_group_id']); if ($customer_group_info) { $this->data['customer_group'] = $customer_group_info['name']; } else { $this->data['customer_group'] = ''; } $this->data['form_title'] = $this->language->get('edit_title_files'); $this->data['update'] = $this->html->getSecureURL('listing_grid/order/update_field', '&id=' . $this->request->get['order_id']); $form = new AForm('HS'); $form->setForm(array('form_name' => 'orderFrm', 'update' => $this->data['update'])); $this->data['form']['id'] = 'orderFrm'; $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'orderFrm', 'attr' => 'data-confirm-exit="true" class="aform form-horizontal"', 'action' => $this->data['action'])); $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_save'), 'style' => 'button1')); $this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'text' => $this->language->get('button_cancel'), 'style' => 'button2')); $this->loadModel('catalog/download'); $all_downloads = $this->model_catalog_download->getDownloads(); $options = array('' => $this->language->get('text_push_download')); foreach ($all_downloads as $d) { $options[$d['download_id']] = $d['name'] . ' (' . $d['mask'] . ')'; } $this->addChild('pages/sale/order_summary', 'summary_form', 'pages/sale/order_summary.tpl'); /** ORDER DOWNLOADS */ $this->data['downloads'] = array(); $order_downloads = $this->model_sale_order->getOrderDownloads($this->request->get['order_id']); if ($order_downloads) { $rl = new AResource('image'); $this->loadModel('catalog/download'); foreach ($order_downloads as $product_id => $order_download) { $downloads = (array) $order_download['downloads']; $this->data['order_downloads'][$product_id]['product_name'] = $order_download['product_name']; $this->data['order_downloads'][$product_id]['product_thumbnail'] = $rl->getMainThumb('products', $product_id, $this->config->get('config_image_grid_width'), $this->config->get('config_image_grid_height')); foreach ($downloads as $download_info) { $download_info['order_status_id'] = $order_info['order_status_id']; $attributes = $this->download->getDownloadAttributesValuesForDisplay($download_info['download_id']); $order_product_id = $download_info['order_product_id']; $is_file = $this->download->isFileAvailable($download_info['filename']); foreach ($download_info['download_history'] as &$h) { $h['time'] = dateISO2Display($h['time'], $this->language->get('date_format_short') . ' ' . $this->language->get('time_format')); } unset($h); $status_text = $this->model_catalog_download->getTextStatusForOrderDownload($download_info); if ($status_text) { $status = $status_text; } else { $status = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'downloads[' . (int) $download_info['order_download_id'] . '][status]', 'value' => $download_info['status'], 'style' => 'btn_switch')); } $this->data['order_downloads'][$product_id]['downloads'][] = array('name' => $download_info['name'], 'attributes' => $attributes, 'href' => $this->html->getSecureURL('catalog/product_files', '&product_id=' . $product_id . '&download_id=' . $download_info['download_id']), 'resource' => $download_info['filename'], 'is_file' => $is_file, 'mask' => $download_info['mask'], 'status' => $status, 'remaining' => $form->getFieldHtml(array('type' => 'input', 'name' => 'downloads[' . (int) $download_info['order_download_id'] . '][remaining_count]', 'value' => $download_info['remaining_count'], 'placeholder' => '-', 'style' => 'small-field')), 'expire_date' => $form->getFieldHtml(array('type' => 'date', 'name' => 'downloads[' . (int) $download_info['order_download_id'] . '][expire_date]', 'value' => $download_info['expire_date'] ? dateISO2Display($download_info['expire_date']) : '', 'default' => '', 'dateformat' => format4Datepicker($this->language->get('date_format_short')), 'highlight' => 'future', 'style' => 'medium-field')), 'download_history' => $download_info['download_history']); $this->data['order_downloads'][$product_id]['push_download'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'push[' . (int) $download_info['order_download_id'] . ']', 'value' => '', 'options' => $options, 'style' => 'chosen no-save', 'placeholder' => $this->language->get('text_push_download'))); } } } else { $this->redirect($this->html->getSecureURL('sale/order/details', '&order_id=' . $this->request->get['order_id'])); } $this->view->batchAssign($this->data); $this->view->assign('help_url', $this->gen_help_url('order_files')); $this->processTemplate('pages/sale/order_files.tpl'); //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function get() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadModel('catalog/product'); $filter_params = array('category_id', 'manufacturer_id', 'keyword', 'match', 'pfrom', 'pto'); $grid_filter_params = array('name', 'description', 'model', 'sku'); $filter_data = array('method' => 'get', 'filter_params' => $filter_params, 'grid_filter_params' => $grid_filter_params); $filter = new AFilter($filter_data); $filters = $filter->getFilterData(); $category_id = $filter->getFilterParam('category_id'); $manufacturer_id = $filter->getFilterParam('manufacturer_id'); $keyword = $filter->getFilterParam('keyword'); if (!$category_id && !$manufacturer_id && !$keyword) { $this->rest->setResponseData(array('Error' => 'Missing one of required product filter parameters')); $this->rest->sendResponse(200); return null; } //get total if ($keyword) { $total = $this->model_catalog_product->getTotalProducts($filters); } elseif ($category_id) { $total = $this->model_catalog_product->getTotalProductsByCategoryId($category_id); } elseif ($manufacturer_id) { $total = $this->model_catalog_product->getTotalProductsByManufacturerId($manufacturer_id); } if ($total > 0) { $total_pages = ceil($total / $filter->getParam('rows')); } else { $total_pages = 0; } //Preserved jqGrid JSON interface $response = new stdClass(); $response->page = $filter->getParam('page'); $response->total = $total_pages; $response->records = $total; $response->limit = $filters['limit']; $response->sidx = $filters['sort']; $response->sord = $filters['order']; $response->params = $filters; $resource = new AResource('image'); if ($keyword) { $results = $this->model_catalog_product->getProducts($filters); } elseif ($category_id) { $results = $this->model_catalog_product->getProductsByCategoryId($category_id, $filters['sort'], $filters['order'], $filters['start'], $filters['limit']); } elseif ($manufacturer_id) { $results = $this->model_catalog_product->getProductsByManufacturerId($manufacturer_id, $filters['sort'], $filters['order'], $filters['start'], $filters['limit']); } $i = 0; if ($results) { foreach ($results as $result) { $thumbnail = $resource->getMainThumb('products', $result['product_id'], $this->config->get('config_image_thumb_width'), $this->config->get('config_image_thumb_height'), true); $response->rows[$i]['id'] = $result['product_id']; $response->rows[$i]['cell']['thumb'] = $thumbnail['thumb_url']; $response->rows[$i]['cell']['name'] = $result['name']; $response->rows[$i]['cell']['description'] = $result['description']; $response->rows[$i]['cell']['model'] = $result['model']; $response->rows[$i]['cell']['price'] = $this->currency->convert($result['final_price'], $this->config->get('config_currency'), $this->currency->getCode()); $response->rows[$i]['cell']['currency_code'] = $this->currency->getCode(); $response->rows[$i]['cell']['rating'] = $result['rating']; $i++; } } //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->rest->setResponseData($response); $this->rest->sendResponse(200); }
/** * @param array $data_source * @param array $result * @return array */ private function _prepareCustomItems($data_source, $result) { if (!$data_source['rl_object_name']) { return $result; } $resource = new AResource('image'); if ($result) { foreach ($result as $k => $item) { if ($data_source['rl_object_name']) { $thumbnail = $resource->getMainThumb($data_source['rl_object_name'], $item[$data_source['data_type']], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'), true); $result[$k]['image'] = $result[$k]['thumb'] = $thumbnail; } if (isset($item['price']) && preg_match('/^[0-9\\.]/', $item['price'])) { $result[$k]['price'] = $this->currency->format($this->tax->calculate($item['price'], $result['tax_class_id'], $this->config->get('config_tax'))); } //TODO: remove it in the future. Deprecated ['url'] in v2.0, it is only used in default template and replaced with ['href'] set in caller function $result[$k]['url'] = $this->html->getSEOURL($data_source['storefront_view_path'], '&' . $data_source['data_type'] . '=' . $item[$data_source['data_type']], true); } } return $result; }
public function getCustomListListingGridData() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); // json-response for jqgrid $this->load->library('json'); // if datasource was switched $layout_manager = new ALayoutManager(); $custom_block_id = (int) $this->request->get['custom_block_id']; $listing_datasource = $this->request->post_or_get('listing_datasource'); $info = $layout_manager->getBlockDescriptions($custom_block_id); $info = is_array($info) ? current($info) : ''; $info = unserialize($info['content']); $custom_list = array(); $lm = new AListingManager($custom_block_id); $this->data['data_sources'] = $lm->getListingDataSources(); if ($info['listing_datasource'] == $listing_datasource) { $list = $lm->getCustomList(); if ($list) { foreach ($list as $row) { $custom_list[$row['id']] = $row['sort_order']; } } } //load data source language and model $this->loadLanguage($this->data['data_sources'][$listing_datasource]['language']); $this->loadModel($this->data['data_sources'][$listing_datasource]['model']); $this->loadModel('tool/image'); //Prepare filter config $grid_filter_params = array('name', 'sort_order', 'model'); $filter = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params)); $filter_data = $filter->getFilterData(); //call data source model total method to get total based on set filter $model = $this->{'model_' . str_replace('/', '_', $this->data['data_sources'][$listing_datasource]['model'])}; $total = call_user_func_array(array($model, $this->data['data_sources'][$listing_datasource]['total_method']), array($filter_data)); $response = new stdClass(); $response->page = $filter->getParam('page'); $response->total = $filter->calcTotalPages($total); $response->records = $total; $response->userdata = (object) array(''); //call data source model method to get all records based on set filter $model = $this->{'model_' . str_replace('/', '_', $this->data['data_sources'][$listing_datasource]['model'])}; $results = call_user_func_array(array($model, $this->data['data_sources'][$listing_datasource]['method']), array($filter_data)); $i = 0; $resource = new AResource('image'); $response->userdata = (object) array('page' => '', 'selId' => array()); $data_type = $this->data['data_sources'][$listing_datasource]['data_type']; //product_id, category_id etc $id_list = $custom_list ? array_keys($custom_list) : array(); if ($results) { foreach ($results as $result) { $list_item_id = $result[$data_type]; //for pre-select if (in_array($list_item_id, $id_list) || in_array($list_item_id, array_keys($this->session->data['listing_selected']))) { $response->userdata->selId[] = $list_item_id; } $thumbnail = $resource->getMainThumb($this->data['data_sources'][$listing_datasource]['rl_object_name'], $list_item_id, 36, 36, true); $response->rows[$i]['id'] = $list_item_id; $response->rows[$i]['cell'] = array($thumbnail['thumb_html'], $result['name']); if (strpos($listing_datasource, 'product') !== FALSE) { $response->rows[$i]['cell'][] = $result['model']; } if ($custom_list[$list_item_id]) { $value = $custom_list[$list_item_id]; } else { $value = $this->session->data['listing_selected'][$list_item_id]['sort_order']; } //TODO: need find solution to replace html hardcode in all response controllers $response->rows[$i]['cell'][] = '<a class="btn_action" href="JavaScript:void(0);" onclick="showPopup(\'' . $this->html->getSecureURL($this->data['data_sources'][$listing_datasource]['view_path'], '&' . $data_type . '=' . $list_item_id) . '\')" title="' . $this->language->get('text_view') . '">' . '<img src="' . RDIR_TEMPLATE . 'image/icons/icon_grid_view.png" alt="' . $this->language->get('text_edit') . '" /></a>'; $i++; } } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->response->addJSONHeader(); $this->response->setOutput(AJson::encode($response)); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->data['heading_title'] = $this->language->get('heading_title'); $this->loadModel('catalog/product'); $this->loadModel('catalog/review'); $this->loadModel('tool/image'); $this->data['button_add_to_cart'] = $this->language->get('button_add_to_cart'); $this->data['products'] = array(); $results = $this->model_catalog_product->getfeaturedProducts($this->config->get('config_featured_limit')); foreach ($results as $result) { $product_ids[] = (int) $result['product_id']; } $products_info = $this->model_catalog_product->getProductsAllInfo($product_ids); $resource = new AResource('image'); foreach ($results as $result) { $thumbnail = $resource->getMainThumb('products', $result['product_id'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'), true); $rating = $products_info[$result['product_id']]['rating']; $special = FALSE; $discount = $products_info[$result['product_id']]['discount']; if ($discount) { $price = $this->currency->format($this->tax->calculate($discount, $result['tax_class_id'], $this->config->get('config_tax'))); } else { $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))); $special = $products_info[$result['product_id']]['special']; if ($special) { $special = $this->currency->format($this->tax->calculate($special, $result['tax_class_id'], $this->config->get('config_tax'))); } } $options = $products_info[$result['product_id']]['options']; if ($options) { $add = $this->html->getSEOURL('product/product', '&product_id=' . $result['product_id'], '&encode'); } else { if ($this->config->get('config_cart_ajax')) { $add = '#'; } else { $add = $this->html->getSecureURL('checkout/cart', '&product_id=' . $result['product_id'], '&encode'); } } //check for stock status, availability and config $track_stock = false; $in_stock = false; $no_stock_text = $result['stock']; $total_quantity = 0; if ($this->model_catalog_product->isStockTrackable($result['product_id'])) { $track_stock = true; $total_quantity = $this->model_catalog_product->hasAnyStock($result['product_id']); //we have stock or out of stock checkout is allowed if ($total_quantity > 0 || $this->config->get('config_stock_checkout')) { $in_stock = true; } } $this->data['products'][] = array('product_id' => $result['product_id'], 'name' => $result['name'], 'blurb' => $result['blurb'], 'model' => $result['model'], 'rating' => $rating, 'stars' => sprintf($this->language->get('text_stars'), $rating), 'price' => $price, 'call_to_order' => $result['call_to_order'], 'options' => $options, 'special' => $special, 'thumb' => $thumbnail, 'href' => $this->html->getSEOURL('product/product', '&product_id=' . $result['product_id'], '&encode'), 'add' => $add, 'track_stock' => $track_stock, 'in_stock' => $in_stock, 'no_stock_text' => $no_stock_text, 'total_quantity' => $total_quantity); } if ($this->config->get('config_customer_price')) { $this->data['display_price'] = TRUE; } elseif ($this->customer->isLogged()) { $this->data['display_price'] = TRUE; } else { $this->data['display_price'] = FALSE; } $this->data['review_status'] = $this->config->get('enable_reviews'); // framed needs to show frames for generic block. //If tpl used by listing block framed was set by listing block settings $this->data['block_framed'] = true; $this->view->batchAssign($this->data); $this->processTemplate(); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function main() { //is this an embed mode if ($this->config->get('embed_mode') == true) { $cart_rt = 'r/checkout/cart/embed'; } else { $cart_rt = 'checkout/cart'; } //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('product/category'); $this->document->resetBreadcrumbs(); $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE)); $this->loadModel('catalog/category'); $this->loadModel('tool/seo_url'); if (!isset($this->request->get['path']) && isset($this->request->get['category_id'])) { $this->request->get['path'] = $this->request->get['category_id']; } if (isset($this->request->get['path'])) { $path = ''; $parts = explode('_', $this->request->get['path']); if (count($parts) == 1) { //see if this is a category ID to sub category, need to build full path $parts = explode('_', $this->model_catalog_category->buildPath($this->request->get['path'])); } foreach ($parts as $path_id) { $category_info = $this->model_catalog_category->getCategory($path_id); if ($category_info) { if (!$path) { $path = $path_id; } else { $path .= '_' . $path_id; } $this->document->addBreadcrumb(array('href' => $this->html->getSEOURL('product/category', '&path=' . $path, '&encode'), 'text' => $category_info['name'], 'separator' => $this->language->get('text_separator'))); } } $category_id = array_pop($parts); } else { $category_id = 0; } $category_info = array(); if ($category_id) { $category_info = $this->model_catalog_category->getCategory($category_id); } elseif ($this->config->get('embed_mode') == true) { $category_info['name'] = $this->language->get('text_top_category'); } if ($category_info) { $this->document->setTitle($category_info['name']); $this->document->setKeywords($category_info['meta_keywords']); $this->document->setDescription($category_info['meta_description']); $this->view->assign('heading_title', $category_info['name']); $this->view->assign('description', html_entity_decode($category_info['description'], ENT_QUOTES, 'UTF-8')); $this->view->assign('text_sort', $this->language->get('text_sort')); 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'); } if (isset($this->request->get['sort'])) { $sorting_href = $this->request->get['sort']; list($sort, $order) = explode("-", $sorting_href); } else { $sorting_href = $this->config->get('config_product_default_sort_order'); list($sort, $order) = explode("-", $sorting_href); if ($sort == 'name') { $sort = 'pd.' . $sort; } elseif (in_array($sort, array('sort_order', 'price'))) { $sort = 'p.' . $sort; } } $url = '&sort=' . $sort . "-" . $order; if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } $this->loadModel('catalog/product'); $category_total = $this->model_catalog_category->getTotalCategoriesByCategoryId($category_id); $product_total = $this->model_catalog_product->getTotalProductsByCategoryId($category_id); if ($category_total || $product_total) { $categories = array(); $results = $this->model_catalog_category->getCategories($category_id); $resource = new AResource('image'); foreach ($results as $result) { $thumbnail = $resource->getMainThumb('categories', $result['category_id'], (int) $this->config->get('config_image_category_width'), (int) $this->config->get('config_image_category_height'), true); $categories[] = array('name' => $result['name'], 'href' => $this->html->getSEOURL('product/category', '&path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url, '&encode'), 'thumb' => $thumbnail); } $this->view->assign('categories', $categories); $this->loadModel('catalog/review'); $this->view->assign('button_add_to_cart', $this->language->get('button_add_to_cart')); $products = array(); $products_result = $this->model_catalog_product->getProductsByCategoryId($category_id, $sort, $order, ($page - 1) * $limit, $limit); foreach ($products_result as $p) { $product_ids[] = (int) $p['product_id']; } $products_info = $this->model_catalog_product->getProductsAllInfo($product_ids); foreach ($products_result as $result) { $thumbnail = $resource->getMainThumb('products', $result['product_id'], (int) $this->config->get('config_image_product_width'), (int) $this->config->get('config_image_product_height'), true); $rating = $products_info[$result['product_id']]['rating']; $special = FALSE; $discount = $products_info[$result['product_id']]['discount']; if ($discount) { $price = $this->currency->format($this->tax->calculate($discount, $result['tax_class_id'], $this->config->get('config_tax'))); } else { $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))); $special = $products_info[$result['product_id']]['special']; if ($special) { $special = $this->currency->format($this->tax->calculate($special, $result['tax_class_id'], $this->config->get('config_tax'))); } } $options = $products_info[$result['product_id']]['options']; if ($options) { $add = $this->html->getSEOURL('product/product', '&product_id=' . $result['product_id'], '&encode'); } else { if ($this->config->get('config_cart_ajax')) { $add = '#'; } else { $add = $this->html->getSecureURL($cart_rt, '&product_id=' . $result['product_id'], '&encode'); } } //check for stock status, availability and config $track_stock = false; $in_stock = false; $no_stock_text = $result['stock']; $total_quantity = 0; if ($this->model_catalog_product->isStockTrackable($result['product_id'])) { $track_stock = true; $total_quantity = $this->model_catalog_product->hasAnyStock($result['product_id']); //we have stock or out of stock checkout is allowed if ($total_quantity > 0 || $this->config->get('config_stock_checkout')) { $in_stock = true; } } $products[] = array('product_id' => $result['product_id'], 'name' => $result['name'], 'blurb' => $result['blurb'], 'model' => $result['model'], 'rating' => $rating, 'stars' => sprintf($this->language->get('text_stars'), $rating), 'thumb' => $thumbnail, 'price' => $price, 'call_to_order' => $result['call_to_order'], 'options' => $options, 'special' => $special, 'href' => $this->html->getSEOURL('product/product', '&path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'], '&encode'), 'add' => $add, 'description' => html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'), 'track_stock' => $track_stock, 'in_stock' => $in_stock, 'no_stock_text' => $no_stock_text, 'total_quantity' => $total_quantity); } $this->data['products'] = $products; if ($this->config->get('config_customer_price')) { $display_price = TRUE; } elseif ($this->customer->isLogged()) { $display_price = TRUE; } else { $display_price = FALSE; } $this->view->assign('display_price', $display_price); $url = ''; if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $sorts = array(); $sorts[] = array('text' => $this->language->get('text_default'), 'value' => 'p.sort_order-ASC', 'href' => $this->html->getSEOURL('product/category', $url . '&path=' . $this->request->get['path'] . '&sort=p.sort_order&order=ASC', '&encode')); $sorts[] = array('text' => $this->language->get('text_sorting_name_asc'), 'value' => 'pd.name-ASC', 'href' => $this->html->getSEOURL('product/category', $url . '&path=' . $this->request->get['path'] . '&sort=pd.name&order=ASC', '&encode')); $sorts[] = array('text' => $this->language->get('text_sorting_name_desc'), 'value' => 'pd.name-DESC', 'href' => $this->html->getSEOURL('product/category', $url . '&path=' . $this->request->get['path'] . '&sort=pd.name&order=DESC', '&encode')); $sorts[] = array('text' => $this->language->get('text_sorting_price_asc'), 'value' => 'p.price-ASC', 'href' => $this->html->getSEOURL('product/category', $url . '&path=' . $this->request->get['path'] . '&sort=p.price&order=ASC', '&encode')); $sorts[] = array('text' => $this->language->get('text_sorting_price_desc'), 'value' => 'p.price-DESC', 'href' => $this->html->getSEOURL('product/category', $url . '&path=' . $this->request->get['path'] . '&sort=p.price&order=DESC', '&encode')); $sorts[] = array('text' => $this->language->get('text_sorting_rating_desc'), 'value' => 'rating-DESC', 'href' => $this->html->getSEOURL('product/category', $url . '&path=' . $this->request->get['path'] . '&sort=rating&order=DESC', '&encode')); $sorts[] = array('text' => $this->language->get('text_sorting_rating_asc'), 'value' => 'rating-ASC', 'href' => $this->html->getSEOURL('product/category', $url . '&path=' . $this->request->get['path'] . '&sort=rating&order=ASC', '&encode')); $sorts[] = array('text' => $this->language->get('text_sorting_date_desc'), 'value' => 'date_modified-DESC', 'href' => $this->html->getSEOURL('product/category', $url . '&path=' . $this->request->get['path'] . '&sort=date_modified&order=DESC', '&encode')); $sorts[] = array('text' => $this->language->get('text_sorting_date_asc'), 'value' => 'date_modified-ASC', 'href' => $this->html->getSEOURL('product/category', $url . '&path=' . $this->request->get['path'] . '&sort=date_modified&order=ASC', '&encode')); $options = array(); foreach ($sorts as $item) { $options[$item['value']] = $item['text']; } $sorting = $this->html->buildSelectbox(array('name' => 'sort', 'options' => $options, 'value' => $sort . '-' . $order)); $this->view->assign('sorting', $sorting); $this->view->assign('url', $this->html->getSEOURL('product/category', '&path=' . $this->request->get['path'])); $pegination_url = $this->html->getSEOURL('product/category', '&path=' . $this->request->get['path'] . '&sort=' . $sorting_href . '&page={page}' . '&limit=' . $limit, '&encode'); $this->view->assign('pagination_bootstrap', HtmlElementFactory::create(array('type' => 'Pagination', 'name' => 'pagination', 'text' => $this->language->get('text_pagination'), 'text_limit' => $this->language->get('text_per_page'), 'total' => $product_total, 'page' => $page, 'limit' => $limit, 'url' => $pegination_url, 'style' => 'pagination'))); $this->view->assign('sort', $sort); $this->view->assign('order', $order); $this->view->setTemplate('pages/product/category.tpl'); } else { $this->document->setTitle($category_info['name']); $this->document->setDescription($category_info['meta_description']); $this->view->assign('heading_title', $category_info['name']); $this->view->assign('text_error', $this->language->get('text_empty')); $this->view->assign('button_continue', $this->language->get('button_continue')); $this->view->assign('continue', $this->html->getURL('index/home')); $this->view->assign('categories', array()); $this->data['products'] = array(); $this->view->setTemplate('pages/product/category.tpl'); } $this->data['review_status'] = $this->config->get('enable_reviews'); $this->view->batchAssign($this->data); } else { $url = ''; if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['path'])) { $this->document->addBreadcrumb(array('href' => $this->html->getSEOURL('product/category', '&path=' . $this->request->get['path'] . $url, '&encode'), '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__); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); if (!$this->customer->isLogged()) { $this->session->data['redirect'] = $this->html->getSecureURL('account/download'); $this->redirect($this->html->getSecureURL('account/login')); } //if disabled downloads redirect to if (!$this->config->get('config_download')) { $this->redirect($this->html->getSecureURL('account/account')); } $this->document->setTitle($this->language->get('heading_title')); $this->document->resetBreadcrumbs(); $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE)); $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('account/account'), 'text' => $this->language->get('text_account'), 'separator' => $this->language->get('text_separator'))); $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('account/download'), 'text' => $this->language->get('text_downloads'), 'separator' => $this->language->get('text_separator'))); 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'); } if ($this->config->get('config_download')) { if (isset($this->request->get['page'])) { $page = $this->request->get['page']; } else { $page = 1; } $downloads = array(); //get only enabled, not expired, which have remaining count > 0 and available $customer_downloads = $this->download->getCustomerDownloads(($page - 1) * $limit, $limit); $resource = new AResource('image'); foreach ($customer_downloads as $download_info) { $text_status = $this->download->getTextStatusForOrderDownload($download_info); $size = filesize(DIR_RESOURCE . $download_info['filename']); $i = 0; $suffix = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); while ($size / 1024 > 1) { $size = $size / 1024; $i++; } if (!$text_status) { $link = HtmlElementFactory::create(array('type' => 'button', 'name' => 'download_button_' . $download_info['order_download_id'], 'title' => $this->language->get('text_download'), 'text' => $this->language->get('text_download'), 'style' => 'button', 'href' => $this->html->getSecureURL('account/download/startdownload', '&order_download_id=' . $download_info['order_download_id']), 'icon' => 'icon-download-alt')); } else { $link = $text_status; } $thumbnail = $resource->getMainThumb('products', $download_info['product_id'], $this->config->get('config_image_cart_width'), $this->config->get('config_image_cart_height'), false); $attributes = $this->download->getDownloadAttributesValuesForCustomer($download_info['download_id']); $downloads[] = array('thumbnail' => $thumbnail, 'attributes' => $attributes, 'order_id' => $download_info['order_id'], 'date_added' => dateISO2Display($download_info['date_added'], $this->language->get('date_format_short')), 'name' => $download_info['name'], 'remaining' => $download_info['remaining_count'], 'size' => round(substr($size, 0, strpos($size, '.') + 4), 2) . $suffix[$i], 'link' => $link, 'expire_date' => dateISO2Display($download_info['expire_date'], $this->language->get('date_format_short') . ' ' . $this->language->get('time_format_short'))); } $this->data['downloads'] = $downloads; $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' => sizeof($downloads), 'page' => $page, 'limit' => $limit, 'url' => $this->html->getURL('account/download&page={page}', '&encode'), 'style' => 'pagination')); if ($downloads) { $template = 'pages/account/download.tpl'; } else { $template = 'pages/error/not_found.tpl'; } } else { $template = 'pages/error/not_found.tpl'; } $continue = HtmlElementFactory::create(array('type' => 'button', 'name' => 'continue_button', 'text' => $this->language->get('button_continue'), 'style' => 'button', 'icon' => 'icon-arrow-right', 'href' => $this->html->getSecureURL('account/account'))); $this->data['button_continue'] = $continue; $this->view->batchAssign($this->data); $this->processTemplate($template); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
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)); $url = ''; if (isset($this->request->get['keyword'])) { $url .= '&keyword=' . $this->request->get['keyword']; } if (isset($this->request->get['category_id'])) { $url .= '&category_id=' . $this->request->get['category_id']; } if (isset($this->request->get['description'])) { $url .= '&description=' . $this->request->get['description']; } if (isset($this->request->get['model'])) { $url .= '&model=' . $this->request->get['model']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $this->document->addBreadcrumb(array('href' => $this->html->getURL('product/search', $url), 'text' => $this->language->get('heading_title'), 'separator' => $this->language->get('text_separator'))); if (isset($this->request->get['page'])) { $page = $this->request->get['page']; } else { $page = 1; } if (isset($this->request->get['sort'])) { list($sort, $order) = explode("-", $this->request->get['sort']); } else { list($sort, $order) = explode("-", $this->config->get('config_product_default_sort_order')); if ($sort == 'name') { $sort = 'pd.' . $sort; } elseif (in_array($sort, array('sort_order', 'price'))) { $sort = 'p.' . $sort; } } $this->data['keyword'] = HtmlElementFactory::create(array('type' => 'input', 'name' => 'keyword', 'value' => $this->request->get['keyword'])); $this->data['keyword'] = $this->data['keyword']->getHtml(); $this->loadModel('catalog/category'); $categories = $this->_getCategories(0); $options = array(0 => $this->language->get('text_category')); if ($categories) { foreach ($categories as $item) { $options[$item['category_id']] = $item['name']; } } $this->data['category'] = HtmlElementFactory::create(array('type' => 'selectbox', 'name' => 'category_id', 'options' => $options, 'value' => $this->request->get['category_id'])); $this->data['description'] = HtmlElementFactory::create(array('type' => 'checkbox', 'id' => 'description', 'name' => 'description', 'checked' => (int) $this->request->get['description'], 'value' => 1, 'label_text' => $this->language->get('entry_description'))); $this->data['model'] = HtmlElementFactory::create(array('type' => 'checkbox', 'id' => 'model', 'name' => 'model', 'checked' => (bool) $this->request->get['model'], 'value' => 1, 'label_text' => $this->language->get('entry_model'))); $this->data['submit'] = HtmlElementFactory::create(array('type' => 'button', 'name' => 'search_button', 'text' => $this->language->get('button_search'), 'icon' => 'icon-search', 'style' => 'button')); if (isset($this->request->get['keyword'])) { $this->loadModel('catalog/product'); $promoton = new APromotion(); if (isset($this->request->get['category_id'])) { $category_id = explode(',', $this->request->get['category_id']); end($category_id); $category_id = current($category_id); } else { $category_id = ''; } $product_total = $this->model_catalog_product->getTotalProductsByKeyword($this->request->get['keyword'], $category_id, isset($this->request->get['description']) ? $this->request->get['description'] : '', isset($this->request->get['model']) ? $this->request->get['model'] : ''); if ($product_total) { $url = ''; if (isset($this->request->get['category_id'])) { $url .= '&category_id=' . $this->request->get['category_id']; } if (isset($this->request->get['description'])) { $url .= '&description=' . $this->request->get['description']; } if (isset($this->request->get['model'])) { $url .= '&model=' . $this->request->get['model']; } $limit = $this->config->get('config_catalog_limit'); if (isset($this->request->get['limit']) && intval($this->request->get['limit']) > 0) { $limit = intval($this->request->get['limit']); if ($limit > 50) { $limit = 50; } } $this->loadModel('catalog/review'); $this->loadModel('tool/seo_url'); $products = array(); $results = $this->model_catalog_product->getProductsByKeyword($this->request->get['keyword'], $category_id, isset($this->request->get['description']) ? $this->request->get['description'] : '', isset($this->request->get['model']) ? $this->request->get['model'] : '', $sort, $order, ($page - 1) * $limit, $limit); //if single result, redirect to the product if (count($results) == 1) { $this->redirect($this->html->getSEOURL('product/product', '&product_id=' . key($results), '&encode')); } $resource = new AResource('image'); if (is_array($results) && $results) { foreach ($results as $result) { $thumbnail = $resource->getMainThumb('products', $result['product_id'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'), true); if ($this->config->get('enable_reviews')) { $rating = $this->model_catalog_review->getAverageRating($result['product_id']); } else { $rating = false; } $special = FALSE; $discount = $promoton->getProductDiscount($result['product_id']); if ($discount) { $price = $this->currency->format($this->tax->calculate($discount, $result['tax_class_id'], $this->config->get('config_tax'))); } else { $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))); $special = $promoton->getProductSpecial($result['product_id']); if ($special) { $special = $this->currency->format($this->tax->calculate($special, $result['tax_class_id'], $this->config->get('config_tax'))); } } $options = $this->model_catalog_product->getProductOptions($result['product_id']); if ($options) { $add = $this->html->getSEOURL('product/product', '&product_id=' . $result['product_id'], '&encode'); } else { if ($this->config->get('config_cart_ajax')) { $add = '#'; } else { $add = $this->html->getSecureURL('checkout/cart', '&product_id=' . $result['product_id'], '&encode'); } } $products[] = array('product_id' => $result['product_id'], 'name' => $result['name'], 'model' => $result['model'], 'rating' => $rating, 'stars' => sprintf($this->language->get('text_stars'), $rating), 'thumb' => $thumbnail, 'price' => $price, 'call_to_order' => $result['call_to_order'], 'options' => $options, 'special' => $special, 'href' => $this->html->getSEOURL('product/product', '&keyword=' . $this->request->get['keyword'] . $url . '&product_id=' . $result['product_id'], '&encode'), 'add' => $add, 'description' => html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')); } } $this->data['products'] = $products; 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; $url = ''; if (isset($this->request->get['keyword'])) { $url .= '&keyword=' . $this->request->get['keyword']; } if (isset($this->request->get['category_id'])) { $url .= '&category_id=' . $this->request->get['category_id']; } if (isset($this->request->get['description'])) { $url .= '&description=' . $this->request->get['description']; } if (isset($this->request->get['model'])) { $url .= '&model=' . $this->request->get['model']; } if (isset($this->request->get['page'])) { $url .= '&page=' . $this->request->get['page']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $sorts = array(); $sorts[] = array('text' => $this->language->get('text_default'), 'value' => 'p.sort_order-ASC', 'href' => $this->html->getURL('product/search', $url . '&sort=p.sort_order&order=ASC', '&encode')); $sorts[] = array('text' => $this->language->get('text_sorting_name_asc'), 'value' => 'pd.name-ASC', 'href' => $this->html->getURL('product/search', $url . '&sort=pd.name&order=ASC', '&encode')); $sorts[] = array('text' => $this->language->get('text_sorting_name_desc'), 'value' => 'pd.name-DESC', 'href' => $this->html->getURL('product/search', $url . '&sort=pd.name&order=DESC', '&encode')); $sorts[] = array('text' => $this->language->get('text_sorting_price_asc'), 'value' => 'p.price-ASC', 'href' => $this->html->getURL('product/search', $url . '&sort=p.price&order=ASC', '&encode')); $sorts[] = array('text' => $this->language->get('text_sorting_price_desc'), 'value' => 'p.price-DESC', 'href' => $this->html->getURL('product/search', $url . '&sort=p.price&order=DESC', '&encode')); $sorts[] = array('text' => $this->language->get('text_sorting_rating_desc'), 'value' => 'rating-DESC', 'href' => $this->html->getURL('product/search', $url . '&sort=rating&order=DESC', '&encode')); $sorts[] = array('text' => $this->language->get('text_sorting_rating_asc'), 'value' => 'rating-ASC', 'href' => $this->html->getURL('product/search', $url . '&sort=rating&order=ASC', '&encode')); $sorts[] = array('text' => $this->language->get('text_sorting_date_desc'), 'value' => 'date_modified-DESC', 'href' => $this->html->getSEOURL('product/search', $url . '&sort=date_modified&order=DESC', '&encode')); $sorts[] = array('text' => $this->language->get('text_sorting_date_asc'), 'value' => 'date_modified-ASC', 'href' => $this->html->getSEOURL('product/search', $url . '&sort=date_modified&order=ASC', '&encode')); $this->data['sorts'] = $sorts; $options = array(); foreach ($sorts as $item) { $options[$item['value']] = $item['text']; } $sorting = $this->html->buildSelectbox(array('name' => 'sort', 'options' => $options, 'value' => $sort . '-' . $order)); $this->data['sorting'] = $sorting; $url = ''; if (isset($this->request->get['keyword'])) { $url .= '&keyword=' . $this->request->get['keyword']; } if (isset($this->request->get['category_id'])) { $url .= '&category_id=' . $this->request->get['category_id']; } if (isset($this->request->get['description'])) { $url .= '&description=' . $this->request->get['description']; } if (isset($this->request->get['model'])) { $url .= '&model=' . $this->request->get['model']; } if (isset($this->request->get['sort'])) { $url .= '&sort=' . $this->request->get['sort']; } if (isset($this->request->get['order'])) { $url .= '&order=' . $this->request->get['order']; } if (isset($this->request->get['limit'])) { $url .= '&limit=' . $this->request->get['limit']; } $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' => $product_total, 'page' => $page, 'limit' => $limit, 'url' => $this->html->getURL('product/search', $url . '&page={page}', '&encode'), 'style' => 'pagination')); $this->data['sort'] = $sort; $this->data['order'] = $order; $this->data['limit'] = $limit; } } $this->data['review_status'] = $this->config->get('enable_reviews'); $this->view->batchAssign($this->data); $this->processTemplate('pages/product/search.tpl'); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
private function _getForm() { $this->data['token'] = $this->session->data['token']; $this->data['cancel'] = $this->html->getSecureURL('sale/coupon'); $this->data['error'] = $this->error; $cont_lang_id = $this->language->getContentLanguageID(); $this->view->assign('category_products_url', $this->html->getSecureURL('r/product/product/category', '&language_id=' . $cont_lang_id)); $this->document->initBreadcrumb(array('href' => $this->html->getSecureURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE)); $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('sale/coupon'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: ')); if (has_value($this->request->get['coupon_id']) && $this->request->is_GET()) { $coupon_info = $this->model_sale_coupon->getCouponByID($this->request->get['coupon_id']); } $this->data['languages'] = $this->language->getAvailableLanguages(); foreach ($this->fields as $f) { if (isset($this->request->post[$f])) { $this->data[$f] = $this->request->post[$f]; } elseif (isset($coupon_info) && isset($coupon_info[$f])) { $this->data[$f] = $coupon_info[$f]; } else { $this->data[$f] = ''; } } if (!is_array($this->data['coupon_description'])) { if (isset($this->request->get['coupon_id'])) { $this->data['coupon_description'] = $this->model_sale_coupon->getCouponDescriptions($this->request->get['coupon_id']); } else { $this->data['coupon_description'] = array(); } } if (!is_array($this->data['coupon_product'])) { if (isset($coupon_info)) { $this->data['coupon_product'] = $this->model_sale_coupon->getCouponProducts($this->request->get['coupon_id']); } else { $this->data['coupon_product'] = array(); } } //check if coupon is active based on dates and update status $now = time(); if ($this->data['date_start'] && dateISO2Int($this->data['date_start']) > $now || $this->data['date_end'] && dateISO2Int($this->data['date_end']) < $now) { $this->data['status'] = 0; } if (isset($this->request->post['date_start'])) { $this->data['date_start'] = dateDisplay2ISO($this->request->post['date_start'], $this->language->get('date_format_short')); } elseif (isset($coupon_info)) { $this->data['date_start'] = dateISO2Display($coupon_info['date_start'], $this->language->get('date_format_short')); } else { $this->data['date_start'] = dateInt2Display(time(), $this->language->get('date_format_short')); } if (isset($this->request->post['date_end'])) { $this->data['date_end'] = dateDisplay2ISO($this->request->post['date_end'], $this->language->get('date_format_short')); } elseif (isset($coupon_info)) { $this->data['date_end'] = dateISO2Display($coupon_info['date_end'], $this->language->get('date_format_short')); } else { $this->data['date_end'] = ''; } if (isset($this->data['uses_total']) && $this->data['uses_total'] == -1) { $this->data['uses_total'] = ''; } elseif (isset($this->data['uses_total']) && $this->data['uses_total'] == '') { $this->data['uses_total'] = 1; } if (isset($this->data['uses_customer']) && $this->data['uses_customer'] == -1) { $this->data['uses_customer'] = ''; } elseif (isset($this->data['uses_customer']) && $this->data['uses_customer'] == '') { $this->data['uses_customer'] = 1; } if (!has_value($this->data['status'])) { $this->data['status'] = 1; } if (!has_value($this->request->get['coupon_id'])) { $this->data['action'] = $this->html->getSecureURL('sale/coupon/insert'); $this->data['heading_title'] = $this->language->get('text_insert') . ' ' . $this->language->get('text_coupon'); $this->data['update'] = ''; $form = new AForm('ST'); } else { $this->data['action'] = $this->html->getSecureURL('sale/coupon/update', '&coupon_id=' . $this->request->get['coupon_id']); $this->data['heading_title'] = $this->language->get('text_edit') . ' ' . $this->language->get('text_coupon') . ' - ' . $this->data['coupon_description'][$cont_lang_id]['name']; $this->data['update'] = $this->html->getSecureURL('listing_grid/coupon/update_field', '&id=' . $this->request->get['coupon_id']); $form = new AForm('HS'); } $this->document->addBreadcrumb(array('href' => $this->data['action'], 'text' => $this->data['heading_title'], 'separator' => ' :: ', 'current' => true)); $form->setForm(array('form_name' => 'couponFrm', 'update' => $this->data['update'])); $this->data['form']['id'] = 'couponFrm'; $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'couponFrm', 'attr' => 'data-confirm-exit="true" class="aform form-horizontal"', 'action' => $this->data['action'])); $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_save'), 'style' => 'button1')); $this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'text' => $this->language->get('button_cancel'), 'style' => 'button2')); $this->data['form']['fields']['status'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'status', 'value' => $this->data['status'], 'style' => 'btn_switch')); $this->data['form']['fields']['name'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'coupon_description[' . $cont_lang_id . '][name]', 'value' => $this->data['coupon_description'][$cont_lang_id]['name'], 'required' => true, 'style' => 'large-field')); $this->data['form']['fields']['description'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'coupon_description[' . $cont_lang_id . '][description]', 'value' => $this->data['coupon_description'][$cont_lang_id]['description'], 'required' => true, 'style' => 'large-field')); $this->data['form']['fields']['code'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'code', 'value' => $this->data['code'], 'required' => true)); $this->data['form']['fields']['type'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'type', 'value' => $this->data['type'], 'options' => array('P' => $this->language->get('text_percent'), 'F' => $this->language->get('text_amount')))); $this->data['form']['fields']['discount'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'discount', 'value' => moneyDisplayFormat($this->data['discount']))); $this->data['form']['fields']['total'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'total', 'value' => moneyDisplayFormat($this->data['total']))); $this->data['form']['fields']['logged'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'logged', 'value' => $this->data['logged'], 'options' => array(1 => $this->language->get('text_yes'), 0 => $this->language->get('text_no')))); $this->data['form']['fields']['shipping'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'shipping', 'value' => $this->data['shipping'], 'options' => array(1 => $this->language->get('text_yes'), 0 => $this->language->get('text_no')))); $this->data['form']['fields']['date_start'] = $form->getFieldHtml(array('type' => 'date', 'name' => 'date_start', 'value' => $this->data['date_start'], 'default' => dateNowDisplay(), 'dateformat' => format4Datepicker($this->language->get('date_format_short')), 'highlight' => 'future', 'required' => true)); $this->data['form']['fields']['date_end'] = $form->getFieldHtml(array('type' => 'date', 'name' => 'date_end', 'value' => $this->data['date_end'], 'default' => '', 'dateformat' => format4Datepicker($this->language->get('date_format_short')), 'highlight' => 'pased', 'required' => true)); $this->data['form']['fields']['uses_total'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'uses_total', 'value' => $this->data['uses_total'])); $this->data['form']['fields']['uses_customer'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'uses_customer', 'value' => $this->data['uses_customer'])); if ($this->request->get['coupon_id']) { $this->loadModel('sale/order'); $total = $this->model_sale_order->getTotalOrders(array('filter_coupon_id' => $this->request->get['coupon_id'])); $this->data['form']['fields']['total_coupon_usage'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'total_coupon_usage', 'value' => (int) $total, 'attr' => 'disabled')); } //load only prior saved products $resource = new AResource('image'); $this->data['products'] = array(); if (count($this->data['coupon_product'])) { $this->loadModel('catalog/product'); $filter = array('subsql_filter' => 'p.product_id in (' . implode(',', $this->data['coupon_product']) . ')'); $results = $this->model_catalog_product->getProducts($filter); foreach ($results as $r) { $thumbnail = $resource->getMainThumb('products', $r['product_id'], (int) $this->config->get('config_image_grid_width'), (int) $this->config->get('config_image_grid_height'), true); $this->data['products'][$r['product_id']]['name'] = $r['name'] . " (" . $r['model'] . ")"; $this->data['products'][$r['product_id']]['image'] = $thumbnail['thumb_html']; } } $this->data['form']['fields']['product'] = $form->getFieldHtml(array('type' => 'multiselectbox', 'name' => 'coupon_product[]', 'value' => $this->data['coupon_product'], 'options' => $this->data['products'], 'style' => 'chosen', 'ajax_url' => $this->html->getSecureURL('r/product/product/products'), 'placeholder' => $this->language->get('text_select_from_lookup'))); $this->view->assign('help_url', $this->gen_help_url('coupon_edit')); $this->view->batchAssign($this->data); $this->processTemplate('pages/sale/coupon_form.tpl'); }
public function main() { $request = $this->request->get; //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); if ($this->config->get('embed_mode') == true) { $cart_rt = 'r/checkout/cart/embed'; //load special headers $this->addChild('responses/embed/head', 'head'); $this->addChild('responses/embed/footer', 'footer'); } else { $cart_rt = 'checkout/cart'; } $this->loadLanguage('product/manufacturer'); $this->loadModel('catalog/manufacturer'); $this->loadModel('catalog/product'); $this->loadModel('tool/seo_url'); $this->loadModel('tool/image'); $this->document->resetBreadcrumbs(); $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE)); if (isset($request['manufacturer_id'])) { $manufacturer_id = $request['manufacturer_id']; } else { $manufacturer_id = 0; } $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($manufacturer_id); if ($manufacturer_info) { $this->document->addBreadcrumb(array('href' => $this->html->getSEOURL('product/manufacturer', '&manufacturer_id=' . $request['manufacturer_id'], '&encode'), 'text' => $manufacturer_info['name'], 'separator' => $this->language->get('text_separator'))); $this->document->setTitle($manufacturer_info['name']); $this->view->assign('heading_title', $manufacturer_info['name']); $this->view->assign('text_sort', $this->language->get('text_sort')); $resource = new AResource('image'); $thumbnail = $resource->getMainThumb('manufacturers', $manufacturer_info['manufacturer_id'], $this->config->get('config_image_grid_width'), $this->config->get('config_image_grid_height')); if (!preg_match('/no_image/', $thumbnail['thumb_url'])) { $this->view->assign('manufacturer_icon', $thumbnail['thumb_url']); } $product_total = $this->model_catalog_product->getTotalProductsByManufacturerId($request['manufacturer_id']); if ($product_total) { if (isset($request['page'])) { $page = $request['page']; } else { $page = 1; } if (isset($request['limit'])) { $limit = (int) $request['limit']; $limit = $limit > 50 ? 50 : $limit; } else { $limit = $this->config->get('config_catalog_limit'); } if (isset($request['sort'])) { $sorting_href = $request['sort']; } else { $sorting_href = $this->config->get('config_product_default_sort_order'); } list($sort, $order) = explode("-", $sorting_href); if ($sort == 'name') { $sort = 'pd.' . $sort; } elseif (in_array($sort, array('sort_order', 'price'))) { $sort = 'p.' . $sort; } $this->loadModel('catalog/review'); $this->view->assign('button_add_to_cart', $this->language->get('button_add_to_cart')); $product_ids = $products = array(); $products_result = $this->model_catalog_product->getProductsByManufacturerId($request['manufacturer_id'], $sort, $order, ($page - 1) * $limit, $limit); foreach ($products_result as $result) { $product_ids[] = (int) $result['product_id']; } $products_info = $this->model_catalog_product->getProductsAllInfo($product_ids); $thumbnails = $resource->getMainThumbList('products', $product_ids, (int) $this->config->get('config_image_product_width'), (int) $this->config->get('config_image_product_height')); $stock_info = $this->model_catalog_product->getProductsStockInfo($product_ids); foreach ($products_result as $result) { $thumbnail = $thumbnails[$result['product_id']]; $rating = $products_info[$result['product_id']]['rating']; $special = FALSE; $discount = $products_info[$result['product_id']]['discount']; if ($discount) { $price = $this->currency->format($this->tax->calculate($discount, $result['tax_class_id'], $this->config->get('config_tax'))); } else { $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))); $special = $products_info[$result['product_id']]['special']; if ($special) { $special = $this->currency->format($this->tax->calculate($special, $result['tax_class_id'], $this->config->get('config_tax'))); } } $options = $products_info[$result['product_id']]['options']; if ($options) { $add = $this->html->getSEOURL('product/product', '&product_id=' . $result['product_id'], '&encode'); } else { if ($this->config->get('config_cart_ajax')) { $add = '#'; } else { $add = $this->html->getSecureURL($cart_rt, '&product_id=' . $result['product_id'], '&encode'); } } //check for stock status, availability and config $track_stock = false; $in_stock = false; $no_stock_text = $result['stock']; $total_quantity = 0; if ($stock_info[$result['product_id']]['subtract']) { $track_stock = true; $total_quantity = $stock_info[$result['product_id']]['quantity']; //we have stock or out of stock checkout is allowed if ($total_quantity > 0 || $this->config->get('config_stock_checkout')) { $in_stock = true; } } $products[] = array('product_id' => $result['product_id'], 'name' => $result['name'], 'blurb' => $result['blurb'], 'model' => $result['model'], 'rating' => $rating, 'stars' => sprintf($this->language->get('text_stars'), $rating), 'thumb' => $thumbnail, 'price' => $price, 'call_to_order' => $result['call_to_order'], 'options' => $options, 'special' => $special, 'href' => $this->html->getSEOURL('product/product', '&manufacturer_id=' . $request['manufacturer_id'] . '&product_id=' . $result['product_id'], '&encode'), 'add' => $add, 'description' => html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'), 'track_stock' => $track_stock, 'in_stock' => $in_stock, 'no_stock_text' => $no_stock_text, 'total_quantity' => $total_quantity); } $this->data['products'] = $products; if ($this->config->get('config_customer_price')) { $display_price = TRUE; } elseif ($this->customer->isLogged()) { $display_price = TRUE; } else { $display_price = FALSE; } $this->view->assign('display_price', $display_price); $url = ''; if (isset($request['page'])) { $url .= '&page=' . $request['page']; } if (isset($request['limit'])) { $url .= '&limit=' . $request['limit']; } $sorts = array(); $sorts[] = array('text' => $this->language->get('text_default'), 'value' => 'p.sort_order-ASC', 'href' => $this->html->getSEOURL('product/manufacturer', '&path=' . $request['manufacturer_id'] . '&sort=p.sort_order&order=ASC' . $url, '&encode')); $sorts[] = array('text' => $this->language->get('text_sorting_name_asc'), 'value' => 'pd.name-ASC', 'href' => $this->html->getSEOURL('product/manufacturer', '&manufacturer_id=' . $request['manufacturer_id'] . '&sort=pd.name&order=ASC' . $url, '&encode')); $sorts[] = array('text' => $this->language->get('text_sorting_name_desc'), 'value' => 'pd.name-DESC', 'href' => $this->html->getSEOURL('product/manufacturer', '&manufacturer_id=' . $request['manufacturer_id'] . '&sort=pd.name&order=DESC' . $url, '&encode')); $sorts[] = array('text' => $this->language->get('text_sorting_price_asc'), 'value' => 'p.price-ASC', 'href' => $this->html->getSEOURL('product/manufacturer', '&manufacturer_id=' . $request['manufacturer_id'] . '&sort=p.price&order=ASC' . $url, '&encode')); $sorts[] = array('text' => $this->language->get('text_sorting_price_desc'), 'value' => 'p.price-DESC', 'href' => $this->html->getSEOURL('product/manufacturer', '&manufacturer_id=' . $request['manufacturer_id'] . '&sort=p.price&order=DESC' . $url, '&encode')); $sorts[] = array('text' => $this->language->get('text_sorting_rating_desc'), 'value' => 'rating-DESC', 'href' => $this->html->getSEOURL('product/manufacturer', '&manufacturer_id=' . $request['manufacturer_id'] . '&sort=rating&order=DESC' . $url, '&encode')); $sorts[] = array('text' => $this->language->get('text_sorting_rating_asc'), 'value' => 'rating-ASC', 'href' => $this->html->getSEOURL('product/manufacturer', '&manufacturer_id=' . $request['manufacturer_id'] . '&sort=rating&order=ASC' . $url, '&encode')); $sorts[] = array('text' => $this->language->get('text_sorting_date_desc'), 'value' => 'date_modified-DESC', 'href' => $this->html->getSEOURL('product/manufacturer', '&manufacturer_id=' . $request['manufacturer_id'] . '&sort=date_modified&order=DESC', '&encode')); $sorts[] = array('text' => $this->language->get('text_sorting_date_asc'), 'value' => 'date_modified-ASC', 'href' => $this->html->getSEOURL('product/manufacturer', '&manufacturer_id=' . $request['manufacturer_id'] . '&sort=date_modified&order=ASC', '&encode')); $options = array(); foreach ($sorts as $item) { $options[$item['value']] = $item['text']; } $sorting = $this->html->buildSelectbox(array('name' => 'sort', 'options' => $options, 'value' => $sort . '-' . $order)); $this->view->assign('sorting', $sorting); $this->view->assign('url', $this->html->getSEOURL('product/manufacturer', '&manufacturer_id=' . $request['manufacturer_id'])); $pagination_url = $this->html->getSEOURL('product/manufacturer', '&manufacturer_id=' . $request['manufacturer_id'] . '&sort=' . $sorting_href . '&page={page}' . '&limit=' . $limit, '&encode'); $this->view->assign('pagination_bootstrap', $this->html->buildElement(array('type' => 'Pagination', 'name' => 'pagination', 'text' => $this->language->get('text_pagination'), 'text_limit' => $this->language->get('text_per_page'), 'total' => $product_total, 'page' => $page, 'limit' => $limit, 'url' => $pagination_url, 'style' => 'pagination'))); $this->view->assign('sort', $sort); $this->view->assign('order', $order); $this->view->setTemplate('pages/product/manufacturer.tpl'); } else { $this->document->setTitle($manufacturer_info['name']); $this->view->assign('heading_title', $manufacturer_info['name']); $this->view->assign('text_error', $this->language->get('text_empty')); $continue = $this->html->buildElement(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'); } } else { $url = ''; if (isset($request['sort'])) { $url .= '&sort=' . $request['sort']; } if (isset($request['order'])) { $url .= '&order=' . $request['order']; } if (isset($request['page'])) { $url .= '&page=' . $request['page']; } $this->document->addBreadcrumb(array('href' => $this->html->getSEOURL('product/manufacturer', '&manufacturer_id=' . $manufacturer_id . $url, '&encode'), '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 = $this->html->buildElement(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->data['review_status'] = $this->config->get('enable_reviews'); $this->view->batchAssign($this->data); $this->processTemplate(); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function get_cart_details($totals) { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); if (!$this->view->isTemplateExists('responses/checkout/cart_details.tpl')) { return ''; } $resource = new AResource('image'); foreach ($this->cart->getProducts() as $result) { $option_data = array(); $thumbnail = $resource->getMainThumb('products', $result['product_id'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'), true); foreach ($result['option'] as $option) { $value = $option['value']; // hide binary value for checkbox if ($option['element_type'] == 'C' && in_array($value, array(0, 1))) { $value = ''; } // strip long textarea value if ($option['element_type'] == 'T') { $title = strip_tags($value); $title = str_replace('\\r\\n', "\n", $title); $value = str_replace('\\r\\n', "\n", $value); if (mb_strlen($value) > 64) { $value = mb_substr($value, 0, 64) . '...'; } } $option_data[] = array('name' => $option['name'], 'value' => $value, 'title' => $title); } $qty += $result['quantity']; $this->data['products'][] = array('key' => $result['key'], 'name' => $result['name'], 'option' => $option_data, 'quantity' => $result['quantity'], 'stock' => $result['stock'], 'price' => $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))), 'href' => $this->html->getSEOURL('product/product', '&product_id=' . $result['product_id']), 'thumb' => $thumbnail); } $this->data['totals'] = $totals['total_data']; $this->data['subtotal'] = $this->currency->format($this->tax->calculate($totals['total'], $result['tax_class_id'], $this->config->get('config_tax'))); $this->data['taxes'] = $totals['taxes']; $this->data['view'] = $this->html->getURL('checkout/cart'); $this->view->batchAssign($this->data); //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->processTemplate('responses/checkout/cart_details.tpl'); }