1

I've just done a Craft 2 > Craft 3 upgrade, and it previously used different locales to change the default currency, depending on the locale.

In Craft 2, I would set COMMERCE_PAYMENT_CURRENCY in my index.php file (https://docs.craftcms.com/commerce/v2/payment-currencies.html#switching-currencies) so that it would set the currency for that specific site.

But in Commerce 2 this doesn't seem to be working at all.

My current setup is:

/web 
   index.php
   /europe
      index.php

And in the /europe/index.php I've got:

<?php
/**
 * Craft web bootstrap file
 */

// Set path constants
define('CRAFT_BASE_PATH', dirname(__DIR__, 2));
define('CRAFT_VENDOR_PATH', CRAFT_BASE_PATH.'/vendor');

define('CRAFT_SITE', 'en_eur');

define('COMMERCE_PAYMENT_CURRENCY', 'EUR');

// Load Composer's autoloader
require_once CRAFT_VENDOR_PATH.'/autoload.php';

// Load dotenv?
if (class_exists('Dotenv\Dotenv') && file_exists(CRAFT_BASE_PATH.'/.env')) {
    Dotenv\Dotenv::create(CRAFT_BASE_PATH)->load();
}

// Load and run Craft
define('CRAFT_ENVIRONMENT', getenv('ENVIRONMENT') ?: 'production');
$app = require CRAFT_VENDOR_PATH.'/craftcms/cms/bootstrap/web.php';
$app->run();

I know this file is being picked up when I go to http://website.local/europe, because if I delete the contents, or change the CRAFT_SITE it reacts correctly.

Just not working for Commerce 2.

1

It seems the const COMMERCE_PAYMENT_CURRENCY isn't checked and set inside Commerce 2 (It was in Commerce 1)

So I created a PR for this issue:

https://github.com/craftcms/commerce/pull/999

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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