wagnerwagner / merx

Merx is a plugin to create online shops with Kirby.
https://merx.wagnerwagner.de
104 stars 10 forks source link

formatPrice fails when option('locale') is an array #31

Closed mrflix closed 3 years ago

mrflix commented 3 years ago

I usually set the locale as an array because the the German numeric comma breaks stuff (padding-bottom: 80,12565% - fun):

'locale' => [
    LC_COLLATE  => 'de_CH.utf-8',
    LC_MONETARY => 'de_CH.utf-8',
    LC_NUMERIC  => 'en_US.utf-8',
    LC_TIME     => 'de_CH.utf-8',
    LC_MESSAGES => 'de_CH.utf-8',
    LC_CTYPE    => 'de_CH.utf-8'
];

This however breaks https://github.com/wagnerwagner/merx/blob/43e9b8ddf195b1a6f540319dd49cda1de074a1b7/src/merx.php#L41 where a string is expected.

My workaround which you're free to include:

$str = option('locale');
if (is_array($str)){
    $str = $str[1];
}
$locale = substr($str, 0, 5);

Though I'm also thinking: doesn't Kirby already set the locale even if its in single language mode?

mrflix commented 3 years ago

Two more places where this breaks:

https://github.com/wagnerwagner/merx/blob/43e9b8ddf195b1a6f540319dd49cda1de074a1b7/src/merx.php#L175

and

https://github.com/wagnerwagner/merx/blob/43e9b8ddf195b1a6f540319dd49cda1de074a1b7/src/cart.php#L122

tobiasfabian commented 3 years ago

Fixed in 1.5.0-rc.1

mrflix commented 3 years ago

Sweet ❤️