Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatter->asCurrency() throws InvalidConfigException #1541

Closed
samhibberd opened this issue Jun 26, 2020 · 3 comments
Closed

Formatter->asCurrency() throws InvalidConfigException #1541

samhibberd opened this issue Jun 26, 2020 · 3 comments
Assignees
Labels
ℹ️ status: need more info When waiting for user to supply database or more information.

Comments

@samhibberd
Copy link

samhibberd commented Jun 26, 2020

Description
Updated to latest craft commerce and running into an InvalidConfigException twig template error when trying to load an order on the front end.

The default currency code for the formatter is not defined.

To Reproduce
How, and what happened?

  1. Load order on the front end, appears to be triggered by using the craft |currency filter
  2. Invalid Configuration – yii\base\InvalidConfigException thrown.

Additional info

  • Craft version: Craft CMS 3.5.0-beta.3 (599445e)
  • Commerce version: 3.1.10
  • PHP version: 7.3
yii\base\InvalidConfigException: The default currency code for the formatter is not defined. in /Users/samhibberd/Sites/beta.findarace.com/vendor/yiisoft/yii2/i18n/Formatter.php:2076
Stack trace:
#0 /Users/samhibberd/Sites/beta.findarace.com/vendor/yiisoft/yii2/i18n/Formatter.php(1275): yii\i18n\Formatter->asCurrencyStringFallback('26.4000', NULL)
#1 /Users/samhibberd/Sites/beta.findarace.com/vendor/craftcms/cms/src/i18n/Formatter.php(257): yii\i18n\Formatter->asCurrency('26.4000', NULL, Array, Array)
#2 /Users/samhibberd/Sites/beta.findarace.com/storage/runtime/compiled_templates/ad/ad0546761a37c47687f1ce0d171c875390a54c150d085e3a86e51d8e3822a9b3.php(181): craft\i18n\Formatter->asCurrency('26.4000')
#3 /Users/samhibberd/Sites/beta.findarace.com/vendor/twig/twig/src/Template.php(184): __TwigTemplate_9e4027f4e74d226aab052dd33e4d323d6558aa21db45ae511383a661889d30c5->block_body(Array, Array)
#4 /Users/samhibberd/Sites/beta.findarace.com/storage/runtime/compiled_templates/ca/caffca22dc70475d3aebdfc9f26899847bab3d3d8df9594e78c04d6396878e76.php(117): Twig\Template->displayBlock('body', Array, Array)
#5 /Users/samhibberd/Sites/beta.findarace.com/vendor/twig/twig/src/Template.php(407): __TwigTemplate_f2389f72a6899c83bcda22f7fae205ddd4d5ca122af5972bda717c1504dbf1d7->doDisplay(Array, Array)
#6 /Users/samhibberd/Sites/beta.findarace.com/vendor/twig/twig/src/Template.php(380): Twig\Template->displayWithErrorHandling(Array, Array)
#7 /Users/samhibberd/Sites/beta.findarace.com/storage/runtime/compiled_templates/ad/ad0546761a37c47687f1ce0d171c875390a54c150d085e3a86e51d8e3822a9b3.php(81): Twig\Template->display(Array, Array)
#8 /Users/samhibberd/Sites/beta.findarace.com/vendor/twig/twig/src/Template.php(407): __TwigTemplate_9e4027f4e74d226aab052dd33e4d323d6558aa21db45ae511383a661889d30c5->doDisplay(Array, Array)
#9 /Users/samhibberd/Sites/beta.findarace.com/vendor/twig/twig/src/Template.php(380): Twig\Template->displayWithErrorHandling(Array, Array)
#10 /Users/samhibberd/Sites/beta.findarace.com/storage/runtime/compiled_templates/b2/b28c157c676e233c00311cb6aa73b235d17a8202af72c1333a22b045f5a7e572.php(83): Twig\Template->display(Array, Array)
#11 /Users/samhibberd/Sites/beta.findarace.com/vendor/twig/twig/src/Template.php(407): __TwigTemplate_ed8f8b65b201e13180cb4301721c4d9ae534a09afa13b9c8b4099a828106be2d->doDisplay(Array, Array)
#12 /Users/samhibberd/Sites/beta.findarace.com/vendor/twig/twig/src/Template.php(380): Twig\Template->displayWithErrorHandling(Array, Array)
#13 /Users/samhibberd/Sites/beta.findarace.com/storage/runtime/compiled_templates/21/2197ee5584f56e866a2ec6aa2380f7e408779c3a067065bd0c7a3abc2db86d35.php(53): Twig\Template->display(Array)
#14 /Users/samhibberd/Sites/beta.findarace.com/vendor/twig/twig/src/Template.php(407): __TwigTemplate_22f68159bd620688ff30233c35de1d99fac302885d5513ff36ff3b8d3cd6d60a->doDisplay(Array, Array)
#15 /Users/samhibberd/Sites/beta.findarace.com/vendor/twig/twig/src/Template.php(380): Twig\Template->displayWithErrorHandling(Array, Array)
#16 /Users/samhibberd/Sites/beta.findarace.com/vendor/twig/twig/src/Template.php(392): Twig\Template->display(Array)
#17 /Users/samhibberd/Sites/beta.findarace.com/vendor/twig/twig/src/TemplateWrapper.php(45): Twig\Template->render(Array, Array)
#18 /Users/samhibberd/Sites/beta.findarace.com/vendor/twig/twig/src/Environment.php(318): Twig\TemplateWrapper->render(Array)
#19 /Users/samhibberd/Sites/beta.findarace.com/vendor/craftcms/cms/src/web/View.php(392): Twig\Environment->render('_views/events/e...', Array)
#20 /Users/samhibberd/Sites/beta.findarace.com/vendor/craftcms/cms/src/web/View.php(453): craft\web\View->renderTemplate('_views/events/e...', Array)
#21 /Users/samhibberd/Sites/beta.findarace.com/vendor/craftcms/cms/src/web/Controller.php(242): craft\web\View->renderPageTemplate('_views/events/e...', Array, 'site')
#22 /Users/samhibberd/Sites/beta.findarace.com/vendor/craftcms/cms/src/controllers/TemplatesController.php(98): craft\web\Controller->renderTemplate('_views/events/e...', Array)
#23 [internal function]: craft\controllers\TemplatesController->actionRender('_views/events/e...', Array)
#24 /Users/samhibberd/Sites/beta.findarace.com/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#25 /Users/samhibberd/Sites/beta.findarace.com/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#26 /Users/samhibberd/Sites/beta.findarace.com/vendor/craftcms/cms/src/web/Controller.php(179): yii\base\Controller->runAction('render', Array)
#27 /Users/samhibberd/Sites/beta.findarace.com/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('render', Array)
#28 /Users/samhibberd/Sites/beta.findarace.com/vendor/craftcms/cms/src/web/Application.php(289): yii\base\Module->runAction('templates/rende...', Array)
#29 /Users/samhibberd/Sites/beta.findarace.com/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('templates/rende...', Array)
#30 /Users/samhibberd/Sites/beta.findarace.com/vendor/craftcms/cms/src/web/Application.php(274): yii\web\Application->handleRequest(Object(craft\web\Request))
#31 /Users/samhibberd/Sites/beta.findarace.com/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#32 /Users/samhibberd/Sites/beta.findarace.com/web/index.php(21): yii\base\Application->run()
#33 /Users/samhibberd/.composer/vendor/weprovide/valet-plus/server.php(131): require('/Users/samhibbe...')
#34 {main}
@samhibberd
Copy link
Author

Was suggested that there might be a Yii bug causing some issues here, see:

craftcms/cms#6277 (comment)

I am going to try and recreate the issue with a fresh install and can provide details.

@lukeholder
Copy link
Member

Using the new *AsCurrency properties in 3.1.11 should resolve this. i.e {{ order.totalPaidAsCurrency }}

Also added some typecasting in 3.1.11, which could have also fixed this.

@samhibberd
Copy link
Author

samhibberd commented Jul 13, 2020

Have tested and it appears to be fixed across the board, thanks @lukeholder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ℹ️ status: need more info When waiting for user to supply database or more information.
Projects
None yet
Development

No branches or pull requests

2 participants