Jump to content
  • 0

Procent rabatu obok ceny


hatrick

Question

Proszę Was o pomoc w edycji pliku product-list.tpl (presta 1562)

Chciałbym aby po dodaniu obniżki procentowej pojawiał się w różowym kwadraciku % obniżki

 

W tej chwili po dodaniu obniżki wyświetla mi mniejszą czcionką, przekreśloną cenę oryginalną a pod nią większą czcionką cenę po rabacie.

 

Znalazłem info, że jest to opcja presty, którą można włączyć w FO, ale u mnie nie działa. 

 

Dotarłem również do czegoś takiego:

{if $product.price_without_reduction gt $product.price}

{if $product.specific_prices}{assign var='pro_specific_prices' value=$product.specific_prices}
{if $pro_specific_prices.reduction_type eq 'percentage' && ($pro_specific_prices.from eq $pro_specific_prices.to OR ($smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $pro_specific_prices.to && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' >= $pro_specific_prices.from))}
<span class="price-discount">{if !$priceDisplay}{displayWtPrice p=$product.price_without_reduction}{else}{displayWtPrice p=((($product.price_without_reduction) / (1 + ((($product.rate|intval) / 100)|floatval)))|floatval)}{/if}</span>

(-{$pro_specific_prices.reduction * 100|floatval}%)
{/if}
{/if}
{/if} 

Wstawiłem to według instrukcji przed <span class="price"... Ale jak to wstawię to wyświetla mi oryginalną cenę przekreśloną, obok tą samą cenę bez przekreślenia oraz procentowy rabat w nawiasie. A poniżej cenę po rabacie.

 

Tak to mniej-więcej wygląda

 

99zł  99zł  (20%)

79,20zł

 

Chciałbym aby tej środkowej ceny (powtórzonej) nie było, a procent aby był w różowym kwadracie

 

A tak wygląda kod mojego pliku, proszę o pomoc co i gdzie wstawić:

{if isset($products)}
	<!-- Products list -->
<ul id="product_list" class="grid">
	{foreach from=$products item=product name=products}
	<li class="ajax_block_product bordercolor{if $smarty.foreach.products.iteration is div by 3} product_list-3{/if} num-{$smarty.foreach.products.iteration}">
		<a href="{$product.link|escape:'htmlall':'UTF-8'}" class="product_img_link" title="{$product.name|escape:'htmlall':'UTF-8'}"  style="position:relative;"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home-list')}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" >
         {if $mod_xnaklejka[$product.id_product]}<img src="{$mod_xnaklejka[$product.id_product]}" width="{$mod_xnaklejka_width2}" height="{$mod_xnaklejka_height2}" class="pl_naklejka"   style="position:absolute; display:block; z-index:99; top:0px; right:0px;">{/if}
        </a>
		<div class="center_block">
			<div class="product_flags">
            
      
				{if isset($product.new) && $product.new == 1}<span class="new">{l s='New'}!</span>{/if}
                {if (!$PS_CATALOG_MODE AND ((isset($product.show_price) && $product.show_price) || (isset($product.available_for_order) && $product.available_for_order)))}             
                {if isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}<span class="availability bordercolor">{if ($product.allow_oosp || $product.quantity > 0)}{l s='Available'}{elseif (isset($product.quantity_all_versions) && $product.quantity_all_versions > 0)}{l s='Product available with different options'}{else}{l s='Out of stock'}{/if}</span>{/if}
				{if isset($product.online_only) && $product.online_only}<span class="online_only bordercolor">{l s='Online only!'}</span>{/if}
           {/if}
			</div>
            <div class="clear"></div>
            <h3><a class="product_link" href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.name|escape:'htmlall':'UTF-8'}">{$product.name|escape:'htmlall':'UTF-8'|truncate:150:'...'}</a></h3>

            
		</div>
																			 
		<div class="right_block bordercolor">
        	{if isset($product.on_sale) && $product.on_sale && isset($product.show_price) && $product.show_price && !$PS_CATALOG_MODE}<span class="on_sale">{l s='On sale!'}</span>
			{elseif isset($product.reduction) && $product.reduction && isset($product.show_price) && $product.show_price && !$PS_CATALOG_MODE}<span class="discount">{l s='Reduced price!'}</span>{/if}
			 {if $product.price_without_reduction != $product.price AND $product.reduction != 0  }
      <span style="font-size:10px;text-decoration: line-through;">{convertPrice price=$product.price_without_reduction}</span> 

      {else}
      
      <span style="font-size:10px;text-decoration: line-through;height: 20px;width: 1px;display: block;"> </span>
      {/if}
      {if (!$PS_CATALOG_MODE AND ((isset($product.show_price) && $product.show_price) || (isset($product.available_for_order) && $product.available_for_order)))}
            {if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}<span class="price">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span>{/if}  
			{/if}	
            
           {if isset($comparator_max_item) && $comparator_max_item}
				<p class="compare checkbox">		
                <input type="checkbox" class="comparator" id="comparator_item_{$product.id_product}" value="comparator_item_{$product.id_product}" {if isset($compareProducts) && in_array($product.id_product, 					$compareProducts)}checked="checked"{/if} /> 
				<label for="comparator_item_{$product.id_product}">{l s='Select to compare'}</label></p>
			{/if}
            <div class="clear noneclass"></div>
				{if ($product.id_product_attribute == 0 || (isset($add_prod_display) && ($add_prod_display == 1))) && $product.available_for_order && !isset($restricted_country_mode) && $product.minimal_quantity <= 1 && $product.customizable != 2 && !$PS_CATALOG_MODE}
					{if ($product.allow_oosp || $product.quantity > 0)}
						{if isset($static_token)}
							<a class="ajax_add_to_cart_button exclusive" rel="ajax_id_product_{$product.id_product|intval}" href="{$link->getPageLink('cart',false, NULL, "add&id_product={$product.id_product|intval}&token={$static_token}", true)}" title="{l s='Add to cart'}"><span></span>{l s='Add to cart'}</a>
						{else}
							<a class="ajax_add_to_cart_button exclusive" rel="ajax_id_product_{$product.id_product|intval}" href="{$link->getPageLink('cart',false, NULL, "add&id_product={$product.id_product|intval}", true)} title="{l s='Add to cart'}"><span></span>{l s='Add to cart'}</a>
						{/if}						
					{else}
						<span class="exclusive"><span></span>{l s='Add to cart'}</span>
					{/if}
				{/if}
			<a class="button" href="{$product.link|escape:'htmlall':'UTF-8'}" title="{l s='View'}">{l s='View'}</a>          
		</div>
	</li>
	{/foreach}
    <script>
    (function($) {
$(function() {

	function createCookie(name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	}
	function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
	function eraseCookie(name) {
		createCookie(name,"",-1);
	}
	$('ul.product_view').each(function(i) {
		var cookie = readCookie('tabCookie'+i);
		if (cookie) $(this).find('li').eq(cookie).addClass('current').siblings().removeClass('current')
			.parents('#center_column').find('#product_list').addClass('list').removeClass('grid').eq(cookie).addClass('grid').removeClass('list');
	})

	$('ul.product_view').delegate('li:not(.current)', 'click', function(i) {
		$(this).addClass('current').siblings().removeClass('current')
			.parents('#center_column').find('#product_list').removeClass('grid').addClass('list').eq($(this).index()).addClass('grid').removeClass('list')
			
				var cookie = readCookie('tabCookie'+i);
		if (cookie) $(this).find('#product_list').eq(cookie).removeClass('grid').addClass('list').siblings().removeClass('list')
		
		
		
		var ulIndex = $('ul.product_view').index($(this).parents('ul.product_view'));
		eraseCookie('tabCookie'+ulIndex);
		createCookie('tabCookie'+ulIndex, $(this).index(), 365);
	})
})
})(jQuery)
    </script>
</ul>
	<!-- /Products list -->
{/if}
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0
tak na szybko - moze wstaw to zamiast twojego:

 

 

{if $product.price_without_reduction gt $product.price}

 

{if $product.specific_prices}{assign var='pro_specific_prices' value=$product.specific_prices}

{if $pro_specific_prices.reduction_type eq 'percentage' && ($pro_specific_prices.from eq $pro_specific_prices.to OR ($smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $pro_specific_prices.to && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' >= $pro_specific_prices.from))}

<span style="background-color: pink;padding: 2px;">(-{$pro_specific_prices.reduction * 100|floatval}%)</span>

 

{/if}

{/if}

{/if} 

Link to comment
Share on other sites

  • 0

 

tak na szybko - moze wstaw to zamiast twojego:
 
 
{if $product.price_without_reduction gt $product.price}
 
{if $product.specific_prices}{assign var='pro_specific_prices' value=$product.specific_prices}
{if $pro_specific_prices.reduction_type eq 'percentage' && ($pro_specific_prices.from eq $pro_specific_prices.to OR ($smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $pro_specific_prices.to && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' >= $pro_specific_prices.from))}
<span style="background-color: pink;padding: 2px;">(-{$pro_specific_prices.reduction * 100|floatval}%)</span>
 
{/if}
{/if}
{/if} 

 

 

Dziękuję, jestem już bliżej tego co chciałem, jeszcze proszę o podpowiedz:

-jak usunąć nawiasy w których jest procent i chciałbym zmienić kolor czcionki na czarny (mam szarą czcionkę na sklepie) 

-potrzebuje również ten procent przesunąć bardziej w prawo

Edited by hatrick (see edit history)
Link to comment
Share on other sites

  • 0

Dobra. Udało mi się metodą prób i błędów. Wstawiam, gotowy gdyby ktoś szukał

{if $product.price_without_reduction gt $product.price}
 
{if $product.specific_prices}{assign var='pro_specific_prices' value=$product.specific_prices}
{if $pro_specific_prices.reduction_type eq 'percentage' && ($pro_specific_prices.from eq $pro_specific_prices.to OR ($smarty.now|date_format:'%Y-%m-%d %H:%M:%S' <= $pro_specific_prices.to && $smarty.now|date_format:'%Y-%m-%d %H:%M:%S' >= $pro_specific_prices.from))}
<span style="background-color: #FF3366;font: bold;color: white;margin-left: 130px;padding: 2px;">-{$pro_specific_prices.reduction * 100|floatval}%</span>
 
{/if}
{/if}
{/if} 
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...