Замена ценника в товаре

Автор RomanMdS, 25 мая 2017, 10:55:16

« назад - далее »

RomanMdS

Уважаемые ветераны, требуется ваш совет и помощь в решении довольна необычной задаче.

Как посоветуете воплотить такую вот задачу:
Есть цена в карточке товара, как бы все ок. Но все ОК если стоит цена, а на сайте есть товар где цену выставить не возможно (ее следует каждый раз уточнать). Если не выставлять цену, то в карточке и во всех блоках вывода на главную страницу красуется - Цена: 0,00 руб. Согласитесь это не комильфо.
Появилась такая вот идея в место 0,00 руб. поставить - Стоимость по запросу.
Вопрос!
Как посоветуете данную идею воплотить? Может были у кого такие наработки, или вы встречали что то подобное?

Мое представление. Думаю следует написать скрипт в подмену и создать правило, если значение равно 0, заменить на - Стоимость по запросу.

DarinSr

Ищите на форуме тему, как заменить 0,00 в цене на текст. Никакого скрипта ненужно, изменения делают в шаблонах product.tpl и product-list.tpl функциями smarty.

RomanMdS

Цитата: DarinSr от 25 мая 2017, 11:23:09
Ищите на форуме тему, как заменить 0,00 в цене на текст. Никакого скрипта ненужно, изменения делают в шаблонах product.tpl и product-list.tpl функциями smarty.
Вот так порадовали! Спасибо за наводку сейчас поищу.

RomanMdS

Цитата: DarinSr от 25 мая 2017, 11:23:09
Ищите на форуме тему, как заменить 0,00 в цене на текст. Никакого скрипта ненужно, изменения делают в шаблонах product.tpl и product-list.tpl функциями smarty.
Уважаемый, а вы бы не могли меня с ориентировать как найти эту статью? А то что то я не могу найти.

RomanMdS


Миколас

Что не понятно?
{if $product.price!=0}{convertPrice price=$product.price}{else} Стоимость по запросу{/if}

RomanMdS

Цитата: Миколас от 26 мая 2017, 15:18:15
Что не понятно?
{if $product.price!=0}{convertPrice price=$product.price}{else} Стоимость по запросу{/if}
Да не могу понять как его вставить в свой код, что не делаю, страница с товаром или сыпется или не грузится.
Вот в эту часть кода пытаюсь впихнуть:

                <!-- prices -->
                <div class="all-price-info">
                  <p class="our_price_display" itemprop="offers" itemscope itemtype="https://schema.org/Offer">
                    {strip}
                      {if $product->quantity > 0}<link itemprop="availability" href="https://schema.org/InStock"/>{/if}
                      {if $priceDisplay >= 0 && $priceDisplay <= 2}
                        <span id="our_price_display" itemprop="price" content="{$productPrice}">{convertPrice price=$productPrice|floatval}</span>
                        <meta itemprop="priceCurrency" content="{$currency->iso_code}" />
                        {hook h="displayProductPriceBlock" product=$product type="price"}
                      {/if}
                    {/strip}
                  </p>
                  <p id="old_price"{if (!$product->specificPrice || !$product->specificPrice.reduction)} class="hidden"{/if}>
                    {strip}
                      {if $priceDisplay >= 0 && $priceDisplay <= 2}
                        {hook h="displayProductPriceBlock" product=$product type="old_price"}
                        <span id="old_price_display"><span class="price">{if $productPriceWithoutReduction > $productPrice}{convertPrice price=$productPriceWithoutReduction|floatval}{/if}</span>{if $productPriceWithoutReduction > $productPrice && $tax_enabled && $display_tax_label == 1} {if $priceDisplay == 1}{l s='tax excl.'}{else}{l s='tax incl.'}{/if}{/if}</span>
                      {/if}
                    {/strip}
                  </p>
                  <p id="reduction_percent" {if $productPriceWithoutReduction <= 0 || !$product->specificPrice || $product->specificPrice.reduction_type != 'percentage'} style="display:none;"{/if}>{strip}
                    <span id="reduction_percent_display">
                      {if $product->specificPrice && $product->specificPrice.reduction_type == 'percentage'}-{$product->specificPrice.reduction*100}%{/if}
                    </span>
                  {/strip}</p>
                  <p id="reduction_amount" {if $productPriceWithoutReduction <= 0 || !$product->specificPrice || $product->specificPrice.reduction_type != 'amount' || $product->specificPrice.reduction|floatval ==0} style="display:none"{/if}>{strip}
                    <span id="reduction_amount_display">
                    {if $product->specificPrice && $product->specificPrice.reduction_type == 'amount' && $product->specificPrice.reduction|floatval !=0}
                      -{convertPrice price=$productPriceWithoutReduction|floatval-$productPrice|floatval}
                    {/if}
                    </span>
                  {/strip}
                  </p>
                </div>
                {if $priceDisplay == 2}
                  <br />
                  <span id="pretaxe_price">
                    <span id="pretaxe_price_display">{convertPrice price=$product->getPrice(false, $smarty.const.NULL)}</span>
                    {l s='tax excl.'}
                  </span>
                {/if}
                 <!-- end prices -->

RomanMdS

Я изменил название переменных, вот что вышло:
{if $productPrice=0}{convertPrice price=$productPrice}{else} TEST{/if}
И на выходе у меня перед нулевой ценой появилось слово - TEST.

Adik

Еще цену может переопределять javascript. Есть такие темы в prestashop. Нужно проверить в установленной теме  файлы js, поискать там функции изменения цены.

RomanMdS

Цитата: Adik от 29 мая 2017, 14:50:54
Еще цену может переопределять javascript. Есть такие темы в prestashop. Нужно проверить в установленной теме  файлы js, поискать там функции изменения цены.
Спасибо сейчас займусь.

RomanMdS

#10
Комрады, прошу о помощи, этот вопрос уже становится ребром. Все мои потуги не увенчались успехом. :(

Подскажите, что и как:
Кусок кода отвечающий за вывод цены в product.tpl

<!-- prices -->
                <div class="all-price-info">
                  <p class="our_price_display" itemprop="offers" itemscope itemtype="https://schema.org/Offer">
                    {strip}
                      {if $product->quantity > 0}<link itemprop="availability" href="https://schema.org/InStock"/>{/if}
                      {if $priceDisplay >= 0 && $priceDisplay <= 2}
                        <span id="our_price_display" itemprop="price" content="{$productPrice}">{convertPrice price=$productPrice|floatval}</span>
                        <meta itemprop="priceCurrency" content="{$currency->iso_code}" />
                        {hook h="displayProductPriceBlock" product=$product type="price"}
                      {/if}
                    {/strip}
                  </p>
                  <p id="old_price"{if (!$product->specificPrice || !$product->specificPrice.reduction)} class="hidden"{/if}>
                    {strip}
                      {if $priceDisplay >= 0 && $priceDisplay <= 2}
                        {hook h="displayProductPriceBlock" product=$product type="old_price"}
                        <span id="old_price_display"><span class="price">{if $productPriceWithoutReduction > $productPrice}{convertPrice price=$productPriceWithoutReduction|floatval}{/if}</span>{if $productPriceWithoutReduction > $productPrice && $tax_enabled && $display_tax_label == 1} {if $priceDisplay == 1}{l s='tax excl.'}{else}{l s='tax incl.'}{/if}{/if}</span>
                      {/if}
                    {/strip}
                  </p>
                  <p id="reduction_percent" {if $productPriceWithoutReduction <= 0 || !$product->specificPrice || $product->specificPrice.reduction_type != 'percentage'} style="display:none;"{/if}>{strip}
                    <span id="reduction_percent_display">
                      {if $product->specificPrice && $product->specificPrice.reduction_type == 'percentage'}-{$product->specificPrice.reduction*100}%{/if}
                    </span>
                  {/strip}</p>
                  <p id="reduction_amount" {if $productPriceWithoutReduction <= 0 || !$product->specificPrice || $product->specificPrice.reduction_type != 'amount' || $product->specificPrice.reduction|floatval ==0} style="display:none"{/if}>{strip}
                    <span id="reduction_amount_display">
                    {if $product->specificPrice && $product->specificPrice.reduction_type == 'amount' && $product->specificPrice.reduction|floatval !=0}
                      -{convertPrice price=$productPriceWithoutReduction|floatval-$productPrice|floatval}
                    {/if}
                    </span>
                  {/strip}
                  </p>
                </div>
                {if $priceDisplay == 2}
                  <br />
                  <span id="pretaxe_price">
                    <span id="pretaxe_price_display">{convertPrice price=$product->getPrice(false, $smarty.const.NULL)}</span>
                    {l s='tax excl.'}
                  </span>
                {/if}
                 <!-- end prices -->


Кусок кода формирующий цену и ее показ в product.js

//update display of the availability of the product AND the prices of the product
function updateDisplay() {
  var productPriceDisplay = productPrice;
  var productPriceWithoutReductionDisplay = productPriceWithoutReduction;
  if (!selectedCombination['unavailable'] && quantityAvailable > 0 && productAvailableForOrder == 1) {
    //show the choice of quantities
    $('#quantity_wanted_p:hidden').show('slow');
    //show the "add to cart" button ONLY if it was hidden
    $('#add_to_cart:hidden').fadeIn(600);
    //hide the hook out of stock
    $('#oosHook').hide();
    $('#availability_date').fadeOut();
    //availability value management
    if (stock_management && availableNowValue != '') {
      $('#availability_value').removeClass('warning_inline').text(availableNowValue).show();
      $('#availability_statut:hidden').show('slow');
    } else {
      $('#availability_statut:visible').hide('slow');
    }
    //'last quantities' message management
    if (!allowBuyWhenOutOfStock) {
      if (quantityAvailable <= maxQuantityToAllowDisplayOfLastQuantityMessage) {
        $('#last_quantities').show('slow');
      } else {
        $('#last_quantities').hide('slow');
      }
    }
    if (quantitiesDisplayAllowed) {
      $('#pQuantityAvailable:hidden').show('slow');
      $('#quantityAvailable').text(quantityAvailable);
      // we have 1 or less product in stock and need to show "item" instead of "items"
      if (quantityAvailable < 2) {
        $('#quantityAvailableTxt').show();
        $('#quantityAvailableTxtMultiple').hide();
      } else {
        $('#quantityAvailableTxt').hide();
        $('#quantityAvailableTxtMultiple').show();
      }
    }
  } else {
    //show the hook out of stock
    if (productAvailableForOrder == 1) {
      $('#oosHook').show();
      if ($('#oosHook').length > 0 && function_exists('oosHookJsCode')) {
        oosHookJsCode();
      }
    }
    //hide 'last quantities' message if it was previously visible
    $('#last_quantities:visible').hide('slow');
    //hide the quantity of pieces if it was previously visible
    $('#pQuantityAvailable:visible').hide('slow');
    //hide the choice of quantities
    if (!allowBuyWhenOutOfStock) {
      $('#quantity_wanted_p:visible').hide('slow');
    }
    //display that the product is unavailable with theses attributes
    if (!selectedCombination['unavailable']) {
      $('#availability_value').text(doesntExistNoMore + (globalQuantity > 0 ? ' ' + doesntExistNoMoreBut : ''));
      if (!allowBuyWhenOutOfStock) {
        $('#availability_value').removeClass('label-success').addClass('label-warning');
      }
    } else {
      $('#availability_value').text(doesntExist).removeClass('label-success').addClass('label-warning');
      $('#oosHook').hide();
    }
    if ((stock_management == 1 && !allowBuyWhenOutOfStock) || (!stock_management && selectedCombination['unavailable'])) {
      $('#availability_statut:hidden').show();
    }
    if (typeof(selectedCombination['available_date']) !== 'undefined' && typeof(selectedCombination['available_date']['date_formatted']) !== 'undefined' && selectedCombination['available_date']['date'].length != 0) {
      var available_date = selectedCombination['available_date']['date'];
      var tab_date = available_date.split('-');
      var time_available = new Date(tab_date[0], tab_date[1], tab_date[2]);
      time_available.setMonth(time_available.getMonth() - 1);
      var now = new Date();
      if (now.getTime() < time_available.getTime() && $('#availability_date_value').text() != selectedCombination['available_date']['date_formatted']) {
        $('#availability_date').fadeOut('normal', function() {
          $('#availability_date_value').text(selectedCombination['available_date']['date_formatted']);
          $(this).fadeIn();
        });
      } else if (now.getTime() < time_available.getTime()) {
        $('#availability_date').fadeIn();
      }
    } else {
      $('#availability_date').fadeOut();
    }


Конечно допускаю, что я выложил не те куски кода :(
Так что прикрепляю исходные, целые файлы.

П.С. Так же возможен способ с вознаграждением, ОЧЕНЬ нужно решить этот вопрос.

DarinSr

Цитата: RomanMdS от 31 мая 2017, 11:21:31
П.С. Так же возможен способ с вознаграждением, ОЧЕНЬ нужно решить этот вопрос.
Предложения о работе
Поиск работы , предложения о работе для специалистов по движкам PrestaShop и Magento. Удаленная работа и заказы для дизайнеров, программистов, верстальщиков, оптимизаторов. Предложения только по PrestaShop и Magento.

RomanMdS

Цитата: DarinSr от 31 мая 2017, 11:48:16
Цитата: RomanMdS от 31 мая 2017, 11:21:31
П.С. Так же возможен способ с вознаграждением, ОЧЕНЬ нужно решить этот вопрос.
Предложения о работе
Поиск работы , предложения о работе для специалистов по движкам PrestaShop и Magento. Удаленная работа и заказы для дизайнеров, программистов, верстальщиков, оптимизаторов. Предложения только по PrestaShop и Magento.
Да это как стимул, я хочу сам понять где туплю. Но спасибо за подсказку.

Миколас

Если есть желание разобраться, то меняй по одному значению и проверяй. Так разберешься. Еще можно удалить показ цены по всему шаблону и подставлять по одному.