0

I would like to add a the currency symbol to a CMS block on a category page or in the category description.

It would be something like under €50 or under $50.

Is there a simple way to do this with a CMS directive? i.e.

{{store_currency}}

Perhaps it's possible with a widget?

Otherwise I was thinking of using a custom variable but this would only work on a store view level and not if the customer changes currency within the store view.

Another option I thought of was to add a CSS class to the tag depending on what currency is selected and use that to hide and display the right currency symbols.

But is there an more straight forward way of doing this? with a cms directive or widget?

1 Answer 1

1

You can do this by creating new widget. Check here : Creating Widget

Here you can place your code at Envato_WidgetLinks_Block_Links block's _toHtml() method, that returns current store's Currency symbol.

Otherwise, (a bit of Hack)

You can add some text to your static block, like [[CURRENCY_SYMBOL]] and replace it with currency symbol using PHP str_replace function, like:

$current_currency_symbol = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();

$cms_block_content = $this->getLayout()->createBlock('cms/block')->setBlockId('cms_block_identifier_here')->toHtml();

echo str_replace("[[CURRENCY_SYMBOL]]", $current_currency_symbol, $cms_block_content);
3
  • where would you put the PHP str_replace?
    – Holly
    Commented Jun 27, 2016 at 13:46
  • You can use this if you are showing/echoing static block in phtml ONLY. o/w go with widget Commented Jun 27, 2016 at 13:49
  • @Holy: does this helps ? Commented Jul 1, 2016 at 12:18

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.