Перейти к публикации
Поиск в
  • Дополнительно...
Искать результаты, содержащие...
Искать результаты в...

Как реализовать ввод и вывод дополнительной цены?


Dart990
 Поделиться

Рекомендованные сообщения

Имеется карточка товара с двумя ценами. Необходимо реализовать третью и выводить как на скрине (салатовая). Но на скрине реализовано с помощью модуля  Additional information, то-есть текст введенный руками, что учитывая скачки курса возможно, но неудобно. 

Цена вводится в админке в USD. Необходимо что бы эта третья цена так же вводилась и считалась по курсу, либо формировалась из имеющейся вычитанием заданной разницы. Эта цена никуда в расчеты не идет, выводится для информации и показывается только в карточке товара на сайте (в перспективе можно и что бы она учитывалась в заказе если ставить галочку  предоплата).

Самым удобным считаю вводить третью цену отдельно в USD и что бы она как оригинальная цена считалась по курсу и выводилась в региональной валюте.

Подскажите, может кто знает модуль с похожим функционалом или как реализовать код? Дополнительное поле рядом с основной ценой в админке, куда вводиться эта третья цена, которая считается по курсу и вывод её на страничке товара. Или может кто-то возьмется, готовы заплатить.

Opencart 1.5.6.4.

post-688893-0-58981000-1472332087_thumb.jpg

Изменено пользователем Dart990
Ссылка на комментарий
Поделиться на других сайтах


Обратите внимание на этот чудный модуль. Проверено, рабочий, у себя организовал так

 

Спасибо, это то что нужно.

Кто-то может помочь (за дополнительную плату), в файле price.xml (vqmod...) дописать код на основе уже имеющегося, нужно только вроде как указать между тегами <search> правильные участки кода для пары других блоков где нужно чтоб модуль отображал цену. На данный момент отображает в карточке товаров, категории, поиске и в производителях, и для этих блоков код один и тот же за исключением естественно того что в <search>. Ниже код для категорий, как пример. 

 

<file name="catalog/controller/product/category.php">
		<operation error="skip">
		<search position="before"><![CDATA[	$this->data['products'][] = array(	]]></search>
		<add><![CDATA[
		
		$this->document->addStyle('catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/tooltips.css');
		
		@$discounts_g = @$this->model_catalog_product->getProductDiscountPrice_Group($result['product_id']);
		$discounts_d = $this->model_catalog_product->getProductDiscountPrice_Default($result['product_id']);
		
		if ($this->customer->isLogged()) {	
		$discount = $this->currency->format($this->tax->calculate($discounts_d, $result['tax_class_id'], $this->config->get('config_tax')));
		$d = 'Обычная цена:  <br />' . $discount;
		} else {
		if ($discounts_g > 0) {
		$discount = $this->currency->format($this->tax->calculate($discounts_g, $result['tax_class_id'], $this->config->get('config_tax')));
		} else {
		if ((float)$result['special']) {
		$discount = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')));
		} else {
		//$discount = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
		$discount = null;
		}
		}
		if ($discount == null) {
		$d = null;
		} else {
		$d = '<a class="tooltip_category" title="Стоимость ' . $result['name'] . ' для клиентов оплачивающих товар по предоплате.">По предоплате ' . $discount . '</a>';
		}
		}
		]]></add>
		</operation>
		
		<operation error="skip">
		<search position="after"><![CDATA[	product_id'  => $result['product_id'], ]]></search>
		<add><![CDATA[	'discount'	=> $d,	]]></add>
		</operation>
</file>

<file name="catalog/view/theme/*/template/product/category.tpl">
	<operation error="skip">
		<search position="before">
		<![CDATA[
		<?php if ($product['rating']) { ?>
		]]></search>
		<add>
		<![CDATA[
		<div class="discount_cat"><?php echo $product['discount']; ?></div>
		]]>
		</add>
	</operation>
	
	<operation error="skip">
		<search position="before">
		<![CDATA[
		var rating = $(element).find('.rating').html();
		]]></search>
		<add>
		<![CDATA[
		var d = $(element).find('.discount_cat').html();
		if (d != null) {
			html += '<div class="discount_cat">' + d  + '</div>';
		}
		]]>
		</add>
	</operation>
</file>
Изменено пользователем Dart990
Ссылка на комментарий
Поделиться на других сайтах


Отметил блоки внизу (1,2,3) в которых нужно добавить правильные участки кода между тегами <search>, и возможно изменить пару переменных в <add>. Работу оплачу!

<?xml version="1.0" encoding="UTF-8"?>
<modification>

	<file name="catalog/model/catalog/product.php">
		<operation error="skip">
		<search position="before"><![CDATA[	public function getTotalProductSpecials() ]]></search>
		<add><![CDATA[
		public function getProductDiscountPrice_Group($product_id) {
			$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "' ORDER BY price ASC");
		if ($query->num_rows > 0) {
			return $query->row['price'];
			echo $query->row['price'];
		} else {
		}
		}
		public function getProductDiscountPrice_Default($product_id) {
			$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product WHERE product_id = '" . (int)$product_id . "' ORDER BY price ASC");
		return $query->row['price'];		
		}
		]]></add>
		</operation>
	</file>
	
	<file name="catalog/controller/product/category.php">
		<operation error="skip">
		<search position="before"><![CDATA[	$this->data['products'][] = array(	]]></search>
		<add><![CDATA[
		
		$this->document->addStyle('catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/tooltips.css');
		
		@$discounts_g = @$this->model_catalog_product->getProductDiscountPrice_Group($result['product_id']);
		$discounts_d = $this->model_catalog_product->getProductDiscountPrice_Default($result['product_id']);
		
		if ($this->customer->isLogged()) {	
		$discount = $this->currency->format($this->tax->calculate($discounts_d, $result['tax_class_id'], $this->config->get('config_tax')));
		$d = 'Обычная цена:  <br />' . $discount;
		} else {
		if ($discounts_g > 0) {
		$discount = $this->currency->format($this->tax->calculate($discounts_g, $result['tax_class_id'], $this->config->get('config_tax')));
		} else {
		if ((float)$result['special']) {
		$discount = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')));
		} else {
		//$discount = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
		$discount = null;
		}
		}
		if ($discount == null) {
		$d = null;
		} else {
		$d = '<a class="tooltip_category" title="Стоимость ' . $result['name'] . ' для клиентов оплачивающих товар по предоплате.">По предоплате ' . $discount . '</a>';
		}
		}
		]]></add>
		</operation>
		
		<operation error="skip">
		<search position="after"><![CDATA[	product_id'  => $result['product_id'], ]]></search>
		<add><![CDATA[	'discount'	=> $d,	]]></add>
		</operation>
	</file>
	
	<file name="catalog/controller/product/search.php">
		<operation error="skip">
		<search position="before"><![CDATA[	$this->data['products'][] = array(	]]></search>
		<add><![CDATA[
		
		$this->document->addStyle('catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/tooltips.css');
		@$discounts_g = @$this->model_catalog_product->getProductDiscountPrice_Group($result['product_id']);
		$discounts_d = $this->model_catalog_product->getProductDiscountPrice_Default($result['product_id']);
		
		if ($this->customer->isLogged()) {	
		$discount = $this->currency->format($this->tax->calculate($discounts_d, $result['tax_class_id'], $this->config->get('config_tax')));
		$d = 'Обычная цена:  <br />' . $discount;
		} else {
		if ($discounts_g > 0) {
		$discount = $this->currency->format($this->tax->calculate($discounts_g, $result['tax_class_id'], $this->config->get('config_tax')));
		} else {
		if ((float)$result['special']) {
		$discount = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')));
		} else {
		$discount = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
		}
		}
		if ($discount == null) {
		$d = null;
		} else {
		$d = '<a class="tooltip_search" title="Стоимость ' . $result['name'] . ' для клиентов оплачивающих товар по предоплате.">По предоплате ' . $discount . '</a>';
		}
		}
		]]></add>
		</operation>
		
		<operation error="skip">
		<search position="after"><![CDATA[	product_id'  => $result['product_id'], ]]></search>
		<add><![CDATA[	'discount'	=> $d,	]]></add>
		</operation>
	</file>

	<file name="catalog/controller/product/manufacturer.php">
		<operation error="skip">
		<search position="before"><![CDATA[	$this->data['products'][] = array(	]]></search>
		<add><![CDATA[
		
		$this->document->addStyle('catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/tooltips.css');
		@$discounts_g = @$this->model_catalog_product->getProductDiscountPrice_Group($result['product_id']);
		$discounts_d = $this->model_catalog_product->getProductDiscountPrice_Default($result['product_id']);
		
		if ($this->customer->isLogged()) {	
		$discount = $this->currency->format($this->tax->calculate($discounts_d, $result['tax_class_id'], $this->config->get('config_tax')));
		$d = 'Обычная цена:  <br />' . $discount;
		} else {
		if ($discounts_g > 0) {
		$discount = $this->currency->format($this->tax->calculate($discounts_g, $result['tax_class_id'], $this->config->get('config_tax')));
		} else {
		if ((float)$result['special']) {
		$discount = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')));
		} else {
		$discount = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
		}
		}
		if ($discount == null) {
		$d = null;
		} else {
		$d = '<a class="tooltip_manufacturer" title="Стоимость ' . $result['name'] . ' для клиентов оплачивающих товар по предоплате.">По предоплате ' . $discount . '</a>';
		}
		}
		]]></add>
		</operation>
		
		<operation error="skip">
		<search position="after"><![CDATA[	product_id'  => $result['product_id'], ]]></search>
		<add><![CDATA[	'discount'	=> $d,	]]></add>
		</operation>
	</file>
	
	<file name="catalog/controller/product/product.php">
		<operation error="skip">
		<search position="before"><![CDATA[	$this->data['options'] = array(); ]]></search>
		<add><![CDATA[
		
		$this->document->addStyle('catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/tooltips.css');
		$discounts_g = $this->model_catalog_product->getProductDiscountPrice_Group($this->request->get['product_id']);
		$discounts_d = $this->model_catalog_product->getProductDiscountPrice_Default($this->request->get['product_id']);
			
		if ($this->customer->isLogged()) {
		if ($discounts_g <= 1) {
		$this->data['discount'] = null;
		$this->data['text'] = null;
		} else {
		$this->data['discount'] = $this->currency->format($this->tax->calculate($discounts_d, $product_info['tax_class_id'], $this->config->get('config_tax')));
		$this->data['text'] = '<a class="tooltip" style="text-decoration:none; border-bottom: dashed 1px;" title="Данная цена для гостей.">Обычная цена:</a> ';
		}
		} else {
		$this->data['discount'] = $this->currency->format($this->tax->calculate($discounts_g, $product_info['tax_class_id'], $this->config->get('config_tax')));
		$this->data['text'] = '<a class="tooltip" style="/*text-decoration:none; border-bottom: dashed 1px;*/" title="Стоимость ' . $product_info['name'] . ' для клиентов оплачивающих товар по предоплате.">(по предоплате)</a> ';
		}
	]]></add>
		</operation>
	</file>
	
	<file name="catalog/view/theme/*/template/product/category.tpl">
	<operation error="skip">
		<search position="before">
		<![CDATA[
		<?php if ($product['rating']) { ?>
		]]></search>
		<add>
		<![CDATA[
		<div class="discount_cat"><?php echo $product['discount']; ?></div>
		]]>
		</add>
	</operation>
	
	<operation error="skip">
		<search position="before">
		<![CDATA[
		var rating = $(element).find('.rating').html();
		]]></search>
		<add>
		<![CDATA[
		var d = $(element).find('.discount_cat').html();
		if (d != null) {
			html += '<div class="discount_cat">' + d  + '</div>';
		}
		]]>
		</add>
	</operation>
	</file>
	
	
	<file name="catalog/view/theme/*/template/product/search.tpl">
	<operation error="skip">
		<search position="before">
		<![CDATA[
		<?php if ($product['rating']) { ?>
		]]></search>
		<add>
		<![CDATA[
		<div class="discount_cat"><?php echo $product['discount']; ?></div>
		]]>
		</add>
	</operation>
	
	<operation error="skip">
		<search position="before">
		<![CDATA[
		var rating = $(element).find('.rating').html();
		]]></search>
		<add>
		<![CDATA[
		var d = $(element).find('.discount_cat').html();
		if (d != null) {
			html += '<div class="discount_cat">' + d  + '</div>';
		}
		]]>
		</add>
	</operation>
	</file>
	
	<file name="catalog/view/theme/*/template/product/manufacturer_info.tpl">
	<operation error="skip">
		<search position="before">
		<![CDATA[
		<?php if ($product['rating']) { ?>
		]]></search>
		<add>
		<![CDATA[
		<div class="discount_cat"><?php echo $product['discount']; ?></div>
		]]>
		</add>
	</operation>
	
	<operation error="skip">
		<search position="before">
		<![CDATA[
		var rating = $(element).find('.rating').html();
		]]></search>
		<add>
		<![CDATA[
		var d = $(element).find('.discount_cat').html();
		if (d != null) {
			html += '<div class="discount_cat">' + d  + '</div>';
		}
		]]>
		</add>
	</operation>
	</file>
	
	<file name="catalog/view/theme/*/template/product/product.tpl">
	<operation error="skip">
		<search position="before">
		<![CDATA[
		 <?php if ($discounts) { ?>
		]]></search>
		<add>
		<![CDATA[
		<style type="text/css">
		.discount_prod{}
		</style>
		 <?php if ($discount > 0) { ?>
        <div class="discount_prod"><?php echo $discount; ?><?php echo $text; ?></div>
        <?php } ?>
		]]>
		</add>
	</operation>
	</file>
	
	
	------------------------------------------------------------------------------
	
	********** 1 **********
	
	<file name="catalog/controller/module/filterpro.php">
		<operation error="skip">
		<search position="before"><![CDATA[	$this->data['products'][] = array(	]]></search>
		<add><![CDATA[
		
		$this->document->addStyle('catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/tooltips.css');
		
		@$discounts_g = @$this->model_catalog_product->getProductDiscountPrice_Group($result['product_id']);
		$discounts_d = $this->model_catalog_product->getProductDiscountPrice_Default($result['product_id']);
		
		if ($this->customer->isLogged()) {	
		$discount = $this->currency->format($this->tax->calculate($discounts_d, $result['tax_class_id'], $this->config->get('config_tax')));
		$d = 'Обычная цена:  <br />' . $discount;
		} else {
		if ($discounts_g > 0) {
		$discount = $this->currency->format($this->tax->calculate($discounts_g, $result['tax_class_id'], $this->config->get('config_tax')));
		} else {
		if ((float)$result['special']) {
		$discount = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')));
		} else {
		//$discount = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
		$discount = null;
		}
		}
		if ($discount == null) {
		$d = null;
		} else {
		$d = '<a class="tooltip_category" title="Стоимость ' . $result['name'] . ' для клиентов оплачивающих товар по предоплате.">По предоплате ' . $discount . '</a>';
		}
		}
		]]></add>
		</operation>
	</file>	
	
	<file name="catalog/view/theme/*/template/module/filterpro.tpl">
	<operation error="skip">
		<search position="before">
		<![CDATA[
		<?php if ($product['rating']) { ?>
		]]></search>
		<add>
		<![CDATA[
		<div class="discount_cat"><?php echo $product['discount']; ?></div>
		]]>
		</add>
	</operation>
	
	<operation error="skip">
		<search position="before">
		<![CDATA[
		var rating = $(element).find('.rating').html();
		]]></search>
		<add>
		<![CDATA[
		var d = $(element).find('.discount_cat').html();
		if (d != null) {
			html += '<div class="discount_cat">' + d  + '</div>';
		}
		]]>
		</add>
	</operation>
	</file>
	
	********** 2 **********
	
	<file name="catalog/controller/module/product_tab.php">
		<operation error="skip">
		<search position="before"><![CDATA[	$this->data['products'][] = array(	]]></search>
		<add><![CDATA[
		
		$this->document->addStyle('catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/tooltips.css');
		
		@$discounts_g = @$this->model_catalog_product->getProductDiscountPrice_Group($result['product_id']);
		$discounts_d = $this->model_catalog_product->getProductDiscountPrice_Default($result['product_id']);
		
		if ($this->customer->isLogged()) {	
		$discount = $this->currency->format($this->tax->calculate($discounts_d, $result['tax_class_id'], $this->config->get('config_tax')));
		$d = 'Обычная цена:  <br />' . $discount;
		} else {
		if ($discounts_g > 0) {
		$discount = $this->currency->format($this->tax->calculate($discounts_g, $result['tax_class_id'], $this->config->get('config_tax')));
		} else {
		if ((float)$result['special']) {
		$discount = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')));
		} else {
		//$discount = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
		$discount = null;
		}
		}
		if ($discount == null) {
		$d = null;
		} else {
		$d = '<a class="tooltip_category" title="Стоимость ' . $result['name'] . ' для клиентов оплачивающих товар по предоплате.">По предоплате ' . $discount . '</a>';
		}
		}
		]]></add>
		</operation>
	</file>	
	
	<file name="catalog/view/theme/*/template/module/product_tab.tpl">
	<operation error="skip">
		<search position="before">
		<![CDATA[
		<?php if ($product['rating']) { ?>
		]]></search>
		<add>
		<![CDATA[
		<div class="discount_cat"><?php echo $product['discount']; ?></div>
		]]>
		</add>
	</operation>
	
	<operation error="skip">
		<search position="before">
		<![CDATA[
		var rating = $(element).find('.rating').html();
		]]></search>
		<add>
		<![CDATA[
		var d = $(element).find('.discount_cat').html();
		if (d != null) {
			html += '<div class="discount_cat">' + d  + '</div>';
		}
		]]>
		</add>
	</operation>
	</file>
	
	********** 3 **********
	
	<file name="catalog/controller/module/caurusel_all.php">
		<operation error="skip">
		<search position="before"><![CDATA[	$this->data['products'][] = array(	]]></search>
		<add><![CDATA[
		
		$this->document->addStyle('catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/tooltips.css');
		
		@$discounts_g = @$this->model_catalog_product->getProductDiscountPrice_Group($result['product_id']);
		$discounts_d = $this->model_catalog_product->getProductDiscountPrice_Default($result['product_id']);
		
		if ($this->customer->isLogged()) {	
		$discount = $this->currency->format($this->tax->calculate($discounts_d, $result['tax_class_id'], $this->config->get('config_tax')));
		$d = 'Обычная цена:  <br />' . $discount;
		} else {
		if ($discounts_g > 0) {
		$discount = $this->currency->format($this->tax->calculate($discounts_g, $result['tax_class_id'], $this->config->get('config_tax')));
		} else {
		if ((float)$result['special']) {
		$discount = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')));
		} else {
		//$discount = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
		$discount = null;
		}
		}
		if ($discount == null) {
		$d = null;
		} else {
		$d = '<a class="tooltip_category" title="Стоимость ' . $result['name'] . ' для клиентов оплачивающих товар по предоплате.">По предоплате ' . $discount . '</a>';
		}
		}
		]]></add>
		</operation>
	</file>	
	
	<file name="catalog/view/theme/*/template/module/caurusel_all.tpl">
	<operation error="skip">
		<search position="before">
		<![CDATA[
		<?php if ($product['rating']) { ?>
		]]></search>
		<add>
		<![CDATA[
		<div class="discount_cat"><?php echo $product['discount']; ?></div>
		]]>
		</add>
	</operation>
	
	<operation error="skip">
		<search position="before">
		<![CDATA[
		var rating = $(element).find('.rating').html();
		]]></search>
		<add>
		<![CDATA[
		var d = $(element).find('.discount_cat').html();
		if (d != null) {
			html += '<div class="discount_cat">' + d  + '</div>';
		}
		]]>
		</add>
	</operation>
	</file>
	
	------------------------------------------------------------------------------
	
	
</modification>
Изменено пользователем Dart990
Ссылка на комментарий
Поделиться на других сайтах


  • 3 недели спустя...

Создайте аккаунт или войдите в него для комментирования

Вы должны быть пользователем, чтобы оставить комментарий

Создать аккаунт

Зарегистрируйтесь для получения аккаунта. Это просто!

Зарегистрировать аккаунт

Войти

Уже зарегистрированы? Войдите здесь.

Войти сейчас
 Поделиться

  • Сейчас на странице   0 пользователей

    • Нет пользователей, просматривающих эту страницу.
×
×
  • Создать...

Важная информация

На нашем сайте используются файлы cookie и происходит обработка некоторых персональных данных пользователей, чтобы улучшить пользовательский интерфейс. Чтобы узнать для чего и какие персональные данные мы обрабатываем перейдите по ссылке. Если Вы нажмете «Я даю согласие», это означает, что Вы понимаете и принимаете все условия, указанные в этом Уведомлении о Конфиденциальности.