PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, October 26, 2022

[FIXED] How to get locale object in PrestaShop 1.7 template?

 October 26, 2022     locale, prestashop-1.7, templates     No comments   

Issue

I'm using Tools::displayPrice() function in my template files to display formated price with currency, but documentation of this function in new version (1.7.6.0) says:

* @deprecated Since 1.7.6.0. Please use Locale::formatPrice() instead
* @see PrestaShop\PrestaShop\Core\Localization\Locale

So how do I use Locale object in my template?

-- P.S. PrestaShop official documentation at: https://devdocs.prestashop.com/1.7/ is a mess, so if anyone could share a link to some complete and reliable resource I (and many more) would be extremely grateful


Solution

For Google results:

Context::getContext()->currentLocale->formatPrice(123.45, 'EUR');

or e.g. in a module

$this->context->currentLocale->formatPrice($price, $currencyCode);

from https://devdocs.prestashop.com/1.7/modules/core_updates/1.7.6/



Answered By - Serge P
Answer Checked By - Senaida (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing