2013-02-05 3 views
0

blockspecials 모듈을 사용하고 있으며 사진에서 볼 수있는 통화가 있습니다. 내가 아는 한 여기서 통화 기호를 제거하면 상점의 모든 곳에서 통화 기호를 제거합니다. 어쩌면 블록 스페셜에서 제거하는 방법이 있을까요? 이 방법은 좋지 않습니다. 사전에 도움을Prestashop 1.5. blockspecials 모듈의 통화 기호

enter image description here

감사합니다.

답변

0

이 모듈은 /classes/Tools.php에있는 displayWtPrice라는 맞춤형 사전 시작 smarty 함수를 호출합니다. 이 함수는 숫자를 통화로 올바르게 포맷합니다. 이 형식을 사용하지 않으려면 blockspecials.tpl에서 smarty 함수를 제거하십시오.

기본적으로 다음과 같이 표시됩니다.

{if !$PS_CATALOG_MODE} 
    <span class="price-discount">{if !$priceDisplay}{displayWtPrice p=$special.price_without_reduction}{else}{displayWtPrice p=$priceWithoutReduction_tax_excl}{/if}</span> 
    <span class="price">{if !$priceDisplay}{displayWtPrice p=$special.price}{else}{displayWtPrice p=$special.price_tax_exc}{/if}</span> 
{/if} 

멋진 태그를 제거하십시오.

{if !$PS_CATALOG_MODE} 
    <span class="price-discount">{if !$priceDisplay}{$special.price_without_reduction}{else}{$priceWithoutReduction_tax_excl}{/if}</span> 
    <span class="price">{if !$priceDisplay}{$special.price}{else}{$special.price_tax_exc}{/if}</span> 
{/if} 

이렇게하면 서식이 지정되지 않은 번호가 남습니다.

기호가없는 형식 지정이 필요하고이 기호가이 기능과 관련이있는 경우에는 prestashop의 핵심을 수정해야합니다.

당신은 대체하여 /classes/Tools.php에서 displayPrice 기능을 복제해야

/Tools.php을 확장 -

<?php 

/** 
* Tools 
*/ 
class Tools extends ToolsCore 
{ 

    /** 
    * Return price with currency sign for a given product 
    * 
    * @param float $price Product price 
    * @param object $currency Current currency (object, id_currency, NULL => context currency) 
    * @return string Price correctly formated (sign, decimal separator...) 
    */ 
    public static function displayPrice($price, $currency = null, $no_utf8 = false, Context $context = null, $showSymbol = true) 
    { 
     if (!is_numeric($price)) 
      return $price; 
     if (!$context) 
      $context = Context::getContext(); 
     if ($currency === null) 
      $currency = $context->currency; 
     // if you modified this function, don't forget to modify the Javascript function formatCurrency (in tools.js) 
     elseif (is_int($currency)) 
      $currency = Currency::getCurrencyInstance((int)$currency); 

     if (is_array($currency)) 
     { 
      $c_char = $currency['sign']; 
      $c_format = $currency['format']; 
      $c_decimals = (int)$currency['decimals'] * _PS_PRICE_DISPLAY_PRECISION_; 
      $c_blank = $currency['blank']; 
     } 
     elseif (is_object($currency)) 
     { 
      $c_char = $currency->sign; 
      $c_format = $currency->format; 
      $c_decimals = (int)$currency->decimals * _PS_PRICE_DISPLAY_PRECISION_; 
      $c_blank = $currency->blank; 
     } 
     else 
      return false; 

     $blank = ($c_blank ? ' ' : ''); 
     $ret = 0; 
     if (($is_negative = ($price < 0))) 
      $price *= -1; 
     $price = Tools::ps_round($price, $c_decimals); 
     switch ($c_format) 
     { 
      /* X 0,000.00 */ 
      case 1: 
       $ret = (($showSymbol) ? $c_char : '').$blank.number_format($price, $c_decimals, '.', ','); 
       break; 
      /* 0 000,00 X*/ 
      case 2: 
       $ret = number_format($price, $c_decimals, ',', ' ').$blank.(($showSymbol) ? $c_char : ''); 
       break; 
      /* X 0.000,00 */ 
      case 3: 
       $ret = (($showSymbol) ? $c_char : '').$blank.number_format($price, $c_decimals, ',', '.'); 
       break; 
      /* 0,000.00 X */ 
      case 4: 
       $ret = number_format($price, $c_decimals, '.', ',').$blank.(($showSymbol) ? $c_char : ''); 
       break; 
      /* 0 000.00 X Added for the switzerland currency */ 
      case 5: 
       $ret = number_format($price, $c_decimals, '.', ' ').$blank.(($showSymbol) ? $c_char : ''); 
       break; 
     } 
     if ($is_negative) 
      $ret = '-'.$ret; 
     if ($no_utf8) 
      return str_replace('€', chr(128), $ret); 
     return $ret; 
    } 



} 

은 이제 재정의해야 /overrides/classes/Tools.php 새로운 클래스를 생성 우리는 Tools를 사용하는 것과 같은 방법으로하지만 이번에는 Product 클래스의 displayWtPrice 함수를 사용합니다.

다음과 같이이 기능을 무시합니다.

public static function displayWtPrice($params, &$smarty) 
    { 
     return Tools::displayPrice($params['p'], Context::getContext()->currency, false, null, (($params['showsymbol'] == false) ? false : true)); 
    } 

제공된 경우 추가 기능 매개 변수를 지정했습니다.

이제와 displayWtPrice에서 추가 PARAM으로 blockspecials.tpl을 수정해야 showsymbol=false

{if !$PS_CATALOG_MODE} 
    <span class="price-discount">{if !$priceDisplay}{displayWtPrice p=$special.price_without_reduction showsymbol=false}{else}{displayWtPrice p=$priceWithoutReduction_tax_excl showsymbol=false}{/if}</span> 
    <span class="price">{if !$priceDisplay}{displayWtPrice p=$special.price showsymbol=false}{else}{displayWtPrice p=$special.price_tax_exc showsymbol=false}{/if}</span> 
{/if}