Ejemplo n.º 1
0
 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();
 }
Ejemplo n.º 2
0
 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__);
 }
Ejemplo n.º 3
0
 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));
 }
Ejemplo n.º 4
0
 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));
 }
Ejemplo n.º 5
0
 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__);
 }
Ejemplo n.º 6
0
 protected function getBlockContent($instance_id)
 {
     $block_info = $this->layout->getBlockDetails($instance_id);
     $custom_block_id = $block_info['custom_block_id'];
     $descriptions = $this->layout->getBlockDescriptions($custom_block_id);
     if ($descriptions[$this->config->get('storefront_language_id')]) {
         $key = $this->config->get('storefront_language_id');
     } else {
         $key = $descriptions ? key($descriptions) : null;
     }
     $this->loadModel('extension/banner_manager');
     $results = $this->model_extension_banner_manager->getBanners($custom_block_id);
     $banners = array();
     if ($results) {
         $rl = new AResource('image');
         foreach ($results as $row) {
             if ($row['banner_type'] == 1) {
                 // if graphic type
                 /**
                  * @var array
                  */
                 $row['images'] = $rl->getResourceAllObjects('banners', $row['banner_id']);
                 //add click registration wrapper to each URL
                 //NOTE: You can remove below line to use tracking javascript instead. Javascript tracks HTML banner clicks
                 $row['target_url'] = $this->html->getURL('r/extension/banner_manager/click', '&banner_id=' . $row['banner_id'], true);
             } else {
                 $row['description'] = html_entity_decode($row['description']);
             }
             $banners[] = $row;
         }
     }
     $output = array('title' => $key ? $descriptions[$key]['title'] : '', 'content' => $banners, 'block_wrapper' => $key ? $descriptions[$key]['block_wrapper'] : 0, 'block_framed' => $key ? (int) $descriptions[$key]['block_framed'] : 0);
     return $output;
 }
Ejemplo n.º 7
0
 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__);
 }
Ejemplo n.º 8
0
 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 ? '&nbsp;<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));
 }
Ejemplo n.º 9
0
 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__);
 }
Ejemplo n.º 10
0
 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);
     $product_ids = array();
     foreach ($results as $result) {
         $product_ids[] = (int) $result['product_id'];
     }
     $resource = new AResource('image');
     $thumbnails = $resource->getMainThumbList('products', $product_ids, $this->config->get('config_image_grid_width'), $this->config->get('config_image_grid_height'));
     $i = 0;
     foreach ($results as $result) {
         $thumbnail = $thumbnails[$result['product_id']];
         $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 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__);
 }
Ejemplo n.º 12
0
 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;
 }
Ejemplo n.º 13
0
function buildStoreFrontMenuTree($menu_array, $level = 0)
{
    $menu_array = (array) $menu_array;
    if (!$menu_array) {
        return '';
    }
    $result = '';
    //for submenus build new UL node
    if ($level > 0) {
        $result .= "<ul class='sub_menu dropdown-menu'>\r\n";
    }
    $registry = Registry::getInstance();
    $logged = $registry->get('customer')->isLogged();
    $ar = new AResource('image');
    foreach ($menu_array as $item) {
        if ($logged && $item['id'] == 'login' || !$logged && $item['id'] == 'logout') {
            continue;
        }
        //build appropriate menu id and classes for css controll
        $id = empty($item['id']) ? '' : ' data-id="menu_' . $item['id'] . '" ';
        // li ID
        if ($level != 0) {
            if (empty($item['children'])) {
                $class = $item['icon'] ? ' class="top nobackground"' : ' class="sub menu_' . $item['id'] . '" ';
            } else {
                $class = $item['icon'] ? ' class="parent nobackground" ' : ' class="parent menu_' . $item['id'] . '" ';
            }
        } else {
            $class = $item['icon'] ? ' class="top nobackground"' : ' class="top menu_' . $item['id'] . '" ';
        }
        $href = empty($item['href']) ? '' : ' href="' . $item['href'] . '" ';
        //construct HTML
        $current = '';
        if ($item['current']) {
            $current = 'current';
        }
        $result .= '<li ' . $id . ' class="dropdown ' . $current . '">';
        $result .= '<a ' . $class . $href . '>';
        //check icon rl type html, image or none.
        $rl_id = $item['icon_rl_id'];
        if ($rl_id) {
            $resource = $ar->getResource($rl_id);
            if ($resource['resource_path'] && is_file(DIR_RESOURCE . 'image/' . $resource['resource_path'])) {
                $result .= '<img class="menu_image" src="' . HTTPS_DIR_RESOURCE . 'image/' . $resource['resource_path'] . '" alt="" />';
            } elseif ($resource['resource_code']) {
                $result .= $resource['resource_code'];
            }
        }
        $result .= '<span class="menu_text">' . $item['text'] . '</span></a>';
        //if children build inner clild tree
        if (!empty($item['children'])) {
            $result .= "\r\n" . buildStoreFrontMenuTree($item['children'], $level + 1);
        }
        $result .= "</li>\r\n";
    }
    if ($level > 0) {
        $result .= "</ul>\r\n";
    }
    return $result;
}
Ejemplo n.º 14
0
 public function get()
 {
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $product_id = $this->request->get['product_id'];
     if (!$product_id) {
         $this->rest->setResponseData(array('Error' => 'Missing product ID as a required parameter'));
         $this->rest->sendResponse(200);
         return null;
     }
     $products = array();
     $this->loadModel('catalog/review');
     $this->loadModel('catalog/product');
     $results = $this->model_catalog_product->getProductRelated($product_id);
     foreach ($results as $result) {
         $resource = new AResource('image');
         $sizes = array('main' => array('width' => $this->config->get('config_image_related_width'), 'height' => $this->config->get('config_image_related_height')), 'thumb' => array('width' => $this->config->get('config_image_thumb_width'), 'height' => $this->config->get('config_image_thumb_height')));
         $image = $resource->getResourceAllObjects('products', $result['product_id'], $sizes, 1);
         if ($this->config->get('enable_reviews')) {
             $rating = $this->model_catalog_review->getAverageRating($result['product_id']);
         } else {
             $rating = false;
         }
         $special = FALSE;
         $discount = $this->model_catalog_product->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 = $this->model_catalog_product->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 = 'a/product/product';
         } else {
             $add = 'a/checkout/cart';
         }
         $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, 'options' => $options, 'special' => $special, 'image' => $image['main_url'], 'thumb' => $image['thumb_url'], 'cart_add_rt' => $add);
     }
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->rest->setResponseData(array('total' => count($products), 'related_products' => $products));
     $this->rest->sendResponse(200);
 }
Ejemplo n.º 15
0
 public function main()
 {
     $request = $this->request->get;
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     //HTML cache only for non-customer
     if (!$this->customer->isLogged() && !$this->customer->isUnauthCustomer()) {
         $allowed_cache_keys = array('path');
         $cache_val = array('path' => $request['path']);
         $this->buildHTMLCacheKey($allowed_cache_keys, $cache_val);
         if ($this->html_cache()) {
             return;
         }
     }
     $this->view->assign('heading_title', $this->language->get('heading_title', 'blocks/category'));
     $this->loadModel('catalog/category');
     if (isset($request['path'])) {
         $this->path = explode('_', $request['path']);
         $this->category_id = end($this->path);
     }
     $this->view->assign('selected_category_id', $this->category_id);
     $this->view->assign('path', $request['path']);
     //load main lavel categories
     $all_categories = $this->model_catalog_category->getAllCategories();
     //build thumbnails list
     $category_ids = array();
     foreach ($all_categories as $category) {
         $category_ids[] = $category['category_id'];
     }
     $resource = new AResource('image');
     $this->thumbnails = $resource->getMainThumbList('categories', $category_ids, $this->config->get('config_image_category_width'), $this->config->get('config_image_category_height'));
     //Build category tree
     $this->_buildCategoryTree($all_categories);
     $categories = $this->_buildNestedCategoryList();
     $this->view->assign('categories', $categories);
     //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->view->assign('home_href', $this->html->getSEOURL('index/home'));
     $this->processTemplate();
     //init controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Ejemplo n.º 16
0
 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__);
 }
Ejemplo n.º 17
0
 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) {
         $product_ids = array();
         foreach ($results as $result) {
             $product_ids[] = (int) $result['product_id'];
         }
         $resource = new AResource('image');
         $thumbnails = $resource->getMainThumbList('products', $product_ids, $this->config->get('config_image_thumb_width'), $this->config->get('config_image_thumb_height'));
         foreach ($results as $result) {
             $thumbnail = $thumbnails[$result['product_id']];
             $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);
 }
Ejemplo n.º 18
0
 public function get()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $product_id = $this->request->get['product_id'];
     $resource_type = $this->request->get['resource_type'];
     if (!$product_id) {
         $this->rest->setResponseData(array('Error' => 'Missing product ID as a required parameter'));
         $this->rest->sendResponse(200);
         return;
     }
     $resources = array();
     $resource = new AResource('image');
     if ($resource_type == 'image') {
         $images = array();
         $results = $resource->getResources('products', $product_id, $this->config->get('storefront_language_id'));
         foreach ($results as $result) {
             $thumbnail = $resource->getResourceThumb($result['resource_id'], $this->config->get('config_image_additional_width'), $this->config->get('config_image_additional_height'));
             if ($thumbnail) {
                 $images[] = array('origial' => HTTP_DIR_RESOURCE . 'image/' . $result['resource_path'], 'thumb' => $thumbnail);
             }
         }
         $resources = $images;
     } else {
         if ($resource_type == 'pdf') {
             // TODO Add support to other types to return files or codes
         } else {
             $resource = new AResource('image');
             //Getting all available types. NOTE there is no easy way, yet, to tell what resources are available in what type for given product.
             //This is possible only in admin for now
             $resources = $resource->getAllResourceTypes();
         }
     }
     //init controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->rest->setResponseData(array('total' => count($resources), 'resources' => $resources));
     $this->rest->sendResponse(200);
 }
Ejemplo n.º 19
0
 public function getSettingImage($rl_image)
 {
     $image_data = array();
     if (!has_value($rl_image)) {
         return array();
     }
     $resource = new AResource('image');
     if (is_numeric($rl_image)) {
         // consider this is a pure image resource ID
         $image_data = $resource->getResource($rl_image);
     } else {
         $image_data = $resource->getResource($resource->getIdFromHexPath(str_replace('image/', '', $rl_image)));
     }
     return $image_data;
 }
Ejemplo n.º 20
0
 /**
  * @deprecated since 1.1.7
  * @param int $parent_id
  * @param string $path
  * @return array
  */
 public function getCategoriesDetails($parent_id = 0, $path = '')
 {
     $language_id = (int) $this->config->get('storefront_language_id');
     $store_id = (int) $this->config->get('config_store_id');
     $this->load->model('catalog/product');
     $this->load->model('catalog/manufacturer');
     $resource = new AResource('image');
     $cash_name = 'category.details.' . $parent_id;
     $categories = $this->cache->get($cash_name, $language_id, $store_id);
     if (count($categories)) {
         return $categories;
     }
     $results = $this->getCategories($parent_id);
     foreach ($results as $result) {
         if (!$path) {
             $new_path = $result['category_id'];
         } else {
             $new_path = $path . '_' . $result['category_id'];
         }
         $brands = array();
         if ($parent_id == 0) {
             $data['filter'] = array();
             $data['filter']['category_id'] = $result['category_id'];
             $data['filter']['status'] = 1;
             $prods = $this->model_catalog_product->getProducts($data);
             foreach ($prods as $prod) {
                 if ($prod['manufacturer_id']) {
                     $brand = $this->model_catalog_manufacturer->getManufacturer($prod['manufacturer_id']);
                     $brands[$prod['manufacturer_id']] = array('name' => $brand['name'], 'href' => $this->html->getSEOURL('product/manufacturer', '&manufacturer_id=' . $brand['manufacturer_id'], '&encode'));
                 }
             }
         }
         $thumbnail = $resource->getMainThumb('categories', $result['category_id'], $this->config->get('config_image_category_width'), $this->config->get('config_image_category_height'), true);
         $categories[] = array('category_id' => $result['category_id'], 'name' => $result['name'], 'children' => $this->getCategoriesDetails($result['category_id'], $new_path), 'href' => $this->html->getSEOURL('product/category', '&path=' . $new_path, '&encode'), 'brands' => $brands, 'product_count' => count($prods), 'thumb' => $thumbnail['thumb_url']);
     }
     $this->cache->set($cash_name, $categories, $language_id, $store_id);
     return $categories;
 }
Ejemplo n.º 21
0
 /**
  * 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');
 }
Ejemplo n.º 22
0
 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__);
 }
Ejemplo n.º 23
0
 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') . '&nbsp;' . $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') . '&nbsp;' . $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 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__);
 }
Ejemplo n.º 25
0
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('catalog/files');
     $this->document->setTitle($this->language->get('heading_title'));
     $this->loadModel('catalog/product');
     $this->loadModel('catalog/download');
     $product_id = $this->request->get['product_id'];
     if (!$product_id) {
         $this->redirect($this->html->getSecureURL('catalog/product'));
     }
     if (has_value($product_id) && $this->request->is_GET()) {
         $product_info = $this->model_catalog_product->getProduct($product_id);
         if (!$product_info) {
             $this->session->data['warning'] = $this->language->get('error_product_not_found');
             $this->redirect($this->html->getSecureURL('catalog/product'));
         }
         // remove
         if (has_value($this->request->get['act']) && $this->request->get['act'] == 'delete') {
             $download_info = $this->model_catalog_download->getDownload($this->request->get['download_id']);
             $map_list = $this->model_catalog_download->getDownloadMapList($this->request->get['download_id']);
             if (sizeof($map_list) == 1 && key($map_list) == $product_id || $download_info['shared'] != 1) {
                 $this->model_catalog_download->deleteDownload($this->request->get['download_id']);
             } else {
                 $this->model_catalog_download->unmapDownload($this->request->get['download_id'], $product_id);
             }
             $this->session->data['success'] = $this->language->get('text_success_remove');
             $this->redirect($this->html->getSecureURL('catalog/product_files', '&product_id=' . $product_id));
         }
     }
     //Downloads disabled. Warn user
     if (!$this->config->get('config_download')) {
         $this->error['warning'] = $this->html->convertLinks($this->language->get('error_downloads_disabled'));
     }
     if ($this->request->is_POST() && $this->_validateForm()) {
         foreach ($this->request->post['selected'] as $id) {
             $this->model_catalog_download->mapDownload($id, $product_id);
         }
         $this->session->data['success'] = $this->language->get('text_map_success');
         $this->redirect($this->html->getSecureURL('catalog/product_files', '&product_id=' . $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->data['product_description'] = $this->model_catalog_product->getProductDescriptions($product_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('catalog/product'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: '));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('catalog/product/update', '&product_id=' . $product_id), 'text' => $this->language->get('text_edit') . '&nbsp;' . $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_files', '&product_id=' . $product_id), 'text' => $this->language->get('tab_files'), 'separator' => ' :: ', 'current' => true));
     $this->data['active'] = 'files';
     //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->loadModel('catalog/download');
     $this->data['downloads'] = array();
     $this->data['product_files'] = $this->model_catalog_download->getProductDownloadsDetails($product_id);
     $rl = new AResource('download');
     $rl_dir = $rl->getTypeDir();
     foreach ($this->data['product_files'] as &$file) {
         $resource_id = $rl->getIdFromHexPath(str_replace($rl_dir, '', $file['filename']));
         $resource_info = $rl->getResource($resource_id);
         $thumbnail = $rl->getResourceThumb($resource_id, $this->config->get('config_image_grid_width'), $this->config->get('config_image_grid_height'));
         if ($resource_info['resource_path']) {
             $file['icon'] = $this->html->buildResourceImage(array('url' => $thumbnail, 'width' => $this->config->get('config_image_grid_width'), 'height' => $this->config->get('config_image_grid_height'), 'attr' => 'alt="' . $resource_info['title'] . '"'));
         } else {
             $file['icon'] = $resource_info['resource_code'];
         }
         $file['status'] = $file['status'] ? $this->language->get('text_enabled') : $this->language->get('text_disabled');
         $file['button_edit'] = $this->html->buildElement(array('type' => 'button', 'text' => $this->language->get('button_edit'), 'href' => $this->html->getSecureURL('r/product/product/buildDownloadForm', '&product_id=' . $product_id . '&download_id=' . $file['download_id'])));
         $map_list = $this->model_catalog_download->getDownloadMapList($file['download_id']);
         if (sizeof($map_list) == 1 && key($map_list) == $product_id || $file['shared'] != 1) {
             $text = $this->language->get('button_delete');
             $icon = 'fa-trash-o';
         } else {
             $text = $this->language->get('button_unmap');
             $icon = 'fa-chain-broken';
         }
         $file['button_delete'] = $this->html->buildElement(array('type' => 'button', 'text' => $text, 'href' => $this->html->getSecureURL('catalog/product_files', '&act=delete&product_id=' . $product_id . '&download_id=' . $file['download_id']), 'icon' => $icon));
         $orders_count = $this->model_catalog_download->getTotalOrdersWithProduct($product_id);
         if ($orders_count) {
             $file['push_to_customers'] = $this->html->buildElement(array('type' => 'button', 'name' => 'push_to_customers', 'text' => sprintf($this->language->get('text_push_to_orders'), $orders_count), 'title' => $this->language->get('text_push'), 'icon' => 'fa-share-alt-square', 'href' => $this->html->getSecureURL('catalog/product_files/pushToCustomers', '&product_id=' . $product_id . '&download_id=' . $file['download_id']), 'attr' => 'data-orders-count="' . $orders_count . '"'));
         }
     }
     unset($file);
     $this->data['button_add_file'] = $this->html->buildElement(array('type' => 'button', 'text' => $this->language->get('text_add_file'), 'href' => $this->html->getSecureURL('r/product/product/buildDownloadForm', '&product_id=' . $product_id)));
     if ($this->config->get('config_embed_status')) {
         $this->data['embed_url'] = $this->html->getSecureURL('common/do_embed/product', '&product_id=' . $product_id);
     }
     $this->addChild('pages/catalog/product_summary', 'summary_form', 'pages/catalog/product_summary.tpl');
     $this->view->assign('help_url', $this->gen_help_url('product_files'));
     $this->view->assign('form_language_switch', $this->html->getContentLanguageSwitcher());
     $this->view->batchAssign($this->data);
     $this->processTemplate('pages/catalog/product_files.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Ejemplo n.º 26
0
 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);
 }
Ejemplo n.º 27
0
 private function _getBlockForm()
 {
     if (isset($this->session->data['warning'])) {
         $this->data['error_warning'] = $this->session->data['warning'];
         $this->session->data['warning'] = '';
     } else {
         $this->data['error_warning'] = '';
     }
     $this->load->library('json');
     $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('design/blocks'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: '));
     $this->data['cancel'] = $this->html->getSecureURL('design/blocks');
     $custom_block_id = (int) $this->request->get['custom_block_id'];
     // need to get data of custom listing
     $options_list = array();
     if ($custom_block_id) {
         $lm = new ALayoutManager();
         $block_info = $lm->getBlockDescriptions($custom_block_id);
         $language_id = $this->session->data['content_language_id'];
         if (!isset($block_info[$language_id])) {
             $language_id = key($block_info);
         }
         foreach ($block_info[$language_id] as $k => $v) {
             $this->data[$k] = $v;
         }
         $content = $block_info[$this->language->getContentLanguageID()]['content'];
         if ($content) {
             $content = unserialize($content);
         } else {
             $content = current($block_info);
             $content = unserialize($content['content']);
         }
         $this->data['banner_group_name'] = $content['banner_group_name'];
         $lm = new AListingManager($this->request->get['custom_block_id']);
         $list = $lm->getCustomList();
         $options_list = array();
         if ($list) {
             foreach ($list as $row) {
                 $options_list[(int) $row['id']] = array();
             }
             $ids = array_keys($options_list);
             $assigned_banners = $this->model_extension_banner_manager->getBanners(array('subsql_filter' => 'b.banner_id IN (' . implode(', ', $ids) . ')'));
             $resource = new AResource('image');
             $thumbnails = $resource->getMainThumbList('banners', $ids, $this->config->get('config_image_grid_width'), $this->config->get('config_image_grid_height'), false);
             foreach ($assigned_banners as $banner) {
                 $id = $banner['banner_id'];
                 if (in_array($id, $ids)) {
                     $thumbnail = $thumbnails[$banner['banner_id']];
                     $icon = $thumbnail['thumb_html'] ? $thumbnail['thumb_html'] : '<i class="fa fa-code fa-4x"></i>&nbsp;';
                     $options_list[$id] = array('image' => $icon, 'id' => $id, 'name' => $banner['name'], 'sort_order' => (int) $banner['sort_order']);
                 }
             }
         }
     }
     if (!$custom_block_id) {
         $this->data['action'] = $this->html->getSecureURL('extension/banner_manager/insert_block');
         $this->data['form_title'] = $this->language->get('text_create_block', 'banner_manager/banner_manager');
         $this->data['update'] = '';
         $form = new AForm('ST');
     } else {
         $this->data['action'] = $this->html->getSecureURL('extension/banner_manager/edit_block', '&custom_block_id=' . $custom_block_id);
         $this->data['form_title'] = $this->language->get('text_edit') . ' ' . $this->data['name'];
         $this->data['update'] = $this->html->getSecureURL('listing_grid/blocks_grid/update_field', '&custom_block_id=' . $custom_block_id);
         $form = new AForm('HS');
     }
     $this->document->addBreadcrumb(array('href' => $this->data['action'], 'text' => $this->data['form_title'], 'separator' => ' :: ', 'current' => true));
     $form->setForm(array('form_name' => 'BannerBlockFrm', 'update' => $this->data['update']));
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'BannerBlockFrm', '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', 'name' => 'cancel', 'text' => $this->language->get('button_cancel'), 'style' => 'button2'));
     if ($custom_block_id) {
         $this->data['form']['fields']['block_status'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'block_status', 'value' => $this->data['status'], 'style' => 'btn_switch'));
         $this->data['form']['text']['block_status'] = $this->html->convertLinks($this->language->get('entry_block_status'));
         $this->data['form']['fields']['block_status_note'] = '';
         $this->data['form']['text']['block_status_note'] = $this->html->convertLinks($this->language->get('entry_block_status_note'));
     }
     $this->data['form']['fields']['block_name'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'block_id', 'value' => $this->data['block_id']));
     $this->data['form']['fields']['block_name'] .= $form->getFieldHtml(array('type' => 'input', 'name' => 'block_name', 'value' => $this->data['name'], 'multilingual' => true, 'required' => true));
     $this->data['form']['text']['block_name'] = $this->language->get('entry_block_name');
     $this->data['form']['fields']['block_title'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'block_title', 'required' => true, 'multilingual' => true, 'value' => $this->data['title']));
     $this->data['form']['text']['block_title'] = $this->language->get('entry_block_title');
     // list of templates for block
     $tmpl_ids = $this->extensions->getInstalled('template');
     $tmpl_ids[] = 'default';
     $this->data['block_wrappers'] = array();
     foreach ($tmpl_ids as $tmpl_id) {
         // for tpls of block that stores in db
         $layout_manager = new ALayoutManager($tmpl_id);
         $block = $layout_manager->getBlockByTxtId('banner_block');
         $block_templates = (array) $layout_manager->getBlockTemplates($block['block_id']);
         foreach ($block_templates as $item) {
             if ($item['template']) {
                 $this->data['block_wrappers'][$item['template']] = $item['template'];
             }
         }
         //Automatic block template selection mode based on parent is limited to 1 template per location
         //To extend, allow custom block's template to be selected to suppress automatic selection
         //for tpls that stores in main.php (other extensions templates)
         $ext_tpls = $this->extensions->getExtensionTemplates();
         foreach ($ext_tpls as $section) {
             foreach ($section as $s => $tpls) {
                 if ($s != 'storefront') {
                     continue;
                 }
                 foreach ($tpls as $tpl) {
                     if (isset($this->data['block_wrappers'][$tpl]) || strpos($tpl, 'blocks/banner_block/') === false) {
                         continue;
                     }
                     $this->data['block_wrappers'][$tpl] = $tpl;
                 }
             }
         }
         $tpls = glob(DIR_STOREFRONT . 'view/*/template/blocks/banner_block/*.tpl');
         foreach ($tpls as $tpl) {
             $pos = strpos($tpl, 'blocks/banner_block/');
             $tpl = substr($tpl, $pos);
             if (!isset($this->data['block_wrappers'][$tpl])) {
                 $this->data['block_wrappers'][$tpl] = $tpl;
             }
         }
     }
     ksort($this->data['block_wrappers']);
     array_unshift($this->data['block_wrappers'], $this->language->get('text_automatic'));
     if ($this->data['block_wrapper'] && !isset($this->data['block_wrappers'][$this->data['block_wrapper']])) {
         $this->data['block_wrappers'] = array_merge(array($this->data['block_wrapper'] => $this->data['block_wrapper']), $this->data['block_wrappers']);
     }
     $this->data['form']['fields']['block_wrapper'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'block_wrapper', 'options' => $this->data['block_wrappers'], 'value' => $this->data['block_wrapper']));
     $this->data['form']['text']['block_wrapper'] = $this->language->get('entry_block_wrapper');
     $this->data['form']['fields']['block_framed'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'block_framed', 'value' => $this->data['block_framed'], 'style' => 'btn_switch'));
     $this->data['form']['text']['block_framed'] = $this->language->get('entry_block_framed');
     $this->data['form']['fields']['block_description'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'block_description', 'value' => $this->data['description'], 'attr' => ' style="height: 50px;"', 'multilingual' => true));
     $this->data['form']['text']['block_description'] = $this->language->get('entry_block_description');
     // groups of banners
     $this->loadModel('extension/banner_manager');
     $result = $this->model_extension_banner_manager->getBannerGroups();
     $groups = array('0' => $this->language->get('text_select'));
     if ($result) {
         foreach ($result as $row) {
             $groups[$row['banner_group_name']] = $row['banner_group_name'];
         }
     }
     $this->data['form']['fields']['banner_group_name'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'banner_group_name', 'options' => $groups, 'value' => $this->data['banner_group_name'], 'style' => 'no-save'));
     $this->data['form']['text']['banner_group_name'] = $this->language->get('entry_banner_group_name');
     $this->data['form']['text']['listed_banners'] = $this->language->get('entry_banners_selected');
     //load only prior saved products
     $this->data['banners'] = array();
     $this->data['form']['fields']['listed_banners'] = $form->getFieldHtml(array('type' => 'multiselectbox', 'name' => 'block_banners[]', 'value' => $ids, 'options' => $options_list, 'style' => 'no-save chosen', 'ajax_url' => $this->html->getSecureURL('listing_grid/banner_manager/banners'), 'placeholder' => $this->language->get('text_select_from_lookup')));
     $this->view->batchAssign($this->language->getASet());
     $this->view->batchAssign($this->data);
     $this->view->assign('form_language_switch', $this->html->getContentLanguageSwitcher());
     $this->view->assign('language_code', $this->session->data['language']);
     $this->view->assign('help_url', $this->gen_help_url('banner_edit'));
     $this->view->assign('rl', $this->html->getSecureURL('common/resource_library', '&object_name=banners&type=image&mode=url'));
     $this->processTemplate('pages/extension/banner_manager_block_form.tpl');
 }
Ejemplo n.º 28
0
 /**
  * @throws AException
  * NOTE: this method have a few hk_processData calls.
  */
 public function main()
 {
     $error_msg = array();
     $cart_rt = 'checkout/cart';
     $product_rt = 'product/product';
     $checkout_rt = 'checkout/shipping';
     $home_rt = 'index/home';
     //is this an embed mode
     if ($this->config->get('embed_mode') == true) {
         $cart_rt = 'r/checkout/cart/embed';
     }
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     //process all possible requests first
     if ($this->request->is_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->extensions->hk_ProcessData($this, 'add_product');
         $this->redirect($this->html->getSecureURL($cart_rt));
     } else {
         if ($this->request->is_GET() && isset($this->request->get['remove'])) {
             //remove product with button claick.
             $this->cart->remove($this->request->get['remove']);
             $this->extensions->hk_ProcessData($this, 'remove_product');
             $this->redirect($this->html->getSecureURL($cart_rt));
         } else {
             if ($this->request->is_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');
                     unset($this->session->data['success']);
                     //process data
                     $this->extensions->hk_ProcessData($this, 'apply_coupon');
                 }
                 if ($this->error['error_warning']) {
                     $error_msg[] = $this->error['error_warning'];
                 }
                 if (isset($this->request->post['quantity'])) {
                     //we update cart
                     if (!is_array($this->request->post['quantity'])) {
                         $this->loadModel('catalog/product', 'storefront');
                         $product_id = $this->request->post['product_id'];
                         if (isset($this->request->post['option'])) {
                             $options = $this->request->post['option'];
                         } else {
                             $options = array();
                         }
                         //for FILE-attributes
                         if (has_value($this->request->files['option']['name'])) {
                             $fm = new AFile();
                             foreach ($this->request->files['option']['name'] as $id => $name) {
                                 $attribute_data = $this->model_catalog_product->getProductOption($product_id, $id);
                                 $attribute_data['settings'] = unserialize($attribute_data['settings']);
                                 $file_path_info = $fm->getUploadFilePath($attribute_data['settings']['directory'], $name);
                                 $options[$id] = $file_path_info['name'];
                                 if (!has_value($name)) {
                                     continue;
                                 }
                                 if ($attribute_data['required'] && !$this->request->files['option']['size'][$id]) {
                                     $this->session->data['error'] = $this->language->get('error_required_options');
                                     $this->redirect($_SERVER['HTTP_REFERER']);
                                 }
                                 $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_rt, '&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']);
                 }
                 if (isset($this->request->post['remove'])) {
                     foreach (array_keys($this->request->post['remove']) as $key) {
                         $this->cart->remove($key);
                     }
                 }
                 $this->extensions->hk_ProcessData($this);
                 //next page is requested after cart update
                 if (isset($this->request->post['next_step'])) {
                     $this->redirect($this->html->getSecureURL($this->request->post['next_step']));
                 }
                 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($cart_rt));
                 }
             }
         }
     }
     $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', 'storefront');
         $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($cart_rt)));
         $cart_products = $this->cart->getProducts();
         $product_ids = array();
         foreach ($cart_products as $result) {
             $product_ids[] = (int) $result['product_id'];
         }
         $resource = new AResource('image');
         $thumbnails = $resource->getMainThumbList('products', $product_ids, $this->config->get('config_image_cart_width'), $this->config->get('config_image_cart_height'));
         $products = array();
         foreach ($cart_products as $result) {
             $option_data = array();
             $thumbnail = $thumbnails[$result['product_id']];
             foreach ($result['option'] as $option) {
                 $title = '';
                 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);
             }
             $products[] = array('remove' => $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'remove[' . $result['key'] . ']')), 'remove_url' => $this->html->getSecureURL($cart_rt, '&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_rt, '&key=' . $result['key'], 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('&amp;', '&', $this->session->data['redirect']);
             unset($this->session->data['redirect']);
         } else {
             $this->data['continue'] = $this->html->getURL($home_rt);
         }
         $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_rt);
         $this->data['checkout_rt'] = $checkout_rt;
         #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($cart_rt);
             $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($cart_rt)));
             $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', 'storefront');
             $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', 'storefront');
             $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', 'storefront');
             $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')));
         if ($this->session->data['error']) {
             $error_msg[] = $this->session->data['error'];
             unset($this->session->data['error']);
         }
         $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'] = $this->html->buildElement(array('name' => 'continue', 'type' => 'button', 'text' => $this->language->get('button_continue'), 'href' => $this->html->getURL($home_rt), 'style' => 'button'));
         if ($this->config->get('embed_mode') == true) {
             $this->data['back_url'] = $this->html->getURL('r/product/category');
         }
         $this->view->setTemplate('pages/error/not_found.tpl');
     }
     $this->view->batchAssign($this->data);
     $this->processTemplate();
     //init controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Ejemplo n.º 29
0
 public function main()
 {
     if ($this->html_cache()) {
         return;
     }
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->data['heading_title'] = $this->language->get('heading_title', 'blocks/featured');
     $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'));
     $product_ids = array();
     foreach ($results as $result) {
         $product_ids[] = (int) $result['product_id'];
     }
     $products_info = $this->model_catalog_product->getProductsAllInfo($product_ids);
     //get thumbnails by one pass
     $resource = new AResource('image');
     $thumbnails = $resource->getMainThumbList('products', $product_ids, $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));
     $stock_info = $this->model_catalog_product->getProductsStockInfo($product_ids);
     foreach ($results 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('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 ($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;
             }
         }
         $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, 'date_added' => $result['date_added']);
     }
     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__);
 }
Ejemplo n.º 30
0
 public function post()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $request = $this->rest->getRequestParams();
     if (!$this->customer->isLoggedWithToken($request['token'])) {
         $this->rest->sendResponse(401, array('error' => 'Not logged in or Login attempt failed!'));
         return null;
     }
     if (!$this->cart->hasProducts()) {
         //No products in the cart.
         $this->rest->sendResponse(200, array('status' => 2, 'error' => 'Nothing in the cart!'));
         return null;
     }
     if (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout')) {
         //No stock for products in the cart if tracked.
         $this->rest->sendResponse(200, array('status' => 3, 'error' => 'No stock for product!'));
         return null;
     }
     if ($this->cart->hasShipping()) {
         if (!isset($this->session->data['shipping_address_id']) || !$this->session->data['shipping_address_id']) {
             //Problem. Missing shipping address
             $this->rest->sendResponse(200, array('status' => 4, 'error' => 'Missing shipping address!'));
             return null;
         }
         if (!isset($this->session->data['shipping_method'])) {
             //Problem. Missing shipping address
             $this->rest->sendResponse(200, array('status' => 5, 'error' => 'Missing shipping method!'));
             return null;
         }
     } else {
         unset($this->session->data['shipping_address_id']);
         unset($this->session->data['shipping_method']);
         unset($this->session->data['shipping_methods']);
         $this->tax->setZone($this->session->data['country_id'], $this->session->data['zone_id']);
     }
     if (!isset($this->session->data['payment_address_id']) || !$this->session->data['payment_address_id']) {
         $this->rest->sendResponse(200, array('status' => 6, 'error' => 'Missing payment (billing) address!'));
         return null;
     }
     if (!isset($this->session->data['payment_method'])) {
         $this->rest->sendResponse(200, array('status' => 5, 'error' => 'Missing payment (billing) method!'));
         return null;
     }
     //build order and pre-save
     $order = new AOrder($this->registry);
     $this->data = $order->buildOrderData($this->session->data);
     $this->session->data['order_id'] = $order->saveOrder();
     //build confirmation data
     $this->loadModel('account/address');
     $shipping_address = $this->model_account_address->getAddress($this->session->data['shipping_address_id']);
     if ($this->cart->hasShipping()) {
         $this->data['shipping_address'] = $this->customer->getFormattedAddress($shipping_address, $shipping_address['address_format']);
     } else {
         $this->data['shipping_address'] = '';
     }
     $this->data['shipping_method'] = $this->session->data['shipping_method']['title'];
     $payment_address = $this->model_account_address->getAddress($this->session->data['payment_address_id']);
     if ($payment_address) {
         $this->data['payment_address'] = $this->customer->getFormattedAddress($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->loadModel('tool/seo_url');
     $this->loadModel('tool/image');
     $product_ids = array();
     foreach ($this->data['products'] as $result) {
         $product_ids[] = (int) $result['product_id'];
     }
     $resource = new AResource('image');
     $thumbnails = $resource->getMainThumbList('products', $product_ids, $this->config->get('config_image_cart_width'), $this->config->get('config_image_cart_height'));
     //Format product data specific for confirmation response
     for ($i = 0; $i < sizeof($this->data['products']); $i++) {
         $product_id = $this->data['products'][$i]['product_id'];
         $thumbnail = $thumbnails[$product_id];
         $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['thumb_url'], 'tax' => $this->currency->format($tax), 'price' => $this->currency->format($this->data['products'][$i]['price']), 'total' => $this->currency->format($this->data['products'][$i]['total'])));
     }
     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'] = sprintf($this->language->get('text_accept_agree'), '', $content_info['title']);
         } else {
             $this->data['text_accept_agree'] = '';
         }
     } else {
         $this->data['text_accept_agree'] = '';
     }
     // Load selected paymnet required data from payment extension
     if ($this->session->data['payment_method']['id'] != 'no_payment_required') {
         $payment_controller = $this->dispatch('responses/extension/' . $this->session->data['payment_method']['id'] . '/api');
     } else {
         $payment_controller = $this->dispatch('responses/checkout/no_payment/api');
     }
     $this->load->library('json');
     $this->data['payment'] = AJson::decode($payment_controller->dispatchGetOutput(), TRUE);
     //set process_rt for process step to run the payment
     $this->session->data['process_rt'] = $this->data['payment']['process_rt'];
     //mark confirmation viewed
     $this->session->data['confirmed'] = TRUE;
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->rest->setResponseData($this->data);
     $this->rest->sendResponse(200);
 }