<?xml version="1.0" encoding="UTF-8"?>
<modification>
	<name>Advanced Product Options</name>
	<version>1.0</version>
	<code>advanced-product-options</code>
	<author>Coding Inspect - codinginspect@gmail.com</author>
	<file path="admin/controller/common/column_left.php">
		<operation error="skip">
			<search><![CDATA[if ($marketplace) {]]></search>
			<add position="before"><![CDATA[
				if ($this->user->hasPermission('access', 'extension/ciadvancedoptions')) {
					$this->load->language('extension/ciadvancedoptions_menu');
					$marketplace[] = array(
						'name'	   => $this->language->get('text_ciadvancedoptions'),
						'href'     => $this->url->link('extension/ciadvancedoptions', 'user_token=' . $this->session->data['user_token'], true),
						'children' => array()
					);
				}
			]]></add>
		</operation>
	</file>
	<file path="admin/controller/catalog/option.php">
		<operation error="skip">
			<search><![CDATA[protected function getForm() {]]></search>
			<add position="after"><![CDATA[
				$this->load->language('extension/ciadvancedoptions_menu');
				$data['entry_option_description'] = $this->language->get('entry_option_description');

				$data['ciadvancedoptions_status'] = $this->config->get('ciadvancedoptions_status');
				$data['ciadvancedoptions_option_description_status'] = $this->config->get('ciadvancedoptions_option_description_status');
			]]></add>
		</operation>
	</file>
	<file path="admin/model/catalog/option.php">
		<operation error="skip">
			<search><![CDATA[name = '" . $this->db->escape($value['name']) . "']]></search>
			<add position="replace"><![CDATA[name = '" . $this->db->escape($value['name']) . "', description = '" . (isset($value['description']) ? $this->db->escape($value['description']) : '') . "']]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[$option_data[$result['language_id']] = array('name' => $result['name']);]]></search>
			<add position="replace"><![CDATA[$option_data[$result['language_id']] = array('name' => $result['name'], 'description' => $result['description']);]]></add>
		</operation>
	</file>
	<file path="admin/controller/catalog/product.php">
		<operation error="skip">
			<search><![CDATA[protected function getForm() {]]></search>
			<add position="after"><![CDATA[
				$this->load->model('tool/image');

				$data['ciadvancedoptions_status'] = $this->config->get('ciadvancedoptions_status');
				$data['ciadvancedoptions_option_model_status'] = $this->config->get('ciadvancedoptions_option_model_status');
				$data['ciadvancedoptions_option_sku_status'] = $this->config->get('ciadvancedoptions_option_sku_status');
				$data['ciadvancedoptions_option_image_status'] = $this->config->get('ciadvancedoptions_option_image_status');
				$data['ciadvancedoptions_customer_group_status'] = $this->config->get('ciadvancedoptions_customer_group_status');
			]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[$product_option_value['weight'],]]></search>
			<add position="before"><![CDATA[
				'ciopmodel'           => (isset($product_option_value['ciopmodel']) ? $product_option_value['ciopmodel'] : ''),
				'ciopsku'             => (isset($product_option_value['ciopsku']) ? $product_option_value['ciopsku'] : ''),
				'ciopimage'           => (isset($product_option_value['ciopimage']) ? $product_option_value['ciopimage'] : ''),
				'ciopimage_thumb'     => (!empty($product_option_value['ciopimage']) && is_file(DIR_IMAGE . $product_option_value['ciopimage']) ?  $this->model_tool_image->resize($product_option_value['ciopimage'], 100, 100) : $this->model_tool_image->resize('no_image.png', 100, 100)),
				'customer_groups'     => (isset($product_option_value['customer_group']) ? $product_option_value['customer_group'] : ''),
			]]></add>
		</operation>
	</file>
	<file path="admin/model/catalog/product.php">
		<operation error="skip">
			<search><![CDATA[weight = '" . (float)$product_option_value['weight'] . "']]></search>
			<add position="replace"><![CDATA[ciopmodel = '" . (isset($product_option_value['ciopmodel']) ? $this->db->escape($product_option_value['ciopmodel']) : '') . "', ciopsku = '" . (isset($product_option_value['ciopsku']) ? $this->db->escape($product_option_value['ciopsku']) : '') . "', ciopimage = '" . (isset($product_option_value['ciopimage']) ? $this->db->escape($product_option_value['ciopimage']) : '') . "', weight = '" . (float)$product_option_value['weight'] . "']]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[$product_option_value['weight'],]]></search>
			<add position="after"><![CDATA[
				'ciopmodel'                  => (isset($product_option_value['ciopmodel']) ? $product_option_value['ciopmodel'] : ''),
				'ciopsku'                    => (isset($product_option_value['ciopsku']) ? $product_option_value['ciopsku'] : ''),
				'ciopimage'                  => (isset($product_option_value['ciopimage']) ? $product_option_value['ciopimage'] : ''),
				'customer_group'             => $this->getProductOptionCustomerGroups($product_option_value['product_option_value_id']),
			]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[public function addProduct($data) {]]></search>
			<add position="before"><![CDATA[
				public function getProductOptionCustomerGroups($product_option_value_id) {
					$customer_group_data = array();

					$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option_value_group WHERE product_option_value_id = '" . (int)$product_option_value_id . "'");

					foreach ($query->rows as $result) {
						$customer_group_data[] = $result['customer_group_id'];
					}

					return $customer_group_data;
				}
			]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[$this->db->query("DELETE FROM " . DB_PREFIX . "product_option_value WHERE product_id = '" . (int)$product_id . "'");]]></search>
			<add position="after"><![CDATA[
				/* Customer group starts */
				$this->db->query("DELETE FROM " . DB_PREFIX . "product_option_value_group WHERE product_id = '" . (int)$product_id . "'");
				/* Customer group ends */
			]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[weight_prefix = '" . $this->db->escape($product_option_value['weight_prefix']) . "'");]]></search>
			<add position="after"><![CDATA[
				/* Customer group starts */
				$product_option_value_id = $this->db->getLastId();

				if (isset($product_option_value['customer_group'])) {
					foreach ($product_option_value['customer_group'] as $ci_customer_group_id) {
						$this->db->query("INSERT INTO " . DB_PREFIX . "product_option_value_group SET product_id = '" . (int)$product_id . "', customer_group_id = '" . (int)$ci_customer_group_id . "', product_option_value_id = '" . (int)$product_option_value_id . "'");
					}
				}
				/* Customer group ends */
			]]></add>
		</operation>
	</file>
	<file path="admin/view/template/catalog/product_form.twig">
		<operation error="skip">
			<search><![CDATA[<td class="text-left">{{ entry_option_value }}</td>]]></search>
			<add position="replace"><![CDATA[<td class="text-left {{ ciadvancedoptions_status and ciadvancedoptions_option_sku_status ? '' : 'hide' }}">{{ entry_sku }}</td><td class="text-left {{ ciadvancedoptions_status and ciadvancedoptions_option_model_status ? '' : 'hide' }}">{{ entry_model }}</td><td class="text-left {{ ciadvancedoptions_status and ciadvancedoptions_option_image_status ? '' : 'hide' }}">{{ entry_image }}</td><td class="text-left {{ ciadvancedoptions_status and ciadvancedoptions_customer_group_status ? '' : 'hide' }}">{{ entry_customer_group }}</td><td class="text-left">{{ entry_option_value }}</td>]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[<td class="text-left"><select name="product_option[{{ option_row }}][product_option_value][{{ option_value_row }}][option_value_id]" class="form-control">]]></search>
			<add position="before"><![CDATA[
				<td class="{{ ciadvancedoptions_status and ciadvancedoptions_option_sku_status ? '' : 'hide' }}"><input type="text" name="product_option[{{ option_row }}][product_option_value][{{ option_value_row }}][ciopsku]" class="form-control" value="{{ product_option_value.ciopsku }}" id="input-ciopsku-{{ option_row }}-{{ option_value_row }}" /></td>
				<td class="{{ ciadvancedoptions_status and ciadvancedoptions_option_model_status ? '' : 'hide' }}"><input type="text" name="product_option[{{ option_row }}][product_option_value][{{ option_value_row }}][ciopmodel]" class="form-control" value="{{ product_option_value.ciopmodel }}" id="input-ciopmodel-{{ option_row }}-{{ option_value_row }}" /></td>
				<td class="{{ ciadvancedoptions_status and ciadvancedoptions_option_image_status ? '' : 'hide' }}"><a href="" id="thumb-ciopimage-{{ option_row }}-{{ option_value_row }}" data-toggle="image" data-placement="bottom" class="img-thumbnail"><img src="{{ product_option_value.ciopimage_thumb }}"  alt="" title="" data-placeholder="{{ placeholder }}" /></a><input type="hidden" name="product_option[{{ option_row }}][product_option_value][{{ option_value_row }}][ciopimage]" value="{{ product_option_value.ciopimage }}" id="input-ciopimage-{{ option_row }}-{{ option_value_row }}" /></td>

				<td class="{{ ciadvancedoptions_status and ciadvancedoptions_customer_group_status ? '' : 'hide' }}">
					{% for customer_group in customer_groups %}
	              	<div class="checkbox">
	                {% if customer_group.customer_group_id in product_option_value.customer_groups %}
	                  {% set ci_check = 'checked="checked"' %}
	                {% else %}
	                  {% set ci_check = '' %}
	                {% endif %}
	                <label><input name="product_option[{{ option_row }}][product_option_value][{{ option_value_row }}][customer_group][]" value="{{ customer_group.customer_group_id }}" type="checkbox" {{ ci_check }}> {{ customer_group.name }}</label>
	              	</div>
	          		{% endfor %}
	          	</td>
			]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[html += '  <td class="text-left"><select name="product_option[' + option_row + '][product_option_value][' + option_value_row + '][option_value_id]" class="form-control">';]]></search>
			<add position="before"><![CDATA[
				html += '<td class="{{ ciadvancedoptions_status and ciadvancedoptions_option_sku_status ? '' : 'hide' }}"><input type="text" name="product_option[' + option_row + '][product_option_value][' + option_value_row + '][ciopsku]" value="" id="input-ciopsku-' + option_row + '-' + option_value_row + '" class="form-control" /></td>';

				html += '<td class="{{ ciadvancedoptions_status and ciadvancedoptions_option_model_status ? '' : 'hide' }}"><input type="text" name="product_option[' + option_row + '][product_option_value][' + option_value_row + '][ciopmodel]" value="" id="input-ciopmodel-' + option_row + '-' + option_value_row + '" class="form-control" /></td>';

				html += '<td class="{{ ciadvancedoptions_status and ciadvancedoptions_option_image_status ? '' : 'hide' }}"><a data-placement="bottom" href="" id="thumb-ciopimage-' + option_row + '-' + option_value_row + '" data-toggle="image" class="img-thumbnail"><img src="{{ placeholder }}" alt="" title="" data-placeholder="{{ placeholder }}" /></a><input type="hidden" name="product_option[' + option_row + '][product_option_value][' + option_value_row + '][ciopimage]" value="" id="input-ciopimage-' + option_row + '-' + option_value_row + '" /></td>';

			 	html += '  <td class="{{ ciadvancedoptions_status and ciadvancedoptions_customer_group_status ? '' : 'hide' }}">';
				{% for customer_group in customer_groups %}
				html += '  <div class="checkbox">';
				html += '  <label><input name="product_option[' + option_row + '][product_option_value][' + option_value_row + '][customer_group][]" value="{{ customer_group.customer_group_id }}" type="checkbox"> {{ customer_group.name }}</label>';
				html += '  </div>';
				{% endfor %}
				html += '  </td>';
			]]></add>
		</operation>
	</file>
	<file path="admin/view/template/catalog/option_form.twig">
		<operation error="skip">
			<!-- for oc3x update search part -->
			<search><![CDATA[id="input-sort-order" class="form-control" />]]></search>
			<add position="after" offset="2"><![CDATA[
			<div class="{{ ciadvancedoptions_status and ciadvancedoptions_option_description_status ? '' : 'hide' }}">
				<ul class="nav nav-tabs" id="cioption-language">
					{% for language in languages %}
					<li><a href="#cioption-language{{ language.language_id }}" data-toggle="tab"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}" /> {{ language.name }}</a></li>
					{% endfor %}
				</ul>
				<div class="tab-content">
					{%  for language in languages %}
					<div class="tab-pane" id="cioption-language{{ language.language_id }}">
						<div class="form-group">
							<label class="col-sm-2 control-label" for="input-cioption-description{{ language.language_id }}">{{ entry_option_description }}</label>
							<div class="col-sm-10">
								<textarea name="option_description[{{ language.language_id }}][description]" placeholder="{{ entry_option_description }}" id="input-cioption-description{{ language.language_id }}" class="form-control" data-toggle="summernote" data-lang="{{ summernote }}">{{ option_description[language.language_id] ? option_description[language.language_id].description : '' }}</textarea>
							</div>
						</div>
					</div>
					{% endfor %}
				</div>
			</div>
			]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[{{ footer }}]]></search>
			<add position="before"><![CDATA[
				<link href="view/javascript/codemirror/lib/codemirror.css" rel="stylesheet" />
				<link href="view/javascript/codemirror/theme/monokai.css" rel="stylesheet" />
				<script type="text/javascript" src="view/javascript/codemirror/lib/codemirror.js"></script>
				<script type="text/javascript" src="view/javascript/codemirror/lib/xml.js"></script>
				<script type="text/javascript" src="view/javascript/codemirror/lib/formatting.js"></script>
				<script type="text/javascript" src="view/javascript/summernote/summernote.js"></script>
				<link href="view/javascript/summernote/summernote.css" rel="stylesheet" />
				<script type="text/javascript" src="view/javascript/summernote/summernote-image-attributes.js"></script>
				<script type="text/javascript" src="view/javascript/summernote/opencart.js"></script>
				<script type="text/javascript"><!--
				$('#cioption-language a:first').tab('show');
				//--></script>
			]]></add>
		</operation>
	</file>
	<file path="catalog/model/catalog/product.php">
		<operation error="skip">
			<search><![CDATA[$product_option['name'],]]></search>
			<add position="after"><![CDATA[
				'description'		   => isset($product_option['description']) ? $product_option['description'] : '',
			]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[$product_option_value['weight'],]]></search>
			<add position="after"><![CDATA[
				'ciopmodel'               => (isset($product_option_value['ciopmodel']) ? $product_option_value['ciopmodel'] : ''),
				'ciopimage'               => (isset($product_option_value['ciopimage']) ? $product_option_value['ciopimage'] : ''),
			]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[public function getProductOptions($product_id) {]]></search>
			<add position="after"><![CDATA[
				$this->load->language('product/ciopsku');
			]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[foreach ($product_option_value_query->rows as $product_option_value) {]]></search>
			<add position="before"><![CDATA[
				$this->load->language('product/cioption');
			]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[foreach ($product_option_value_query->rows as $product_option_value) {]]></search>
			<add position="after"><![CDATA[
				if(isset($product_option_value['ciopsku']) && trim($product_option_value['ciopsku']) != "" && $this->config->get('ciadvancedoptions_option_sku_status')) {
					$product_option_value['name'] = $product_option_value['name'] .' ('. $this->language->get('text_cisku') . $product_option_value['ciopsku'] . ' )';
				}
			]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[foreach ($product_option_value_query->rows as $product_option_value)]]></search>
			<add position="before"><![CDATA[
				if($this->config->get('ciadvancedoptions_customer_group_status')) {
					$product_option_value_query = $this->db->query("SELECT pov.*, ov.*, ovd.* FROM " . DB_PREFIX . "product_option_value pov LEFT JOIN " . DB_PREFIX . "option_value ov ON (pov.option_value_id = ov.option_value_id) LEFT JOIN " . DB_PREFIX . "option_value_description ovd ON (ov.option_value_id = ovd.option_value_id) LEFT JOIN " . DB_PREFIX . "product_option_value_group povg ON (povg.product_option_value_id = pov.product_option_value_id) WHERE pov.product_id = '" . (int)$product_id . "' AND (povg.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' OR (povg.customer_group_id is null AND povg.product_option_value_id is null AND povg.product_id is null)) AND pov.product_option_id = '" . (int)$product_option['product_option_id'] . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY ov.sort_order");
				}
			]]></add>
		</operation>
	</file>
	<file path="catalog/controller/journal3/price.php" info="for journal3">
		<operation error="skip">
		<search><![CDATA[public function index() {]]></search>
			<add position="after"><![CDATA[
				/*we disable journal3 live price update. When ci advanced product options > live option price is enabled*/
				if($this->config->get('ciadvancedoptions_status') && $this->config->get('ciadvancedoptions_option_price_status')) {
					return false;
				}
			]]></add>
		</operation>
	</file>
	<file path="catalog/controller/journal2/ajax.php" info="for journal2">
		<operation error="skip">
		<search><![CDATA[public function price() {]]></search>
			<add position="after"><![CDATA[
				/*we disable journal2 ajax live price update. When ci advanced product options > live option price is enabled*/
				if($this->config->get('ciadvancedoptions_status') && $this->config->get('ciadvancedoptions_option_price_status')) {
					return false;
				}
			]]></add>
		</operation>
	</file>
	<file path="catalog/controller/product/product.php">
		<operation error="skip">
		<search><![CDATA[$data['tab_review']]]></search>
			<add position="before"><![CDATA[
				$data['ciadvancedoptions_status'] = $this->config->get('ciadvancedoptions_status');
				$data['ciadvancedoptions_option_price_status'] = $this->config->get('ciadvancedoptions_option_price_status');
				$data['ciadvancedoptions_option_description_status'] = $this->config->get('ciadvancedoptions_option_description_status');
				$data['ciadvancedoptions_option_model_status'] = $this->config->get('ciadvancedoptions_option_model_status');
				$data['ciadvancedoptions_option_image_status'] = $this->config->get('ciadvancedoptions_option_image_status');

				$data['cimodel_type'] = $this->config->get('ciadvancedoptions_model_type');

				/*we get active theme. For JS purpose*/
				if($this->config->get('config_theme')) {
					$data['ciactive_theme'] = $this->config->get('config_theme');
				} else if($this->config->get('theme_default_directory')) {
					$data['ciactive_theme'] = $this->config->get('theme_default_directory');
				} else if($this->config->get('config_template')) {
					$data['ciactive_theme'] = $this->config->get('config_template');
				} else{
					$data['ciactive_theme'] = 'default';
				}

				if(empty($data['ciactive_theme'])) {
					$data['ciactive_theme'] = 'default';
				}

				if($data['ciadvancedoptions_option_image_status']) {
					$this->document->addScript('catalog/view/javascript/ciopimage.js');
				}
			]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[$option['name'],]]></search>
			<add position="after"><![CDATA[
				'description'          => isset($option['description']) ? html_entity_decode($option['description'], ENT_QUOTES, 'UTF-8') : '',
			]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[$product_option_value_data[] = array(]]></search>
			<add position="before"><![CDATA[
				/*CI option img starts*/
				if (!empty($option_value['ciopimage']) && is_file(DIR_IMAGE . $option_value['ciopimage'])) {


					if(defined('JOURNAL3_ACTIVE')) {
						$ciopimage['thumb'] = $this->model_journal3_image->resize($option_value['ciopimage'], $this->journal3->settings->get('image_dimensions_options.width'), $this->journal3->settings->get('image_dimensions_options.height'), $this->journal3->settings->get('image_dimensions_options.resize'));

						$ciopimage['galleryThumb'] =  $this->model_journal3_image->resize($option_value['ciopimage'], $this->journal3->settings->get('image_dimensions_popup_thumb.width'), $this->journal3->settings->get('image_dimensions_popup_thumb.height'), $this->journal3->settings->get('image_dimensions_popup_thumb.resize'));

						$ciopimage['image'] = $this->model_journal3_image->resize($option_value['ciopimage'], $this->journal3->settings->get('image_dimensions_thumb.width'), $this->journal3->settings->get('image_dimensions_thumb.height'), $this->journal3->settings->get('image_dimensions_thumb.resize'));
						$ciopimage['image2x'] = $this->model_journal3_image->resize($option_value['ciopimage'], $this->journal3->settings->get('image_dimensions_thumb.width') * 2, $this->journal3->settings->get('image_dimensions_thumb.height') * 2, $this->journal3->settings->get('image_dimensions_thumb.resize'));
						$ciopimage['popup'] = $this->model_journal3_image->resize($option_value['ciopimage'], $this->journal3->settings->get('image_dimensions_popup.width'), $this->journal3->settings->get('image_dimensions_popup.height'), $this->journal3->settings->get('image_dimensions_popup.resize'));


					} else {

						$ciopimage['thumb'] = $this->model_tool_image->resize($option_value['ciopimage'], 50, 50);

						if(strpos($this->config->get('config_template'), 'journal2') === 0) {
							$ciopimage['thumb'] = Journal2Utils::resizeImage($this->model_tool_image, $option_value['ciopimage'], $this->journal2->settings->get('product_page_options_push_image_width', 30), $this->journal2->settings->get('product_page_options_push_image_height', 30), 'crop');
						}

						$ciopimage['image2x'] = $ciopimage['image'] = $this->model_tool_image->resize($option_value['ciopimage'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_thumb_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_thumb_height'));

						$ciopimage['galleryThumb'] = $ciopimage['popup'] = $this->model_tool_image->resize($option_value['ciopimage'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_height'));
					}


				} else {
					$ciopimage['thumb'] = '';
					$ciopimage['image'] = '';
					$ciopimage['popup'] = '';
					/*these variables taken for journal3 only*/
					$ciopimage['galleryThumb'] = '';
					$ciopimage['image2x'] = '';
				}
				/*CI option img ends*/
			]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[$product_option_value_data[] = array(]]></search>
			<add position="after"><![CDATA[
				/*CI option img starts*/
				'ciopimage'                   => $ciopimage,
				/*CI option img ends*/
			]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[$option_value['option_value_id'],]]></search>
			<add position="after"><![CDATA[
				'ciopmodel'               => (isset($option_value['ciopmodel']) ? $option_value['ciopmodel'] : ''),
			]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[public function write()]]></search>
			<add position="before"><![CDATA[
				public function CiLiveOptionPrice() {
					$this->load->model('catalog/product');
					$this->language->load('product/product');
					$json = array();
					if(isset($this->request->get['product_id'])) {
						$product_id = $this->request->get['product_id'];
					} else {
						$product_id = 0;
					}

					$product_info = $this->model_catalog_product->getProduct($product_id);
					if($product_info) {
						if(!empty($this->request->post['quantity']) && (int)$this->request->post['quantity']) {
							$quantity = $this->request->post['quantity'];
						}else{
							$quantity = ($product_info['minimum']) ? $product_info['minimum'] : 1;
						}

						$price = $product_info['price'];
						$special = $product_info['special'];
						$option_price = 0;

						// SOME DEFAULT OPENCART CODE // THANK YOU :)
						if(isset($this->request->post['option'])) {
							foreach ($this->request->post['option'] as $product_option_id => $value) {
								$option_query = $this->db->query("SELECT po.product_option_id, po.option_id, od.name, o.type FROM " . DB_PREFIX . "product_option po LEFT JOIN `" . DB_PREFIX . "option` o ON (po.option_id = o.option_id) LEFT JOIN " . DB_PREFIX . "option_description od ON (o.option_id = od.option_id) WHERE po.product_option_id = '" . (int)$product_option_id . "' AND po.product_id = '" . (int)$product_info['product_id'] . "' AND od.language_id = '" . (int)$this->config->get('config_language_id') . "'");

								if ($option_query->num_rows) {
									if ($option_query->row['type'] == 'select' || $option_query->row['type'] == 'radio' || $option_query->row['type'] == 'image') {
										$option_value_query = $this->db->query("SELECT pov.option_value_id, ovd.name, pov.quantity, pov.price, pov.price_prefix FROM " . DB_PREFIX . "product_option_value pov LEFT JOIN " . DB_PREFIX . "option_value ov ON (pov.option_value_id = ov.option_value_id) LEFT JOIN " . DB_PREFIX . "option_value_description ovd ON (ov.option_value_id = ovd.option_value_id) WHERE pov.product_option_value_id = '" . (int)$value . "' AND pov.product_option_id = '" . (int)$product_option_id . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "'");

										if ($option_value_query->num_rows) {
											if ($option_value_query->row['price_prefix'] == '+') {
												$option_price += $option_value_query->row['price'];
											} elseif ($option_value_query->row['price_prefix'] == '-') {
												$option_price -= $option_value_query->row['price'];
											}
										}
									} elseif ($option_query->row['type'] == 'checkbox' && is_array($value)) {
										foreach ($value as $product_option_value_id) {
											$option_value_query = $this->db->query("SELECT pov.option_value_id, ovd.name, pov.quantity, pov.price, pov.price_prefix, pov.points, pov.points_prefix, pov.weight, pov.weight_prefix FROM " . DB_PREFIX . "product_option_value pov LEFT JOIN " . DB_PREFIX . "option_value ov ON (pov.option_value_id = ov.option_value_id) LEFT JOIN " . DB_PREFIX . "option_value_description ovd ON (ov.option_value_id = ovd.option_value_id) WHERE pov.product_option_value_id = '" . (int)$product_option_value_id . "' AND pov.product_option_id = '" . (int)$product_option_id . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "'");

											if ($option_value_query->num_rows) {
												if ($option_value_query->row['price_prefix'] == '+') {
													$option_price += $option_value_query->row['price'];
												} elseif ($option_value_query->row['price_prefix'] == '-') {
													$option_price -= $option_value_query->row['price'];
												}
											}
										}
									}
								}
							}
						}

						if($special) {
							$total_price = ($special + $option_price);
						} else {
							$total_price = ($price + $option_price);
						}

						if($special) {
							$json['cibaseprice'] = $this->currency->format($this->tax->calculate(($price + $option_price), $product_info['tax_class_id'], $this->config->get('config_tax')) * $quantity, $this->session->data['currency']);
						}

						if ($this->config->get('config_tax')) {
							$json['citaxprice'] = $this->currency->format($total_price * $quantity, $this->session->data['currency']);
						}

						$json['citotalprice'] = $this->currency->format($this->tax->calculate($total_price, $product_info['tax_class_id'], $this->config->get('config_tax')) * $quantity, $this->session->data['currency']);
					}

					$this->response->addHeader('Content-Type: application/json');
					$this->response->setOutput(json_encode($json));
				}
			]]></add>
		</operation>
	</file>
	<file path="catalog/view/theme/*/template/product/product.twig">
		<operation error="skip" for="radio,checkbox,file">
			<search><![CDATA[<label class="control-label">{{ option.name }}</label>]]></search>
			<add position="replace"><![CDATA[{% if ciadvancedoptions_status and ciadvancedoptions_option_description_status and option.description and option.description|trim %}
              	<label class="control-label"><a data-toggle="modal" href="#cioption-description-{{ option.option_id }}">{{ option.name }} <i class="fa fa-question-circle"></i></a></label>

              	{% else %}
              	<label class="control-label">{{ option.name }}</label>
              	{% endif %}]]></add>
		</operation>
		<operation error="skip" for="select,text,textarea,date,datetime,time">
			<search><![CDATA[<label class="control-label" for="input-option{{ option.product_option_id }}">{{ option.name }}</label>]]></search>
			<add position="replace"><![CDATA[{% if ciadvancedoptions_status and ciadvancedoptions_option_description_status and option.description and option.description|trim %}
              	<label class="control-label" for="input-option{{ option.product_option_id }}"><a data-toggle="modal" href="#cioption-description-{{ option.option_id }}">{{ option.name }} <i class="fa fa-question-circle"></i></a></label>
              	{% else %}
              	<label class="control-label" for="input-option{{ option.product_option_id }}">{{ option.name }}</label>
              	{% endif %}]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[<li>{{ text_model }}]]></search>
			<add position="replace"><![CDATA[<li class="ciopmodel">{{ text_model }}]]></add>
		</operation>
		<operation error="skip" info="for journal2">
			<search><![CDATA[<li class="p-model">{{ text_model }}]]></search>
			<add position="replace"><![CDATA[<li class="p-model ciopmodel">{{ text_model }}]]></add>
		</operation>
		<operation error="skip" info="for journal3">
			<search><![CDATA[<span>{{ model }}</span>]]></search>
			<add position="replace"><![CDATA[<span class="ciopmodel-j3">{{ model }}</span>]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[<h2>{{ price }}</h2>]]></search>
			<add position="replace"><![CDATA[<h2><span class="cibaseprice">{{ price }}</span></h2>]]></add>
		</operation>
		<operation error="skip" info="for journal3 and journal2">
			<search><![CDATA[class="product-price"]]></search>
			<add position="replace"><![CDATA[class="product-price cibaseprice"]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[style="text-decoration: line-through;"]]></search>
			<add position="replace"><![CDATA[style="text-decoration: line-through;" class="cioldprice"]]></add>
		</operation>
		<operation error="skip" info="for journal2">
			<search><![CDATA[class="price-old"]]></search>
			<add position="replace"><![CDATA[class="price-old cioldprice"]]></add>
		</operation>
		<operation error="skip" info="for journal3">
			<search><![CDATA[class="product-price-old"]]></search>
			<add position="replace"><![CDATA[class="product-price-old cioldprice"]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[{{ special }}]]></search>
			<add position="replace"><![CDATA[<span class="cibaseprice">{{ special }}</span>]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[<li>{{ text_tax }}]]></search>
			<add position="replace"><![CDATA[<li class="citaxprice">{{ text_tax }}]]></add>
		</operation>
		<operation error="skip" info="for journal2">
			<search><![CDATA[class="price-tax"]]></search>
			<add position="replace"><![CDATA[class="price-tax citaxprice"]]></add>
		</operation>
		<operation error="skip" info="for journal3">
			<search><![CDATA[class="product-tax"]]></search>
			<add position="replace"><![CDATA[class="product-tax citaxprice"]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[<input type="radio" name="option[{{ option.product_option_id }}]" value="{{ option_value.product_option_value_id }}" />]]></search>
			<add position="after"><![CDATA[
				{% if option_value.ciopimage.thumb %}
	            <img src="{{ option_value.ciopimage.thumb }}" alt="{{ option_value.name }} {% if option_value.price %} {{ option_value.price_prefix }} {{ option_value.price }} {% endif %}" class="img-thumbnail" />
	            {% endif %}
			]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[<input type="checkbox" name="option[{{ option.product_option_id }}][]" value="{{ option_value.product_option_value_id }}" />]]></search>
			<add position="after"><![CDATA[
				{% if option_value.ciopimage.thumb %}
	            <img src="{{ option_value.ciopimage.thumb }}" alt="{{ option_value.name }} {% if option_value.price %} {{ option_value.price_prefix }} {{ option_value.price }} {% endif %}" class="img-thumbnail" />
	            {% endif %}
			]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[src="{{ thumb }}"]]></search>
			<add position="replace"><![CDATA[src="{{ thumb }}" data-ciopsrc="{{ thumb }}"]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[href="{{ popup }}"]]></search>
			<add position="replace"><![CDATA[href="{{ popup }}" data-ciophref="{{ popup }}"]]></add>
		</operation>
		<operation error="skip" info="for journal3">
			<search><![CDATA[data-largeimg="{{ image.popup }}"]]></search>
			<add position="replace"><![CDATA[data-largeimg="{{ image.popup }}" data-ciophref="{{ image.popup }}" data-ciopsrc="{{ image.image }}" {% if j3 and image.galleryThumb %}data-ciopgalleryThumb="{{ image.galleryThumb }}{% endif %}"]]></add>
		</operation>
		<operation error="skip" info="for journal3">
			<search><![CDATA[data-images='{{ gallery|json_encode }}']]></search>
			<add position="replace"><![CDATA[data-images='{{ gallery|json_encode }}' data-oimages='{{ gallery|json_encode }}']]></add>
		</operation>
		<operation error="skip" info="for journal3.0.18">
			<search><![CDATA[data-images='{{ gallery|json_encode|e }}']]></search>
			<add position="replace"><![CDATA[data-images='{{ gallery|json_encode|e }}' data-oimages='{{ gallery|json_encode|e }}']]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[<option value="{{ option_value.product_option_value_id }}]]></search>
			<add position="replace"><![CDATA[<option data-ciopimage="{{ option_value.ciopimage.image }}" data-ciopimagepopup="{{ option_value.ciopimage.popup }}" data-ciopimagegalleryThumb="{{ option_value.ciopimage.galleryThumb }}" value="{{ option_value.product_option_value_id }}]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[type="radio" name="option[{{ option.product_option_id }}]"]]></search>
			<add position="replace"><![CDATA[data-ciopimage="{{ option_value.ciopimage.image }}" data-ciopimagepopup="{{ option_value.ciopimage.popup }}" data-ciopimagegalleryThumb="{{ option_value.ciopimage.galleryThumb }}" type="radio" name="option[{{ option.product_option_id }}]"]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[type="checkbox" name="option[{{ option.product_option_id }}][]"]]></search>
			<add position="replace"><![CDATA[data-ciopimage="{{ option_value.ciopimage.image }}" data-ciopimagepopup="{{ option_value.ciopimage.popup }}" data-ciopimagegalleryThumb="{{ option_value.ciopimage.galleryThumb }}" type="checkbox" name="option[{{ option.product_option_id }}][]"]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[{{ footer }}]]></search>
			<add position="before"><![CDATA[
				{% if ciadvancedoptions_status %}
					<script type="text/javascript"><!--
					ciactive_theme = '{{ ciactive_theme }}';
					//--></script>

					{% if ciadvancedoptions_option_description_status %}
						{% for option in options %}
							{% if option.description and option.description|trim %}
							<div class="modal fade cioption-description" id="cioption-description-{{ option.option_id }}" role="dialog"><div class="modal-dialog"><div class="modal-content"><div class="modal-body"><button type="button" class="close" data-dismiss="modal">&times;</button>{{ option.description }}</div></div></div></div>
							{% endif %}
						{% endfor %}
						<style>
						<!-- for journal3 -->
						.product-info .product-options .modal.cioption-description {
							display: none;
						}
						</style>
					{% endif %}

					{% if ciadvancedoptions_option_price_status %}
					<script type="text/javascript"><!--
					function CiLiveOptionPrice() {
						var optionpriceurl = 'index.php?route=product/product/CiLiveOptionPrice&product_id={{ product_id }}';
						$.ajax({
							url: optionpriceurl,
							type: 'post',
							data: $('#product input[type=\'text\'], #product input[type=\'radio\']:checked, #product input[type=\'checkbox\']:checked, #product select'),
							dataType: 'json',
							beforeSend: function() {
							},
							success: function(json) {
								if(json['cibaseprice']) {
									$('.cioldprice').html(json['cibaseprice']);
								}

								if(json['citaxprice']) {
									$('.citaxprice').html('{{ text_tax }} '+ json['citaxprice']);
								}

								if(json['citotalprice']) {
									$('.cibaseprice').html(json['citotalprice']);
								}
							}
						});
					}

					$('#product').delegate('select, input[type=\'radio\'], input[type=\'checkbox\']', 'change', function() { CiLiveOptionPrice(); });
					$('#product').delegate('input[name=\'quantity\']', 'keyup', function() { CiLiveOptionPrice(); });
					$(document).ready(function() { CiLiveOptionPrice(); });
					//--></script>
					{% endif %}

					{% if ciadvancedoptions_option_model_status %}
					<script type="text/javascript"><!--
					$('#product').delegate('select, input[type=\'radio\'], input[type=\'checkbox\']', 'change', function() {
						if(($(this).attr("type")=="radio" || $(this).attr("type")=="checkbox")) {
							if($(this).prop('checked')) {
								var thisid = $(this).val();
							} else {
								var thisid = '';
							}
						} else {
							var thisid = $(this).val();
						}

						var cimodel_type = '{{ cimodel_type }}';

					  	if(thisid) {
					  			var ci_model_array = [];
								{% for option in options %}
								{% for product_option_value in option.product_option_value %}
								{% if product_option_value.ciopmodel %}
								ci_model_array.push({ 'id' : '{{ product_option_value.product_option_value_id }}', 'ciopmodel' : '{{ product_option_value.ciopmodel ? product_option_value.ciopmodel : '' }}' });
								{% endif %}
								{% endfor %}
								{% endfor %}

								/* Product Model + Option Model */
								/* Show Only Option Model */
								if(cimodel_type == 'add_model' || cimodel_type == 'replace_add_model') {
									$.each(ci_model_array, function(index,element) {
										if(thisid == element.id && element.ciopmodel) {
											var add_model_html = '{{ text_model }} ';
											if(cimodel_type == 'add_model') {
											add_model_html += '{{ model }}';
											}
											add_model_html += element.ciopmodel;
											$('.ciopmodel').html(add_model_html);
										}
							    	});
						    	}

								/* Product Model + Option Model + Option Model */
								/* Show Only Option Model + Option Model */
						    	if(cimodel_type == 'concat_model' || cimodel_type == 'replace_concat_model') {
									var contact_model_html = '{{ text_model }} ';

									if(cimodel_type == 'concat_model') {
									contact_model_html += '{{ model }}';
									}

									$.each($('#product').find('select, input[type=\'radio\'], input[type=\'checkbox\']'), function() {
										{% for option in options %}
										{% for product_option_value in option.product_option_value %}
										{% if product_option_value.ciopmodel %}
										var meid = '{{ product_option_value.product_option_value_id }}';

										var $thiss = $(this);
										if(($thiss.is("select") && $thiss.val()) || ($thiss.attr("type")=="radio" && $thiss.is("input") && $thiss.prop("checked")) || ($thiss.attr("type")=="checkbox") && $thiss.is("input") && $thiss.prop("checked")) {
											if($thiss.val() == meid)  {
												contact_model_html += '{{ product_option_value.ciopmodel }}';
											}
										}
										{% endif %}
										{% endfor %}
										{% endfor %}
									});

									$('.ciopmodel').html(contact_model_html);
								}
					  	} else {
					  		/* Product Model + Option Model */
					  		/* Show Only Option Model */
					  		if(cimodel_type == 'add_model' || cimodel_type == 'replace_add_model') {
					  	  		$.each($('#product').find('select, input[type=\'radio\'], input[type=\'checkbox\']'), function() {
						        	{% for option in options %}
									{% for product_option_value in option.product_option_value %}
									{% if product_option_value.ciopmodel %}
						    		var meid = '{{ product_option_value.product_option_value_id }}';

						    		var $thiss = $(this);
						    		if(($thiss.is("select") && $thiss.val()) || ($thiss.attr("type")=="radio" && $thiss.is("input") && $thiss.prop("checked")) || ($thiss.attr("type")=="checkbox") && $thiss.is("input") && $thiss.prop("checked")) {
							    		if($thiss.val() == meid)  {
							    			var add_model_html = '{{ text_model }} ';
							    			if(cimodel_type == 'add_model') {
									        add_model_html += '{{ model }}';
									        }
									        add_model_html += '{{ product_option_value.ciopmodel }}';
									        $('.ciopmodel').html(add_model_html);
							    		}
						    		}
						    		{% endif %}
									{% endfor %}
									{% endfor %}
					      		});
					  		}

					  		/* Product Model + Option Model + Option Model */
							/* Show Only Option Model + Option Model */
					  		if(cimodel_type == 'concat_model' || cimodel_type == 'replace_concat_model') {
					  	  		var concat_model_html = '{{ text_model }} ';

					  	  		if(cimodel_type == 'concat_model') {
					  	  		concat_model_html += '{{ model }}';
					  	  		}

								var has_cimodal = false;
								$.each($('#product').find('select, input[type=\'radio\'], input[type=\'checkbox\']'), function() {
									{% for option in options %}
									{% for product_option_value in option.product_option_value %}
									{% if product_option_value.ciopmodel %}
									var meid = '{{ product_option_value.product_option_value_id }}';
									var $thiss = $(this);
									if(($thiss.is("select") && $thiss.val()) || ($thiss.attr("type")=="radio" && $thiss.is("input") && $thiss.prop("checked")) || ($thiss.attr("type")=="checkbox") && $thiss.is("input") && $thiss.prop("checked")) {
										if($thiss.val() == meid)  {
											concat_model_html += '{{ product_option_value.ciopmodel }}';
											has_cimodal = true;
										}
									}
									{% endif %}
									{% endfor %}
									{% endfor %}
								});

								if(has_cimodal) {
									$('.ciopmodel').html(concat_model_html);
								}
					  		}

					  		/* No Option Selected */
						  	var isanyoption = $('#product input[type=\'radio\']:checked, #product input[type=\'checkbox\']:checked').length;
						 	if(!isanyoption && !$('#product select').val()) {
						  		var html2 = '{{ text_model }} ';
						        html2 += '{{ model }}';
						        $('.ciopmodel').html(html2);
						  }
					  	}
					});
					//--></script>
					{% endif %}
				{% endif %}
			]]></add>
		</operation>
	</file>
	<file path="catalog/controller/checkout/cart.php">
		<operation error="skip">
			<search><![CDATA[foreach ($product_options as $product_option) {]]></search>
			<add position="before"><![CDATA[
			$product_info['oimage'] = $product_info['image'];
			]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[foreach ($product_options as $product_option) {]]></search>
			<add position="after"><![CDATA[
			if(isset($option[$product_option['product_option_id']])) {
				foreach($product_option['product_option_value'] as $product_option_value) {
					if(is_array($option[$product_option['product_option_id']])) {
						if(in_array($product_option_value['product_option_value_id'], $option[$product_option['product_option_id']]) && !empty($product_option_value['ciopimage'])) {
								$product_info['image'] = $product_option_value['ciopimage'];
							}
					} else {
						if($product_option_value['product_option_value_id'] == $option[$product_option['product_option_id']] && !empty($product_option_value['ciopimage'])) {
							$product_info['image'] = $product_option_value['ciopimage'];
						}
					}

				}

			}
			]]></add>
		</operation>
	</file>
	<file path="catalog/controller/checkout/{cart,confirm}*.php">
		<operation error="skip">
			<search><![CDATA[20 ? utf8_substr($value, 0, 20]]></search>
			<add position="replace"><![CDATA[40 ? utf8_substr($value, 0, 40]]></add>
		</operation>
	</file>
	<file path="catalog/controller/common/cart.php">
		<operation error="skip">
			<search><![CDATA[20 ? utf8_substr($value, 0, 20]]></search>
			<add position="replace"><![CDATA[40 ? utf8_substr($value, 0, 40]]></add>
		</operation>
	</file>
	<file path="catalog/model/checkout/order.php">
		<operation error="skip">
			<search><![CDATA[20 ? utf8_substr($value, 0, 20]]></search>
			<add position="replace"><![CDATA[40 ? utf8_substr($value, 0, 40]]></add>
		</operation>
	</file>
	<file path="system/library/cart/cart.php">
		<operation error="skip">
			<search><![CDATA[$option_data = array();]]></search>
			<add position="after"><![CDATA[
				$ciopmodel = '';
			]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[pov.weight_prefix]]></search>
			<add position="replace"><![CDATA[pov.weight_prefix, pov.ciopmodel, pov.ciopimage]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[$product_query->row['model'],]]></search>
			<add position="replace"><![CDATA[$product_query->row['model'] . ($this->config->get('ciadvancedoptions_option_model_status') ? $ciopmodel : ''),]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[$this->customer = $registry->get('customer');]]></search>
			<add position="after"><![CDATA[
				$this->load = $registry->get('load');
				$this->language = $registry->get('language');
				$this->load->language('product/cioption');
			]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[pov.weight_prefix]]></search>
			<add position="replace"><![CDATA[pov.weight_prefix, pov.ciopsku]]></add>
		</operation>
		<operation error="skip">
			<search index="0,1"><![CDATA[$option_data[] = array(]]></search>
			<add position="before"><![CDATA[
				if(isset($option_value_query->row['ciopsku']) && trim($option_value_query->row['ciopsku']) != "" && $this->config->get('ciadvancedoptions_option_sku_status')) {
					$option_value_query->row['name'] = $option_value_query->row['name'] .' ('. $this->language->get('text_cisku') . $option_value_query->row['ciopsku'] . ' )';
				}

				if ($option_query->row['type'] == 'select' || $option_query->row['type'] == 'radio' || $option_query->row['type'] == 'checkbox') {
					if(isset($option_value_query->row['ciopmodel']) && trim($option_value_query->row['ciopmodel']) != "") {
						if($this->config->get('ciadvancedoptions_model_type') == 'add_model') {
							$ciopmodel = $option_value_query->row['ciopmodel'];
						}

						if($this->config->get('ciadvancedoptions_model_type') == 'concat_model') {
							$ciopmodel .= $option_value_query->row['ciopmodel'];
						}

						if($this->config->get('ciadvancedoptions_model_type') == 'replace_add_model') {
							$product_query->row['model'] = '';
							$ciopmodel = $option_value_query->row['ciopmodel'];
						}

						if($this->config->get('ciadvancedoptions_model_type') == 'replace_concat_model') {
							$product_query->row['model'] = '';
							$ciopmodel .= $option_value_query->row['ciopmodel'];
						}
					}
				}
			]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[WHERE pov.product_option_value_id = '" . (int)$value . "' AND pov.product_option_id = '" . (int)$product_option_id . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "'");]]></search>
			<add position="after"><![CDATA[
				if($this->config->get('ciadvancedoptions_customer_group_status')) {
					$option_value_query = $this->db->query("SELECT pov.option_value_id, ovd.name, pov.quantity, pov.subtract, pov.price, pov.price_prefix, pov.points, pov.points_prefix, pov.weight, pov.weight_prefix, pov.ciopsku, pov.ciopmodel, pov.ciopimage, ovd.name FROM " . DB_PREFIX . "product_option_value pov LEFT JOIN " . DB_PREFIX . "option_value ov ON (pov.option_value_id = ov.option_value_id) LEFT JOIN " . DB_PREFIX . "option_value_description ovd ON (ov.option_value_id = ovd.option_value_id) LEFT JOIN " . DB_PREFIX . "product_option_value_group povg ON (povg.product_option_value_id = pov.product_option_value_id) WHERE pov.product_option_value_id = '" . (int)$value . "' AND (povg.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' OR (povg.customer_group_id is null AND povg.product_option_value_id is null AND povg.product_id is null)) AND pov.product_option_id = '" . (int)$product_option_id . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
				}
			]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[WHERE pov.product_option_value_id = '" . (int)$product_option_value_id . "' AND pov.product_option_id = '" . (int)$product_option_id . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "'");]]></search>
			<add position="after"><![CDATA[
				if($this->config->get('ciadvancedoptions_customer_group_status')) {
					$option_value_query = $this->db->query("SELECT pov.option_value_id, pov.quantity, pov.subtract, pov.price, pov.price_prefix, pov.points, pov.points_prefix, pov.weight, pov.weight_prefix, pov.ciopsku, pov.ciopmodel, pov.ciopimage, ovd.name FROM " . DB_PREFIX . "product_option_value pov LEFT JOIN " . DB_PREFIX . "option_value_description ovd ON (pov.option_value_id = ovd.option_value_id) LEFT JOIN " . DB_PREFIX . "product_option_value_group povg ON (povg.product_option_value_id = pov.product_option_value_id) WHERE pov.product_option_value_id = '" . (int)$product_option_value_id . "' AND (povg.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' OR (povg.customer_group_id is null AND povg.product_option_value_id is null AND povg.product_id is null)) AND pov.product_option_id = '" . (int)$product_option_id . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
				}
			]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[if ($option_value_query->num_rows) {]]></search>
			<add position="after"><![CDATA[
				if(!empty($option_value_query->row['ciopimage'])) {
					$product_query->row['image'] = $option_value_query->row['ciopimage'];
				}
			]]></add>
		</operation>
	</file>
</modification>