I added a php function to magento price template this way

I added this code:

function Convert2farsi ($srting)
      $search= array("0","1","2","3","4","5","6","7","8","9");
      $replace= array("A","B","C","D","E","F","G","H","I","J");
      $int= str_replace($search,$replace,$srting);

to app/design/frontend/shopper/default/template/catalog/product/price.phtml

and changed this line price.phtml:

<?php $_convertedPrice = $_store->roundPrice($_store->convertPrice($_product->getPrice())); ?>

to this:

<?php $_convertedPrice = $_store->roundPrice($_store->convertPrice(Convert2farsi ($_product->getPrice()))); ?>


  1. Products with Custom Options wont take effect of this code and are showing in their past way.

  2. In each category just one product is shown and the others are missing.

  3. Product prices won't show on category hover mode and give this error on hover: cannot redeclare Convert2farsi () previously declared in .../price.phtml line 28 and 34

1 Answer 1

  1. price.html has a lot more lines where price is output. If it is too complicated for you, try the price.phtml template without all the Weee stuff
  2. I guess an error is stopping further output.
  3. The best way is to to create a helper with function Convert2farsi - creating a helper. But if you won't, you should check if function was declared to avoid redeclaration:

    if (!function_exists('Convert2farsi')) {
        function Convert2farsi ($srting) {

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.