shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

product.php (25176B)


      1 <?php
      2 class ControllerProductProduct extends Controller {
      3 	private $error = array();
      4 
      5 	public function index() {
      6 		$this->load->language('product/product');
      7 
      8 		$data['breadcrumbs'] = array();
      9 
     10 		$data['breadcrumbs'][] = array(
     11 			'text' => $this->language->get('text_home'),
     12 			'href' => $this->url->link('common/home')
     13 		);
     14 
     15 		$this->load->model('catalog/category');
     16 
     17 		if (isset($this->request->get['path'])) {
     18 			$path = '';
     19 
     20 			$parts = explode('_', (string)$this->request->get['path']);
     21 
     22 			$category_id = (int)array_pop($parts);
     23 
     24 			foreach ($parts as $path_id) {
     25 				if (!$path) {
     26 					$path = $path_id;
     27 				} else {
     28 					$path .= '_' . $path_id;
     29 				}
     30 
     31 				$category_info = $this->model_catalog_category->getCategory($path_id);
     32 
     33 				if ($category_info) {
     34 					$data['breadcrumbs'][] = array(
     35 						'text' => $category_info['name'],
     36 						'href' => $this->url->link('product/category', 'path=' . $path)
     37 					);
     38 				}
     39 			}
     40 
     41 			// Set the last category breadcrumb
     42 			$category_info = $this->model_catalog_category->getCategory($category_id);
     43 
     44 			if ($category_info) {
     45 				$url = '';
     46 
     47 				if (isset($this->request->get['sort'])) {
     48 					$url .= '&sort=' . $this->request->get['sort'];
     49 				}
     50 
     51 				if (isset($this->request->get['order'])) {
     52 					$url .= '&order=' . $this->request->get['order'];
     53 				}
     54 
     55 				if (isset($this->request->get['page'])) {
     56 					$url .= '&page=' . $this->request->get['page'];
     57 				}
     58 
     59 				if (isset($this->request->get['limit'])) {
     60 					$url .= '&limit=' . $this->request->get['limit'];
     61 				}
     62 
     63 				$data['breadcrumbs'][] = array(
     64 					'text' => $category_info['name'],
     65 					'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url)
     66 				);
     67 			}
     68 		}
     69 
     70 		$this->load->model('catalog/manufacturer');
     71 
     72 		if (isset($this->request->get['manufacturer_id'])) {
     73 			$data['breadcrumbs'][] = array(
     74 				'text' => $this->language->get('text_brand'),
     75 				'href' => $this->url->link('product/manufacturer')
     76 			);
     77 
     78 			$url = '';
     79 
     80 			if (isset($this->request->get['sort'])) {
     81 				$url .= '&sort=' . $this->request->get['sort'];
     82 			}
     83 
     84 			if (isset($this->request->get['order'])) {
     85 				$url .= '&order=' . $this->request->get['order'];
     86 			}
     87 
     88 			if (isset($this->request->get['page'])) {
     89 				$url .= '&page=' . $this->request->get['page'];
     90 			}
     91 
     92 			if (isset($this->request->get['limit'])) {
     93 				$url .= '&limit=' . $this->request->get['limit'];
     94 			}
     95 
     96 			$manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($this->request->get['manufacturer_id']);
     97 
     98 			if ($manufacturer_info) {
     99 				$data['breadcrumbs'][] = array(
    100 					'text' => $manufacturer_info['name'],
    101 					'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url)
    102 				);
    103 			}
    104 		}
    105 
    106 		if (isset($this->request->get['search']) || isset($this->request->get['tag'])) {
    107 			$url = '';
    108 
    109 			if (isset($this->request->get['search'])) {
    110 				$url .= '&search=' . $this->request->get['search'];
    111 			}
    112 
    113 			if (isset($this->request->get['tag'])) {
    114 				$url .= '&tag=' . $this->request->get['tag'];
    115 			}
    116 
    117 			if (isset($this->request->get['description'])) {
    118 				$url .= '&description=' . $this->request->get['description'];
    119 			}
    120 
    121 			if (isset($this->request->get['category_id'])) {
    122 				$url .= '&category_id=' . $this->request->get['category_id'];
    123 			}
    124 
    125 			if (isset($this->request->get['sub_category'])) {
    126 				$url .= '&sub_category=' . $this->request->get['sub_category'];
    127 			}
    128 
    129 			if (isset($this->request->get['sort'])) {
    130 				$url .= '&sort=' . $this->request->get['sort'];
    131 			}
    132 
    133 			if (isset($this->request->get['order'])) {
    134 				$url .= '&order=' . $this->request->get['order'];
    135 			}
    136 
    137 			if (isset($this->request->get['page'])) {
    138 				$url .= '&page=' . $this->request->get['page'];
    139 			}
    140 
    141 			if (isset($this->request->get['limit'])) {
    142 				$url .= '&limit=' . $this->request->get['limit'];
    143 			}
    144 
    145 			$data['breadcrumbs'][] = array(
    146 				'text' => $this->language->get('text_search'),
    147 				'href' => $this->url->link('product/search', $url)
    148 			);
    149 		}
    150 
    151 		if (isset($this->request->get['product_id'])) {
    152 			$product_id = (int)$this->request->get['product_id'];
    153 		} else {
    154 			$product_id = 0;
    155 		}
    156 
    157 		$this->load->model('catalog/product');
    158 
    159 		$product_info = $this->model_catalog_product->getProduct($product_id);
    160 
    161 		if ($product_info) {
    162 			$url = '';
    163 
    164 			if (isset($this->request->get['path'])) {
    165 				$url .= '&path=' . $this->request->get['path'];
    166 			}
    167 
    168 			if (isset($this->request->get['filter'])) {
    169 				$url .= '&filter=' . $this->request->get['filter'];
    170 			}
    171 
    172 			if (isset($this->request->get['manufacturer_id'])) {
    173 				$url .= '&manufacturer_id=' . $this->request->get['manufacturer_id'];
    174 			}
    175 
    176 			if (isset($this->request->get['search'])) {
    177 				$url .= '&search=' . $this->request->get['search'];
    178 			}
    179 
    180 			if (isset($this->request->get['tag'])) {
    181 				$url .= '&tag=' . $this->request->get['tag'];
    182 			}
    183 
    184 			if (isset($this->request->get['description'])) {
    185 				$url .= '&description=' . $this->request->get['description'];
    186 			}
    187 
    188 			if (isset($this->request->get['category_id'])) {
    189 				$url .= '&category_id=' . $this->request->get['category_id'];
    190 			}
    191 
    192 			if (isset($this->request->get['sub_category'])) {
    193 				$url .= '&sub_category=' . $this->request->get['sub_category'];
    194 			}
    195 
    196 			if (isset($this->request->get['sort'])) {
    197 				$url .= '&sort=' . $this->request->get['sort'];
    198 			}
    199 
    200 			if (isset($this->request->get['order'])) {
    201 				$url .= '&order=' . $this->request->get['order'];
    202 			}
    203 
    204 			if (isset($this->request->get['page'])) {
    205 				$url .= '&page=' . $this->request->get['page'];
    206 			}
    207 
    208 			if (isset($this->request->get['limit'])) {
    209 				$url .= '&limit=' . $this->request->get['limit'];
    210 			}
    211 
    212 			$data['breadcrumbs'][] = array(
    213 				'text' => $product_info['name'],
    214 				'href' => $this->url->link('product/product', $url . '&product_id=' . $this->request->get['product_id'])
    215 			);
    216 
    217 			$this->document->setTitle($product_info['meta_title']);
    218 			$this->document->setDescription($product_info['meta_description']);
    219 			$this->document->setKeywords($product_info['meta_keyword']);
    220 			$this->document->addLink($this->url->link('product/product', 'product_id=' . $this->request->get['product_id']), 'canonical');
    221 			$this->document->addScript('catalog/view/javascript/jquery/magnific/jquery.magnific-popup.min.js');
    222 			$this->document->addStyle('catalog/view/javascript/jquery/magnific/magnific-popup.css');
    223 			$this->document->addScript('catalog/view/javascript/jquery/datetimepicker/moment/moment.min.js');
    224 			$this->document->addScript('catalog/view/javascript/jquery/datetimepicker/moment/moment-with-locales.min.js');
    225 			$this->document->addScript('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js');
    226 			$this->document->addStyle('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css');
    227 
    228 			$data['heading_title'] = $product_info['name'];
    229 
    230 			$data['text_minimum'] = sprintf($this->language->get('text_minimum'), $product_info['minimum']);
    231 			$data['text_login'] = sprintf($this->language->get('text_login'), $this->url->link('account/login', '', true), $this->url->link('account/register', '', true));
    232 
    233 			$this->load->model('catalog/review');
    234 
    235 			$data['tab_review'] = sprintf($this->language->get('tab_review'), $product_info['reviews']);
    236 
    237 			$data['product_id'] = (int)$this->request->get['product_id'];
    238 			$data['manufacturer'] = $product_info['manufacturer'];
    239 			$data['manufacturers'] = $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $product_info['manufacturer_id']);
    240 			$data['model'] = $product_info['model'];
    241 			$data['reward'] = $product_info['reward'];
    242 			$data['points'] = $product_info['points'];
    243 			$data['description'] = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8');
    244 
    245 			if ($product_info['quantity'] <= 0) {
    246 				$data['stock'] = $product_info['stock_status'];
    247 			} elseif ($this->config->get('config_stock_display')) {
    248 				$data['stock'] = $product_info['quantity'];
    249 			} else {
    250 				$data['stock'] = $this->language->get('text_instock');
    251 			}
    252 
    253 			$this->load->model('tool/image');
    254 
    255 			if ($product_info['image']) {
    256 				$data['popup'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_height'));
    257 			} else {
    258 				$data['popup'] = '';
    259 			}
    260 
    261 			if ($product_info['image']) {
    262 				$data['thumb'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_thumb_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_thumb_height'));
    263 			} else {
    264 				$data['thumb'] = '';
    265 			}
    266 
    267 			$data['images'] = array();
    268 
    269 			$results = $this->model_catalog_product->getProductImages($this->request->get['product_id']);
    270 
    271 			foreach ($results as $result) {
    272 				$data['images'][] = array(
    273 					'popup' => $this->model_tool_image->resize($result['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_height')),
    274 					'thumb' => $this->model_tool_image->resize($result['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_additional_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_additional_height'))
    275 				);
    276 			}
    277 
    278 			if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
    279 				$data['price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
    280 			} else {
    281 				$data['price'] = false;
    282 			}
    283 
    284 			if ((float)$product_info['special']) {
    285 				$data['special'] = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
    286 			} else {
    287 				$data['special'] = false;
    288 			}
    289 
    290 			if ($this->config->get('config_tax')) {
    291 				$data['tax'] = $this->currency->format((float)$product_info['special'] ? $product_info['special'] : $product_info['price'], $this->session->data['currency']);
    292 			} else {
    293 				$data['tax'] = false;
    294 			}
    295 
    296 			$discounts = $this->model_catalog_product->getProductDiscounts($this->request->get['product_id']);
    297 
    298 			$data['discounts'] = array();
    299 
    300 			foreach ($discounts as $discount) {
    301 				$data['discounts'][] = array(
    302 					'quantity' => $discount['quantity'],
    303 					'price'    => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency'])
    304 				);
    305 			}
    306 
    307 			$data['options'] = array();
    308 
    309 			foreach ($this->model_catalog_product->getProductOptions($this->request->get['product_id']) as $option) {
    310 				$product_option_value_data = array();
    311 
    312 				foreach ($option['product_option_value'] as $option_value) {
    313 					if (!$option_value['subtract'] || ($option_value['quantity'] > 0)) {
    314 						if ((($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) && (float)$option_value['price']) {
    315 							$price = $this->currency->format($this->tax->calculate($option_value['price'], $product_info['tax_class_id'], $this->config->get('config_tax') ? 'P' : false), $this->session->data['currency']);
    316 						} else {
    317 							$price = false;
    318 						}
    319 
    320 						$product_option_value_data[] = array(
    321 							'product_option_value_id' => $option_value['product_option_value_id'],
    322 							'option_value_id'         => $option_value['option_value_id'],
    323 							'name'                    => $option_value['name'],
    324 							'image'                   => $this->model_tool_image->resize($option_value['image'], 50, 50),
    325 							'price'                   => $price,
    326 							'price_prefix'            => $option_value['price_prefix']
    327 						);
    328 					}
    329 				}
    330 
    331 				$data['options'][] = array(
    332 					'product_option_id'    => $option['product_option_id'],
    333 					'product_option_value' => $product_option_value_data,
    334 					'option_id'            => $option['option_id'],
    335 					'name'                 => $option['name'],
    336 					'type'                 => $option['type'],
    337 					'value'                => $option['value'],
    338 					'required'             => $option['required']
    339 				);
    340 			}
    341 
    342 			if ($product_info['minimum']) {
    343 				$data['minimum'] = $product_info['minimum'];
    344 			} else {
    345 				$data['minimum'] = 1;
    346 			}
    347 
    348 			$data['review_status'] = $this->config->get('config_review_status');
    349 
    350 			if ($this->config->get('config_review_guest') || $this->customer->isLogged()) {
    351 				$data['review_guest'] = true;
    352 			} else {
    353 				$data['review_guest'] = false;
    354 			}
    355 
    356 			if ($this->customer->isLogged()) {
    357 				$data['customer_name'] = $this->customer->getFirstName() . '&nbsp;' . $this->customer->getLastName();
    358 			} else {
    359 				$data['customer_name'] = '';
    360 			}
    361 
    362 			$data['reviews'] = sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']);
    363 			$data['rating'] = (int)$product_info['rating'];
    364 
    365 			// Captcha
    366 			if ($this->config->get('captcha_' . $this->config->get('config_captcha') . '_status') && in_array('review', (array)$this->config->get('config_captcha_page'))) {
    367 				$data['captcha'] = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha'));
    368 			} else {
    369 				$data['captcha'] = '';
    370 			}
    371 
    372 			$data['share'] = $this->url->link('product/product', 'product_id=' . (int)$this->request->get['product_id']);
    373 
    374 			$data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($this->request->get['product_id']);
    375 
    376 			$data['products'] = array();
    377 
    378 			$results = $this->model_catalog_product->getProductRelated($this->request->get['product_id']);
    379 
    380 			foreach ($results as $result) {
    381 				if ($result['image']) {
    382 					$image = $this->model_tool_image->resize($result['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_related_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_related_height'));
    383 				} else {
    384 					$image = $this->model_tool_image->resize('placeholder.png', $this->config->get('theme_' . $this->config->get('config_theme') . '_image_related_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_related_height'));
    385 				}
    386 
    387 				if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
    388 					$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
    389 				} else {
    390 					$price = false;
    391 				}
    392 
    393 				if ((float)$result['special']) {
    394 					$special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
    395 				} else {
    396 					$special = false;
    397 				}
    398 
    399 				if ($this->config->get('config_tax')) {
    400 					$tax = $this->currency->format((float)$result['special'] ? $result['special'] : $result['price'], $this->session->data['currency']);
    401 				} else {
    402 					$tax = false;
    403 				}
    404 
    405 				if ($this->config->get('config_review_status')) {
    406 					$rating = (int)$result['rating'];
    407 				} else {
    408 					$rating = false;
    409 				}
    410 
    411 				$data['products'][] = array(
    412 					'product_id'  => $result['product_id'],
    413 					'thumb'       => $image,
    414 					'name'        => $result['name'],
    415 					'description' => utf8_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
    416 					'price'       => $price,
    417 					'special'     => $special,
    418 					'tax'         => $tax,
    419 					'minimum'     => $result['minimum'] > 0 ? $result['minimum'] : 1,
    420 					'rating'      => $rating,
    421 					'href'        => $this->url->link('product/product', 'product_id=' . $result['product_id'])
    422 				);
    423 			}
    424 
    425 			$data['tags'] = array();
    426 
    427 			if ($product_info['tag']) {
    428 				$tags = explode(',', $product_info['tag']);
    429 
    430 				foreach ($tags as $tag) {
    431 					$data['tags'][] = array(
    432 						'tag'  => trim($tag),
    433 						'href' => $this->url->link('product/search', 'tag=' . trim($tag))
    434 					);
    435 				}
    436 			}
    437 
    438 			$data['recurrings'] = $this->model_catalog_product->getProfiles($this->request->get['product_id']);
    439 
    440 			$this->model_catalog_product->updateViewed($this->request->get['product_id']);
    441 			
    442 			$data['column_left'] = $this->load->controller('common/column_left');
    443 			$data['column_right'] = $this->load->controller('common/column_right');
    444 			$data['content_top'] = $this->load->controller('common/content_top');
    445 			$data['content_bottom'] = $this->load->controller('common/content_bottom');
    446 			$data['footer'] = $this->load->controller('common/footer');
    447 			$data['header'] = $this->load->controller('common/header');
    448 
    449 			$this->response->setOutput($this->load->view('product/product', $data));
    450 		} else {
    451 			$url = '';
    452 
    453 			if (isset($this->request->get['path'])) {
    454 				$url .= '&path=' . $this->request->get['path'];
    455 			}
    456 
    457 			if (isset($this->request->get['filter'])) {
    458 				$url .= '&filter=' . $this->request->get['filter'];
    459 			}
    460 
    461 			if (isset($this->request->get['manufacturer_id'])) {
    462 				$url .= '&manufacturer_id=' . $this->request->get['manufacturer_id'];
    463 			}
    464 
    465 			if (isset($this->request->get['search'])) {
    466 				$url .= '&search=' . $this->request->get['search'];
    467 			}
    468 
    469 			if (isset($this->request->get['tag'])) {
    470 				$url .= '&tag=' . $this->request->get['tag'];
    471 			}
    472 
    473 			if (isset($this->request->get['description'])) {
    474 				$url .= '&description=' . $this->request->get['description'];
    475 			}
    476 
    477 			if (isset($this->request->get['category_id'])) {
    478 				$url .= '&category_id=' . $this->request->get['category_id'];
    479 			}
    480 
    481 			if (isset($this->request->get['sub_category'])) {
    482 				$url .= '&sub_category=' . $this->request->get['sub_category'];
    483 			}
    484 
    485 			if (isset($this->request->get['sort'])) {
    486 				$url .= '&sort=' . $this->request->get['sort'];
    487 			}
    488 
    489 			if (isset($this->request->get['order'])) {
    490 				$url .= '&order=' . $this->request->get['order'];
    491 			}
    492 
    493 			if (isset($this->request->get['page'])) {
    494 				$url .= '&page=' . $this->request->get['page'];
    495 			}
    496 
    497 			if (isset($this->request->get['limit'])) {
    498 				$url .= '&limit=' . $this->request->get['limit'];
    499 			}
    500 
    501 			$data['breadcrumbs'][] = array(
    502 				'text' => $this->language->get('text_error'),
    503 				'href' => $this->url->link('product/product', $url . '&product_id=' . $product_id)
    504 			);
    505 
    506 			$this->document->setTitle($this->language->get('text_error'));
    507 
    508 			$data['continue'] = $this->url->link('common/home');
    509 
    510 			$this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found');
    511 
    512 			$data['column_left'] = $this->load->controller('common/column_left');
    513 			$data['column_right'] = $this->load->controller('common/column_right');
    514 			$data['content_top'] = $this->load->controller('common/content_top');
    515 			$data['content_bottom'] = $this->load->controller('common/content_bottom');
    516 			$data['footer'] = $this->load->controller('common/footer');
    517 			$data['header'] = $this->load->controller('common/header');
    518 
    519 			$this->response->setOutput($this->load->view('error/not_found', $data));
    520 		}
    521 	}
    522 
    523 	public function review() {
    524 		$this->load->language('product/product');
    525 
    526 		$this->load->model('catalog/review');
    527 
    528 		if (isset($this->request->get['page'])) {
    529 			$page = $this->request->get['page'];
    530 		} else {
    531 			$page = 1;
    532 		}
    533 
    534 		$data['reviews'] = array();
    535 
    536 		$review_total = $this->model_catalog_review->getTotalReviewsByProductId($this->request->get['product_id']);
    537 
    538 		$results = $this->model_catalog_review->getReviewsByProductId($this->request->get['product_id'], ($page - 1) * 5, 5);
    539 
    540 		foreach ($results as $result) {
    541 			$data['reviews'][] = array(
    542 				'author'     => $result['author'],
    543 				'text'       => nl2br($result['text']),
    544 				'rating'     => (int)$result['rating'],
    545 				'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added']))
    546 			);
    547 		}
    548 
    549 		$pagination = new Pagination();
    550 		$pagination->total = $review_total;
    551 		$pagination->page = $page;
    552 		$pagination->limit = 5;
    553 		$pagination->url = $this->url->link('product/product/review', 'product_id=' . $this->request->get['product_id'] . '&page={page}');
    554 
    555 		$data['pagination'] = $pagination->render();
    556 
    557 		$data['results'] = sprintf($this->language->get('text_pagination'), ($review_total) ? (($page - 1) * 5) + 1 : 0, ((($page - 1) * 5) > ($review_total - 5)) ? $review_total : ((($page - 1) * 5) + 5), $review_total, ceil($review_total / 5));
    558 
    559 		$this->response->setOutput($this->load->view('product/review', $data));
    560 	}
    561 
    562 	public function write() {
    563 		$this->load->language('product/product');
    564 
    565 		$json = array();
    566 
    567 		if ($this->request->server['REQUEST_METHOD'] == 'POST') {
    568 			if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 25)) {
    569 				$json['error'] = $this->language->get('error_name');
    570 			}
    571 
    572 			if ((utf8_strlen($this->request->post['text']) < 25) || (utf8_strlen($this->request->post['text']) > 1000)) {
    573 				$json['error'] = $this->language->get('error_text');
    574 			}
    575 
    576 			if (empty($this->request->post['rating']) || $this->request->post['rating'] < 0 || $this->request->post['rating'] > 5) {
    577 				$json['error'] = $this->language->get('error_rating');
    578 			}
    579 
    580 			// Captcha
    581 			if ($this->config->get('captcha_' . $this->config->get('config_captcha') . '_status') && in_array('review', (array)$this->config->get('config_captcha_page'))) {
    582 				$captcha = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha') . '/validate');
    583 
    584 				if ($captcha) {
    585 					$json['error'] = $captcha;
    586 				}
    587 			}
    588 
    589 			if (!isset($json['error'])) {
    590 				$this->load->model('catalog/review');
    591 
    592 				$this->model_catalog_review->addReview($this->request->get['product_id'], $this->request->post);
    593 
    594 				$json['success'] = $this->language->get('text_success');
    595 			}
    596 		}
    597 
    598 		$this->response->addHeader('Content-Type: application/json');
    599 		$this->response->setOutput(json_encode($json));
    600 	}
    601 
    602 	public function getRecurringDescription() {
    603 		$this->load->language('product/product');
    604 		$this->load->model('catalog/product');
    605 
    606 		if (isset($this->request->post['product_id'])) {
    607 			$product_id = $this->request->post['product_id'];
    608 		} else {
    609 			$product_id = 0;
    610 		}
    611 
    612 		if (isset($this->request->post['recurring_id'])) {
    613 			$recurring_id = $this->request->post['recurring_id'];
    614 		} else {
    615 			$recurring_id = 0;
    616 		}
    617 
    618 		if (isset($this->request->post['quantity'])) {
    619 			$quantity = $this->request->post['quantity'];
    620 		} else {
    621 			$quantity = 1;
    622 		}
    623 
    624 		$product_info = $this->model_catalog_product->getProduct($product_id);
    625 		
    626 		$recurring_info = $this->model_catalog_product->getProfile($product_id, $recurring_id);
    627 
    628 		$json = array();
    629 
    630 		if ($product_info && $recurring_info) {
    631 			if (!$json) {
    632 				$frequencies = array(
    633 					'day'        => $this->language->get('text_day'),
    634 					'week'       => $this->language->get('text_week'),
    635 					'semi_month' => $this->language->get('text_semi_month'),
    636 					'month'      => $this->language->get('text_month'),
    637 					'year'       => $this->language->get('text_year'),
    638 				);
    639 
    640 				if ($recurring_info['trial_status'] == 1) {
    641 					$price = $this->currency->format($this->tax->calculate($recurring_info['trial_price'] * $quantity, $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
    642 					$trial_text = sprintf($this->language->get('text_trial_description'), $price, $recurring_info['trial_cycle'], $frequencies[$recurring_info['trial_frequency']], $recurring_info['trial_duration']) . ' ';
    643 				} else {
    644 					$trial_text = '';
    645 				}
    646 
    647 				$price = $this->currency->format($this->tax->calculate($recurring_info['price'] * $quantity, $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
    648 
    649 				if ($recurring_info['duration']) {
    650 					$text = $trial_text . sprintf($this->language->get('text_payment_description'), $price, $recurring_info['cycle'], $frequencies[$recurring_info['frequency']], $recurring_info['duration']);
    651 				} else {
    652 					$text = $trial_text . sprintf($this->language->get('text_payment_cancel'), $price, $recurring_info['cycle'], $frequencies[$recurring_info['frequency']], $recurring_info['duration']);
    653 				}
    654 
    655 				$json['success'] = $text;
    656 			}
    657 		}
    658 
    659 		$this->response->addHeader('Content-Type: application/json');
    660 		$this->response->setOutput(json_encode($json));
    661 	}
    662 }