1

I have to show "On request" if price is 0, I have used Commerce Extra Price Formatters and it allow us to do so,but I need currency converter block also and if I go through Commerce Extra Price Formatters then it will not convert currency, So if there is any other alternative to show text without using any module then pls suggest..

1
  • Drupal 7 right?
    – No Sssweat
    Mar 3, 2016 at 12:53

2 Answers 2

0

There's actually quite a nice module for this also:

https://www.drupal.org/project/commerce_free_price_formatter

The beauty of it is, that is works as a price formatter and you can use it on specific displays, product types or views as you desire :)

And this module only changes the name of 0 price to what you want, and the formatter settings have a fallback formatter choice, where you can chose your current default formatter for all the times when the price isn't 0

7
  • But the currecy converter not working I am using commerce multicurrency module
    – akash99
    Mar 3, 2016 at 13:36
  • Can you specify what you mean by currency converter not working? as I understand, 0 should be 0 in any currency and where you need the currency converter to work is when you actually have a price value. I use the module for the same purpose you're describing and my prices are good in all currencies for when there is a price. Mar 3, 2016 at 13:51
  • commerce multicurrency provide user to insert price field in different currencies also it provide currency converter block that converts the currency, Suppose 100 USD is the price of the product displaying on the site and site visitor want to see the price in some other currency then they can do it by using currency converter block
    – akash99
    Mar 3, 2016 at 13:59
  • 0 will be 0 but the product having price more then 0 then
    – akash99
    Mar 3, 2016 at 14:02
  • Have you installed the module? If you install the module, enable it, then you go to your store->configuration->product variation types->[your product type]->manage display from there you choose the free formatter as your price formatter, and in the settings (little turnwheel) you choose the message (on request) and choose your current formatter as the fallback formatter. Then all prices that are not 0, will act as if they did before. Mar 3, 2016 at 14:39
0

Add this to your (template) .tpl.php file

<?php

if ($node = menu_get_object()) {
  // Get the nid
  $nid = $node->nid;

$node = node_load($nid);
$wrapper = entity_metadata_wrapper('node', $node);
$field_value = $wrapper->field_price->value();

if ($field_value == 0) {
  print 'On Request'; 
  } else { 
  print $field_value;
  }
}

?>

Not sure if the machine name of price is field_price.

If the machine name is just price then use $field_value = $wrapper->price->value(); instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.