Jump to content

[SOLVED] Show prices for some products only and display "please call for quote" for other items


Recommended Posts

Hi everyone, I need you're help to figure out something in the Prestashop configuration.


In my shop, I don't want to display the price of all the items. I have 2 categories of products:
- in category 1, each product have a set retail price
- in category 2, the items do not have a set price (EXTREMELY customizable products and prone to competitors underpricing).


Therefore, I would like to show the general product picture and description for all product categories, but for category 2, I would like the customer to contact us for the exact price.


Therefore, my question is: How can I show prices for some products only and display "please call for quote" for other items?

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

Unfortunately, this is not an easy thing to do. Do not try this unless you are comfortable messing around with code and have backed up these files before modifying them.

The way I would do it is to add the following at line 177 of classes/Tools.php (after the "$price =" line):

if ($price == 0)
   return 'Call for price';



and modify js/tools.js in your theme's directory and add the following to the start of the formatCurrency function:

if (price == 0)
   return 'Call for price';



This will change all $0.00 to 'Call for price', but on the product page, it will display as 'Call for price tax incl.', so you'll have to modify product.tpl and the tpls of any other modules if necessary and write something like {if $price != 0}{l s='tax incl.'}{/if}. You'll have to modify modules/blockcart/blockcart.php too, since the totals will display as 'Call for price' when nothing is in the cart. Change lines 43-47 from:

'shipping_cost' => Tools::displayPrice($params['cart']->getOrderTotal(intval(Configuration::get('PS_PRICE_DISPLAY')) == 1 ? false : true, 5), $currency),
'show_wrapping' => floatval($params['cart']->getOrderTotal(true, 6)) > 0 ? true : false,
'wrapping_cost' => Tools::displayPrice($params['cart']->getOrderTotal(intval(Configuration::get('PS_PRICE_DISPLAY')) == 1 ? false : true, 6), $currency),
'product_total' => Tools::displayPrice($params['cart']->getOrderTotal(intval(Configuration::get('PS_PRICE_DISPLAY')) == 1 ? false : true, 4), $currency),
'total' => Tools::displayPrice($params['cart']->getOrderTotal(intval(Configuration::get('PS_PRICE_DISPLAY')) == 1 ? false : true), $currency),



to:

'shipping_cost' => Tools::displayPrice($params['cart']->getOrderTotal(intval(Configuration::get('PS_PRICE_DISPLAY')) == 1 ? false : true, 5), $currency) == 'Call for price' ? Tools::displayPrice(0.001, $currency) : Tools::displayPrice($params['cart']->getOrderTotal(intval(Configuration::get('PS_PRICE_DISPLAY')) == 1 ? false : true, 5), $currency),
'show_wrapping' => floatval($params['cart']->getOrderTotal(true, 6)) > 0 ? true : false,
'wrapping_cost' => Tools::displayPrice($params['cart']->getOrderTotal(intval(Configuration::get('PS_PRICE_DISPLAY')) == 1 ? false : true, 6), $currency) == 'Call for price' ? Tools::displayPrice(0.001, $currency) : Tools::displayPrice($params['cart']->getOrderTotal(intval(Configuration::get('PS_PRICE_DISPLAY')) == 1 ? false : true, 6), $currency),
'product_total' => Tools::displayPrice($params['cart']->getOrderTotal(intval(Configuration::get('PS_PRICE_DISPLAY')) == 1 ? false : true, 4), $currency) == 'Call for price' ? Tools::displayPrice(0.001, $currency) : Tools::displayPrice($params['cart']->getOrderTotal(intval(Configuration::get('PS_PRICE_DISPLAY')) == 1 ? false : true, 4), $currency),
'total' => Tools::displayPrice($params['cart']->getOrderTotal(intval(Configuration::get('PS_PRICE_DISPLAY')) == 1 ? false : true), $currency) == 'Call for price' ? Tools::displayPrice(0.001, $currency) : Tools::displayPrice($params['cart']->getOrderTotal(intval(Configuration::get('PS_PRICE_DISPLAY')) == 1 ? false : true), $currency),



Hopefully, this will give you a starting point for displaying 'Call for price'.

Link to comment
Share on other sites

I'll be more specific. Change lines 195-221 of product.tpl from:


   {if !$priceDisplay || $priceDisplay == 2}
{convertPrice price=$product->getPrice(true, $smarty.const.NULL, 2)}
           {l s='tax incl.'}
   {/if}
   {if $priceDisplay == 1}
{convertPrice price=$product->getPrice(false, $smarty.const.NULL, 2)}
           {l s='tax excl.'}
   {/if}

   {if $priceDisplay == 2}


{convertPrice price=$product->getPrice(false, $smarty.const.NULL, 2)} {l s='tax excl.'}
   {/if}



{if ($product->reduction_price != 0 || $product->reduction_percent != 0) && ($product->reduction_from == $product->reduction_to OR ($smarty.now|date_format:'%Y-%m-%d' <= $product->reduction_to && $smarty.now|date_format:'%Y-%m-%d' >= $product->reduction_from))}


   {if !$priceDisplay || $priceDisplay == 2}
{convertPrice price=$product->getPriceWithoutReduct()}
           {l s='tax incl.'}
    {/if}
    {if $priceDisplay == 1}
{convertPrice price=$product->getPriceWithoutReduct(true)}
            {l s='tax excl.'}
     {/if}



to:


   {if !$priceDisplay || $priceDisplay == 2}
{convertPrice price=$product->getPrice(true, $smarty.const.NULL, 2)}
           {if $price > 0}{l s='tax incl.'}{/if}
   {/if}
   {if $priceDisplay == 1}
{convertPrice price=$product->getPrice(false, $smarty.const.NULL, 2)}
           {if $price > 0}{l s='tax excl.'}{/if}
   {/if}

   {if $priceDisplay == 2}


{convertPrice price=$product->getPrice(false, $smarty.const.NULL, 2)}{if $price > 0} {l s='tax excl.'}{/if}
   {/if}



{if ($product->reduction_price != 0 || $product->reduction_percent != 0) && ($product->reduction_from == $product->reduction_to OR ($smarty.now|date_format:'%Y-%m-%d' <= $product->reduction_to && $smarty.now|date_format:'%Y-%m-%d' >= $product->reduction_from))}


   {if !$priceDisplay || $priceDisplay == 2}
{convertPrice price=$product->getPriceWithoutReduct()}
           {if $price > 0}{l s='tax incl.'}{/if}
   {/if}
   {if $priceDisplay == 1}
{convertPrice price=$product->getPriceWithoutReduct(true)}
           {if $price > 0}{l s='tax excl.'}{/if}
  {/if}

Link to comment
Share on other sites

  • 1 month later...

I can't figure out what I was thinking when I wrote that code. I can't find a $price variable. Try the following instead:


   {if !$priceDisplay || $priceDisplay == 2}
{convertPrice price=$product->getPrice(true, $smarty.const.NULL, 2)}
           {if $product->getPrice(true, $smarty.const.NULL, 2) > 0}{l s='tax incl.'}{/if}
   {/if}
   {if $priceDisplay == 1}
{convertPrice price=$product->getPrice(false, $smarty.const.NULL, 2)}
           {if $product->getPrice(false, $smarty.const.NULL, 2) > 0}{l s='tax excl.'}{/if}
   {/if}

   {if $priceDisplay == 2}


{convertPrice price=$product->getPrice(false, $smarty.const.NULL, 2)}{if $product->getPrice(false, $smarty.const.NULL, 2) > 0} {l s='tax excl.'}{/if}
   {/if}



{if ($product->reduction_price != 0 || $product->reduction_percent != 0) && ($product->reduction_from == $product->reduction_to OR ($smarty.now|date_format:'%Y-%m-%d' <= $product->reduction_to && $smarty.now|date_format:'%Y-%m-%d' >= $product->reduction_from))}


   {if !$priceDisplay || $priceDisplay == 2}
{convertPrice price=$product->getPriceWithoutReduct()}
           {if $product->getPriceWithoutReduct() > 0}{l s='tax incl.'}{/if}
   {/if}
   {if $priceDisplay == 1}
{convertPrice price=$product->getPriceWithoutReduct(true)}
           {if $product->getPriceWithoutReduct(true) > 0}{l s='tax excl.'}{/if}
  {/if}

Link to comment
Share on other sites

More perfect it could not be!:-)
thanks a million.

Quick edit.
I have disabled out of stock ordering in the BO so the cart button does not display.
Final code hack is with displaying the "number of item in stock" Would like to remove this line for all products that are at 0 stock also.

So to do this:
In product.tpl around line 266
Replace:
<!-- number of item in stock -->

quantity == 0)} style="display:none;"{/if}>
{$product->quantity|intval}
quantity > 1} style="display:none;"{/if} id="quantityAvailableTxt">{l s='item in stock'}
quantity < 2} style="display:none;"{/if} id="quantityAvailableTxtMultiple">{l s='items in stock'}



With:
<!-- number of item in stock -->


quantity < 2} style="display:none;"{/if} id="quantityAvailable">{$product->quantity|intval}
quantity != 1} style="display:none;"{/if} id="quantityAvailableTxt">{l s='item in stock'}
quantity < 2} style="display:none;"{/if} id="quantityAvailableTxtMultiple">{l s='items in stock'}



What this will do is remove any stock quantity level message from items that are at 0 stock from displaying.
Link to comment
Share on other sites

I am trying to do something very similar, but instead of displaying a call us, I want to display: "Sold Out" if the product quantity is 0 but can't get it to work...

See this thread where I am asking for something similar: http://www.prestashop.com/forums/viewthread/43138/

I thought adding the following code would be a solution, but it doesn't work for some reason:

{if $product->quantity == 0} 

{l s='SOLD OUT!'}
{/if}



On the same page, there is the code to hide the Add to Cart button if the item is unavailable:

quantity == 0} style="display:none;"{/if} id="add_to_cart" class="buttons_bottom_block">
<input type="submit" name="Submit" value="{l s='Add to cart'}" /></span>



How come that works fine, yet I can't get the opposite to work??? If i use the first code, it will still display items that have quantity available if entered in the "1. Info" tab in the back office...

What is the variable that displays the overall quantity of the products if it is not: $product->quantity???

Link to comment
Share on other sites

  • 4 months later...

Rocky, can you help me with modifying the blockcart.php for the 1.3.1 version ? The above doesn't fit anymore now the declaration are :
'shipping_cost' => Tools::displayPrice($params['cart']->getOrderTotal($usetax, 5), $currency),
'show_wrapping' => $wrappingCost > 0 ? true : false,
'wrapping_cost' => Tools::displayPrice($wrappingCost, $currency),
'product_total' => Tools::displayPrice($params['cart']->getOrderTotal($usetax, 4), $currency),
'total' => Tools::displayPrice($params['cart']->getOrderTotal($usetax), $currency),
instead and I'm stuck with the cart showing 'ask for price'.

Link to comment
Share on other sites

hi

it works great on 1.25 and thanks Rocky for help

one small issue on order.php i think. when the mails arrives Discounts, Gift-wrapping and Shipping display the text not 0.

any solution like in blockcart.php?

thanks in advance

Link to comment
Share on other sites

  • 2 months later...

So far managed to edit Tools.php and tools.js and now my store is showing 'Call for price'. However now lis the issue to fix blockcart module from saying that. You can see what i mean by navigating to www.thunderbayindustrial.ca . Got into block cart and am having difficulties with it since it is not nerely the same as the one rocky showed since that was 1.2 and now im using 1.3 and there has been some changes there, but i think ill be able to figure it out tommarow once i disect it a bit more(didn't have much time before work) , add me to msn(see pm) and maybe we can work this out together. Ill be up around 9 am eastern tackling this SOB hehe.

Link to comment
Share on other sites

  • 2 weeks later...

Hey for all that is wondering so far I have gotten this to work in prestashop 1.3.1 the steps are as follows:

classes/Tools.php After line 229 ($price = self::ps_round($price, $c_decimals);

add the following:

if ($price == 0) 
  return 'Call for price'; 



in modules/blockcart/blockcart.php change the corresponding array values to reflect

'shipping_cost' => Tools::displayPrice($params['cart']->getOrderTotal($usetax, 5), $currency) == 'Call for price' ? '$0' : Tools::displayPrice($params['cart']->getOrderTotal($usetax, 5), $currency),
           'show_wrapping' => $wrappingCost > 0 ? true : false,
           'wrapping_cost' => Tools::displayPrice($wrappingCost, $currency) == 'Call for price' ? '$0' : Tools::displayPrice($wrappingCost, $currency),
           'product_total' => Tools::displayPrice($params['cart']->getOrderTotal($usetax, 4), $currency) == 'Call for price' ? '$0' : Tools::displayPrice($params['cart']->getOrderTotal($usetax, 4), $currency),
           'total' => Tools::displayPrice($params['cart']->getOrderTotal($usetax), $currency) == 'Call for price' ? '$0' : Tools::displayPrice($params['cart']->getOrderTotal($usetax), $currency),



So far that is as far as i have gotten but i will post as i progress further. If you would like to see the outcome please navigate to www.thunderbayindustrial.ca , take note i do not charge for shipping therefore shipping is always 0 with my cart(i did not hard code it as zero in my code tho it still accounts for flexibility)

Link to comment
Share on other sites

camrinp have you tried my solution? I think the possibility to choose where show cart or not in a item basis from the BO is more reliable than based in price. Furthermore with that modification you don't show any prices or cart, only a link to the contact form. But that is only my opinion.

Regards

Link to comment
Share on other sites

  • 3 weeks later...
  • 4 months later...

sorry, please help me, I couldn't find where is classes/Tools.php. I'm a beginner at PS. and I have basic knowledge on C programming only.Luckily I managed to do some changes at js/tools.js in the theme directory.

Link to comment
Share on other sites

  • 1 month later...

Rocky, Thanks for the good tip,
===================================================
if ($price == 0) return 'Call for price';
and modify js/tools.js in your theme’s directory and add the following to the start of the formatCurrency function:
if (price == 0) return 'Call for price'
=================================================
These code are still working on 1.4.0~, but my case, S/H and Total also showing "call for price" on My cart.
Could you tell me how can I fix this?

Link to comment
Share on other sites

  • 3 months later...

Rocky,

 

I did this and it has worked PERFECTLY in 4 versions, however I just started getting tons of orders and decided to use the MailAlerts module. I noticed something very funny..

 

In the module where Discounts and Gift Wrapping should show $0, it now shows "Call for price". I am guessing this is because of this modification to make prices with $0 show "call for price" How do I exclude this from the mail alerts and emails that go to the customers confirming thier order so that the $0 show there?

See attached for example to help explain.

post-89639-0-59841200-1313781214_thumb.jpg

Link to comment
Share on other sites

Rocky,

 

Can you please help me with this request? You seem to be the only resident pro with knowledge of this tweak.

 

I also attached an image of the html version of the mailalerts module showing the fields it pulls from if that may help.

 

Please advise if I can just edit this and how to make the correction??

post-89639-0-75167600-1314044840_thumb.jpg

 

The fields that should be showing $0 like Discounts, Gift Wrapping, Shipping are coming up "Call for Price" which is some how because of this fix above I used to have customers call for price when I put 0$ for the price of an item. Per your code above. But I don't want that to appear on any emails to the customers. How can exclude the emails?

 

Thanks,

Tina

Link to comment
Share on other sites

  • 1 month later...

I do realize this is a quite old topic, but...

 

How would you implement the 'Call for price' feature in multiple languages?

 

I managed to get the shop to return a text string for certain products ('Call for quote'), but how can I show a different string (the translation) when selecting another language?

 

I tried with {l s='...'} in various combinations, but obviously in doesn't work, because the variable is not part of a .tpl file, so I could later edit its translation in the back-office.

 

I've also tried to do a layered if($lang_iso == 1/2/3...) return '...', but that didn't work either.

 

Any ideas? Thank you

Link to comment
Share on other sites

I would highly reccomend you upgrade the site to 1.4.4.1 and the products in that version have a check box to show price.. just uncheck it. Then it works like a catalog.. just add "Call for Price" and the phone number to short description.

Works great.

 

They way we did that before caused all kinds of issues in the mail alerts and in the checkout so I would not even try it.

 

If you have an earlier version just upgrade.. I just updated all my sites and glad I did.

Link to comment
Share on other sites

That's a good idea. I actually never noticed that option. It's available in 1.4.1.0 as well. It might be a better idea, because this way you wouldn't have a shopping cart that says 'Call for price' instead of an ammount in USD/ EUR.

Thank you.

Link to comment
Share on other sites

  • 3 years later...
  • 1 month later...

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