Jump to content

Recommended Posts

I just uploaded 130 virtual goods, namely books in pdf format to be distributed with prestashop.

I have found that they are placed in the Downloads folder into FTP.

Can someone explain why I find this folder with 9998 pdf files?

 

Many thanks in advance

Link to comment
Share on other sites

  • 1 year later...

Hello in my shop will offer some free virtual goods ... I wonder if there's as if the value of the product is equal to 0 appears free text

 

You can do that very easily by editing /root/themes/your_theme/product.tpl file. For example in the default prestashop the lines you're interested in are 263-270.

All you have to do is add an if statement to check whether the price equals to 0 and if it does display some text. 

Here's the original code:

{if $priceDisplay >= 0 && $priceDisplay <= 2}
    <span id="our_price_display" class="price" itemprop="price" content="{$productPrice}">{convertPrice price=$productPrice|floatval}</span>
    {if $tax_enabled  && ((isset($display_tax_label) && $display_tax_label == 1) || !isset($display_tax_label))}
        {if $priceDisplay == 1} {l s='tax excl.'}{else} {l s='tax incl.'}{/if}
    {/if}
    <meta itemprop="priceCurrency" content="{$currency->iso_code}" />
    {hook h="displayProductPriceBlock" product=$product type="price"}
{/if}

And here is the code wrapped in an if statement:

{if $priceDisplay >= 0 && $priceDisplay <= 2}
    {if $productPrice == 0}
        {l s="Free!"}
    {else}
        <span id="our_price_display" class="price" itemprop="price" content="{$productPrice}">{convertPrice price=$productPrice|floatval}</span>
        {if $tax_enabled  && ((isset($display_tax_label) && $display_tax_label == 1) || !isset($display_tax_label))}
            {if $priceDisplay == 1} {l s='tax excl.'}{else} {l s='tax incl.'}{/if}
        {/if}
        <meta itemprop="priceCurrency" content="{$currency->iso_code}" />
        {hook h="displayProductPriceBlock" product=$product type="price"}
    {/if}
{/if}
Edited by Catalin Scaesteanu (see edit history)
  • Like 1
Link to comment
Share on other sites

 

You can do that very easily by editing /root/themes/your_theme/product.tpl file. For example in the default prestashop the lines you're interested in are 263-270.

All you have to do is add an if statement to check whether the price equals to 0 and if it does display some text. 

Here's the original code:

{if $priceDisplay >= 0 && $priceDisplay <= 2}
    <span id="our_price_display" class="price" itemprop="price" content="{$productPrice}">{convertPrice price=$productPrice|floatval}</span>
    {if $tax_enabled  && ((isset($display_tax_label) && $display_tax_label == 1) || !isset($display_tax_label))}
        {if $priceDisplay == 1} {l s='tax excl.'}{else} {l s='tax incl.'}{/if}
    {/if}
    <meta itemprop="priceCurrency" content="{$currency->iso_code}" />
    {hook h="displayProductPriceBlock" product=$product type="price"}
{/if}

And here is the code wrapped in an if statement:

{if $priceDisplay >= 0 && $priceDisplay <= 2}
    {if $productPrice == 0}
        {l s="Free!"}
    {else}
        <span id="our_price_display" class="price" itemprop="price" content="{$productPrice}">{convertPrice price=$productPrice|floatval}</span>
        {if $tax_enabled  && ((isset($display_tax_label) && $display_tax_label == 1) || !isset($display_tax_label))}
            {if $priceDisplay == 1} {l s='tax excl.'}{else} {l s='tax incl.'}{/if}
        {/if}
        <meta itemprop="priceCurrency" content="{$currency->iso_code}" />
        {hook h="displayProductPriceBlock" product=$product type="price"}
    {/if}
{/if}

Hi  Catalin

 

First thanks for answering me

 

 

Will hold the change in Home Or only on the product page?

 

 

 

Link to comment
Share on other sites

That code is just for the product page.

I will post the entire blocks for (hopefully) easier copy / pasting because there are multiple places which need to be changed.

 

For home page and category page edit product-list.tpl at line 66 - 99, search and edit this code for mouse hover state:

{if (!$PS_CATALOG_MODE && ((isset($product.show_price) && $product.show_price) || (isset($product.available_for_order) && $product.available_for_order)))}
                    <div class="content_price" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
                        {if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}
                            <span itemprop="price" class="price product-price">
                                {hook h="displayProductPriceBlock" product=$product type="before_price"}
                        {if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}
                    </span>
                    <meta itemprop="priceCurrency" content="{$currency->iso_code}" />
                    {if isset($product.specific_prices) && $product.specific_prices && isset($product.specific_prices.reduction) && $product.specific_prices.reduction > 0}
                        {hook h="displayProductPriceBlock" product=$product type="old_price"}
                        <span class="old-price product-price">
                            {displayWtPrice p=$product.price_without_reduction}
                        </span>
                        {if $product.specific_prices.reduction_type == 'percentage'}
                            <span class="price-percent-reduction">-{$product.specific_prices.reduction * 100}%</span>
                        {/if}
                    {/if}
                    {if $PS_STOCK_MANAGEMENT && isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}
                        <span class="unvisible">
                            {if ($product.allow_oosp || $product.quantity > 0)}
                                <link itemprop="availability" href="http://schema.org/InStock" />{if $product.quantity <= 0}{if $product.allow_oosp}{if isset($product.available_later) && $product.available_later}{$product.available_later}{else}{l s='In Stock'}{/if}{else}{l s='Out of stock'}{/if}{else}{if isset($product.available_now) && $product.available_now}{$product.available_now}{else}{l s='In Stock'}{/if}{/if}
                            {elseif (isset($product.quantity_all_versions) && $product.quantity_all_versions > 0)}
                                <link itemprop="availability" href="http://schema.org/LimitedAvailability" />{l s='Product available with different options'}

                            {else}
                                <link itemprop="availability" href="http://schema.org/OutOfStock" />{l s='Out of stock'}
                            {/if}
                        </span>
                    {/if}
                    {hook h="displayProductPriceBlock" product=$product type="price"}
                    {hook h="displayProductPriceBlock" product=$product type="unit_price"}
                {/if}
            </div>
        {/if}

And change it to:

{if (!$PS_CATALOG_MODE && ((isset($product.show_price) && $product.show_price) || (isset($product.available_for_order) && $product.available_for_order)))}
            <div class="content_price" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
                {if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}
                    <span itemprop="price" class="price product-price">
                        {hook h="displayProductPriceBlock" product=$product type="before_price"}
                        {if !$priceDisplay}
                            {if $product.price == '0'}
                                {l s="Free"}
                            {else}
                                {convertPrice price=$product.price}
                            {/if}
                        {else}
                            {convertPrice price=$product.price_tax_exc}
                        {/if}
                    </span>
                    <meta itemprop="priceCurrency" content="{$currency->iso_code}" />
                    {if isset($product.specific_prices) && $product.specific_prices && isset($product.specific_prices.reduction) && $product.specific_prices.reduction > 0}
                        {if $product.price != '0'}
                            {hook h="displayProductPriceBlock" product=$product type="old_price"}
                            <span class="old-price product-price">
                                {displayWtPrice p=$product.price_without_reduction}
                            </span>
                            {if $product.specific_prices.reduction_type == 'percentage'}
                                <span class="price-percent-reduction">-{$product.specific_prices.reduction * 100}%</span>
                            {/if}
                        {/if}
                    {/if}
                    {if $PS_STOCK_MANAGEMENT && isset($product.available_for_order) && $product.available_for_order && !isset($restricted_country_mode)}
                        <span class="unvisible">
                            {if ($product.allow_oosp || $product.quantity > 0)}
                                <link itemprop="availability" href="http://schema.org/InStock" />{if $product.quantity <= 0}{if $product.allow_oosp}{if isset($product.available_later) && $product.available_later}{$product.available_later}{else}{l s='In Stock'}{/if}{else}{l s='Out of stock'}{/if}{else}{if isset($product.available_now) && $product.available_now}{$product.available_now}{else}{l s='In Stock'}{/if}{/if}
                            {elseif (isset($product.quantity_all_versions) && $product.quantity_all_versions > 0)}
                                <link itemprop="availability" href="http://schema.org/LimitedAvailability" />{l s='Product available with different options'}

                            {else}
                                <link itemprop="availability" href="http://schema.org/OutOfStock" />{l s='Out of stock'}
                            {/if}
                        </span>
                    {/if}
                    {hook h="displayProductPriceBlock" product=$product type="price"}
                    {hook h="displayProductPriceBlock" product=$product type="unit_price"}
                {/if}
            </div>
        {/if}

Then at line 125 - 147 is the code displaying the product:

{if (!$PS_CATALOG_MODE AND ((isset($product.show_price) && $product.show_price) || (isset($product.available_for_order) && $product.available_for_order)))}
    <div class="content_price">
        {if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}
            {hook h="displayProductPriceBlock" product=$product type='before_price'}
            <span class="price product-price">
        {if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}
    </span>
    {if isset($product.specific_prices) && $product.specific_prices && isset($product.specific_prices.reduction) && $product.specific_prices.reduction > 0}
        {hook h="displayProductPriceBlock" product=$product type="old_price"}
        <span class="old-price product-price">
            {displayWtPrice p=$product.price_without_reduction}
        </span>
        {hook h="displayProductPriceBlock" id_product=$product.id_product type="old_price"}
        {if $product.specific_prices.reduction_type == 'percentage'}
            <span class="price-percent-reduction">-{$product.specific_prices.reduction * 100}%</span>
        {/if}
    {/if}
    {hook h="displayProductPriceBlock" product=$product type="price"}
    {hook h="displayProductPriceBlock" product=$product type="unit_price"}
    {hook h="displayProductPriceBlock" product=$product type='after_price'}
{/if}
</div>
{/if}

Change this to:

{if (!$PS_CATALOG_MODE AND ((isset($product.show_price) && $product.show_price) || (isset($product.available_for_order) && $product.available_for_order)))}
    <div class="content_price">
        {if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}
            {hook h="displayProductPriceBlock" product=$product type='before_price'}
            <span class="price product-price">
                {if !$priceDisplay}
                    {if $product.price == '0'}
                        {l s="Free"}
                    {else}
                        {convertPrice price=$product.price}
                    {/if}
                {else}
                    {convertPrice price=$product.price_tax_exc}
                {/if}
            </span>
            {if isset($product.specific_prices) && $product.specific_prices && isset($product.specific_prices.reduction) && $product.specific_prices.reduction > 0}
                {if $product.price != '0'}
                    {hook h="displayProductPriceBlock" product=$product type="old_price"}
                    <span class="old-price product-price">
                        {displayWtPrice p=$product.price_without_reduction}
                    </span>
                    {hook h="displayProductPriceBlock" id_product=$product.id_product type="old_price"}
                    {if $product.specific_prices.reduction_type == 'percentage'}
                        <span class="price-percent-reduction">-{$product.specific_prices.reduction * 100}%</span>
                    {/if}
                {/if}
            {/if}
            {hook h="displayProductPriceBlock" product=$product type="price"}
            {hook h="displayProductPriceBlock" product=$product type="unit_price"}
            {hook h="displayProductPriceBlock" product=$product type='after_price'}
        {/if}
    </div>
{/if}

I will write a tutorial on how to change prices '0.00' into 'free' next week. Besides product page, category and homepage you also should change the order (checkout) page, order-history, the price in the cart, invoices (I'm not sure if it's legal to change the invoices yet but I will get informed) etc.

It will be a lengthy blog post and I'll share it here so that other people can benefit of this.

Link to comment
Share on other sites

Great friend again thank you for your help ..... with people like you that knowledge is diffused
Look'm just using a different template .. then code of the product-list.tpl file is a little different is as follows:

{*
* 2007-2014 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2014 PrestaShop SA
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*}
{include file="$tpl_dir./layout/setting.tpl"}
{if isset($products) && $products}
	{*define numbers of product per line in other page for desktop*}
        {if isset($class)}
            {*only display grid mode when include from other module*}
            {assign var="LISTING_GRIG_MODE" value="grid" scope="global"}
            {assign var='nbItemsPerLine' value=$LISTING_PRODUCT_COLUMN_MODULE}
            {if $LISTING_PRODUCT_COLUMN_MODULE=="5"}
                {assign var="colValue" value="col-xs-{12/$LISTING_PRODUCT_MOBILE} col-sm-{12/$LISTING_PRODUCT_TABLET} col-md-2-4 col-sp-12" scope="global"}
            {else}
                {assign var="colValue" value="col-sp-12 col-xs-{12/$LISTING_PRODUCT_MOBILE} col-sm-{12/$LISTING_PRODUCT_TABLET} col-md-{12/$LISTING_PRODUCT_COLUMN_MODULE}" scope="global"}
            {/if}
        {else}
            {assign var='nbItemsPerLine' value=$LISTING_PRODUCT_COLUMN}
	{/if}
        {assign var='nbItemsPerLineTablet' value=$LISTING_PRODUCT_TABLET}
        {assign var='nbItemsPerLineMobile' value=$LISTING_PRODUCT_MOBILE}
	{*define numbers of product per line in other page for tablet*}
	{assign var='nbLi' value=$products|@count}
	{math equation="nbLi/nbItemsPerLine" nbLi=$nbLi nbItemsPerLine=$nbItemsPerLine assign=nbLines}
	{math equation="nbLi/nbItemsPerLineTablet" nbLi=$nbLi nbItemsPerLineTablet=$nbItemsPerLineTablet assign=nbLinesTablet}
	<!-- Products list -->
	<div {if isset($id) && $id} id="{$id}"{/if} class="product_list no-margin {$LISTING_GRIG_MODE} row {if isset($class) && $class} {$class}{/if}">
	{foreach from=$products item=product name=products}
		{math equation="(total%perLine)" total=$smarty.foreach.products.total perLine=$nbItemsPerLine assign=totModulo}
		{math equation="(total%perLineT)" total=$smarty.foreach.products.total perLineT=$nbItemsPerLineTablet assign=totModuloTablet}
		{math equation="(total%perLineT)" total=$smarty.foreach.products.total perLineT=$nbItemsPerLineMobile assign=totModuloMobile}
		{if $totModulo == 0}{assign var='totModulo' value=$nbItemsPerLine}{/if}
		{if $totModuloTablet == 0}{assign var='totModuloTablet' value=$nbItemsPerLineTablet}{/if}
		{if $totModuloMobile == 0}{assign var='totModuloMobile' value=$nbItemsPerLineMobile}{/if}	
		<div class="ajax_block_product col-sp-12 no-padding {$colValue}{if $smarty.foreach.products.iteration%$nbItemsPerLine == 0} last-in-line
		{elseif $smarty.foreach.products.iteration%$nbItemsPerLine == 1} first-in-line{/if}
		{if $smarty.foreach.products.iteration > ($smarty.foreach.products.total - $totModulo)} last-line{/if}
		{if $smarty.foreach.products.iteration%$nbItemsPerLineTablet == 0} last-item-of-tablet-line
		{elseif $smarty.foreach.products.iteration%$nbItemsPerLineTablet == 1} first-item-of-tablet-line{/if}
		{if $smarty.foreach.products.iteration%$nbItemsPerLineMobile == 0} last-item-of-mobile-line
		{elseif $smarty.foreach.products.iteration%$nbItemsPerLineMobile == 1} first-item-of-mobile-line{/if}
		{if $smarty.foreach.products.iteration > ($smarty.foreach.products.total - $totModuloMobile)} last-mobile-line{/if}">
			{include file="$tpl_dir./sub/product-item/product-item.tpl" callFromModule=isset($class)}
		</div>

	{/foreach}
	</div>
{addJsDefL name=min_item}{l s='Please select at least one product' js=1}{/addJsDefL}
{addJsDefL name=max_item}{l s='You cannot add more than %d product(s) to the product comparison' sprintf=$comparator_max_item js=1}{/addJsDefL}
{addJsDef comparator_max_item=$comparator_max_item}
{addJsDef comparedProductsIds=$compared_products}
{/if}

however I found this reference code in produto.tpl file, a few lines above where vc reported for the initial modification:

{if $product->show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE}
							<!-- prices -->
							<div class="price">
								<p id="old_price"{if (!$product->specificPrice || !$product->specificPrice.reduction) && $group_reduction == 0} class="hidden"{/if}>
									{if $priceDisplay >= 0 && $priceDisplay <= 2}
										{hook h="displayProductPriceBlock" product=$product type="old_price"}
										<span id="old_price_display">{if $productPriceWithoutReduction > $productPrice}{convertPrice price=$productPriceWithoutReduction}{/if}</span>
										<!-- {if $tax_enabled && $display_tax_label == 1}{if $priceDisplay == 1}{l s='tax excl.'}{else}{l s='tax incl.'}{/if}{/if} -->
									{/if}
								</p>
								<p id="reduction_percent" {if !$product->specificPrice || $product->specificPrice.reduction_type != 'percentage'} style="display:none;"{/if}>
									<span id="reduction_percent_display">
										{if $product->specificPrice && $product->specificPrice.reduction_type == 'percentage'}-{$product->specificPrice.reduction*100}%{/if}
									</span>
								</p>
								<p class="our_price_display" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
									{if $product->quantity > 0}<link itemprop="availability" href="http://schema.org/InStock"/>{/if}

I am right in assuming that this is just where I have to change?

Link to comment
Share on other sites

Yes, this seems to be location where you need to apply the changes.
Make a backup of the files you want to change so that if you break things you can easily overwrite and no harm is done.

Also you can dump the output of a smarty variable to see what it contains like this: {$productPriceWithoutReduction|d}

This way you can pin-point the exact location where the prices show up.

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...