Jump to content

Call for Pricing


Tiago

Recommended Posts

Hello guys , im new to prestashop and to php.

I was trying to change some files on the prestashop but i have some problem that im not discovering.

Im using the  PrestaShop version: 1.7.2.4 

And the theme i am using is the classinc one.

All i need is when a product have price at 0.00€ it should apear call for pricing!

I managed to do this but if the price is difrent then 0 it stills to show call for pricing.

 

The files i changed was - themes/classic/templates/catalog/_partial/product-prices.tpl

//top of the file
{if $product->price == 0}
<div class="product-price h5">
          <span itemprop="price" content="">Call for Pricing!</span>
</div>
{/if} 
{if $product->price != 0} 

the rest of the code from the file here

{/if}

and the second file was: themes/classic/templates/catalog/_partial/miniatures/product.tpl


        {block name='product_price_and_shipping'}
45       <!-- Changes here -->   {if $product->price == 0}
        <div class="product-price-and-shipping">
            <span itemprop="price" class="price"> Call for Pricing!</span>
        </div>
49     <!-- Changes here --> {/if}
50<!-- Changes here -->{if $product->price !=0}
          {if $product.show_price}
            <div class="product-price-and-shipping">
              {if $product.has_discount}
                {hook h='displayProductPriceBlock' product=$product type="old_price"}

                <span class="sr-only">{l s='Regular price' d='Shop.Theme.Catalog'}</span>
                <span class="regular-price">{$product.regular_price}</span>
                {if $product.discount_type === 'percentage'}
                  <span class="discount-percentage">{$product.discount_percentage}</span>
                {/if}
61   <!-- Changes here --> {/if}

              {hook h='displayProductPriceBlock' product=$product type="before_price"}

              <span class="sr-only">{l s='Price' d='Shop.Theme.Catalog'}</span>
              <span itemprop="price" class="price">{$product.price}</span>

              {hook h='displayProductPriceBlock' product=$product type='unit_price'}

              {hook h='displayProductPriceBlock' product=$product type='weight'}
            </div>
          {/if}
			{/if}
        {/block}

Can some one give me a clue what is wrong or where i should put the if statement?

Link to comment
Share on other sites

Pierre_d thanks for the reply.

I did the changes but it dosen´s change anything. If the product price is 0 it gives call for pricing and if i change the price it keeps giving the call for price.

I cheked the class and the $price var is a float value.

 

But the problem presists!

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

On 15/01/2018 at 12:31 PM, Pierre_d said:

Try {if $product.price == 0}. If it stills does not work, check the data type of price in the PHP class.

You have any other sugestion Pierre? Plz let me know cause im trying to figure whats wrong but cant find it.

Link to comment
Share on other sites

Hi Tiago, I've tried in my development environment and... it works!

{if $product.price == 0}
	the price is zero
{else}
	the price is not zero
{/if}

Two things come to my mind. 1) $product.price is zero because of your configuration or 2) have you forced template recompilation in the BO > Advanced Parameters > Performance ?

Link to comment
Share on other sites

23 minutes ago, Pierre_d said:

Hi Tiago, I've tried in my development environment and... it works!


{if $product.price == 0}
	the price is zero
{else}
	the price is not zero
{/if}

Two things come to my mind. 1) $product.price is zero because of your configuration or 2) have you forced template recompilation in the BO > Advanced Parameters > Performance ?

In wich lines you did the if statment Pierre?

Link to comment
Share on other sites

On 17/01/2018 at 3:49 PM, Pierre_d said:

I've tried with product-prices.tpl. Works for me. Display "Call for prices" when price is 0 else displays the price!

You need to force template recompilation. Have you done that ?

 

Yes and seams not to work for me! No idea what i have to do but thanks for the help

Link to comment
Share on other sites

  • 2 weeks later...

Yes, you can hide the price from the miniatures on the category page. You need to modify themes\classic\templates\catalog\_partials\miniatures\product.tpl. Locate {block name='product_price_and_shipping'} and enclose the price display between an if:

{if $product.price > 0}
...
{/if}

 

  • Thanks 1
Link to comment
Share on other sites

  • 3 weeks later...
  • 9 months later...

hello 

On 1/22/2018 at 7:01 AM, Tiago said:

Yes and seams not to work for me! No idea what i have to do but thanks for the help

hello dear 

you should put below code in product.tpl after line: 

<span class="sr-only">{l s='Price' d='Shop.Theme.Catalog'}</span>

          <!-- changes here -->
              {if $product.price_amount == 0}
                <span itemprop="price" class="price">Call for Price!</span>
              {else}
              <span itemprop="price" class="price">{$product.price}</span>
              {/if}
                <!-- finish here -->

 

and below code in product-prices.tpl after line :

    <meta itemprop="priceCurrency" content="{$currency.iso_code}">   

 {if $product.price_amount == 0}
                       <!-- changes here  <div class="current-price">    -->
              <span itemprop="price" content="{$product.price_amount}">Call for Price!</span>
                      {else}
                            <div class="current-price">
            <span itemprop="price" content="{$product.price_amount}">{$product.price}</span>
                         {/if}

 

Edited by se.ehsan (see edit history)
Link to comment
Share on other sites

  • 10 months later...
On 1/22/2018 at 12:01 PM, Tiago said:

Yes and seams not to work for me! No idea what i have to do but thanks for the help

Hi Tiago!

I want to know if you managed to do what you wanted.

Can you please tell me what tou did, or send me the files you edited?

 

Thanks

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