cart icon indicating copy to clipboard operation
cart copied to clipboard

Currency selector renders value of `default`

Open rintisch opened this issue 2 years ago • 0 comments

Bug Report

Current Behavior The template for currency selector checks the amount of currencies and should only render if more than one currency is given. https://github.com/extcode/cart/blob/bf1a2765a3def05fc7f19d86944a90b313119407/Resources/Private/Templates/Cart/Currency/Edit.html#L4

But due to the configuration structure the selector is even rendered if only one currency is defined because default = 1 is interpreted as a value.

https://github.com/extcode/cart/blob/bf1a2765a3def05fc7f19d86944a90b313119407/Configuration/TypoScript/setup.typoscript#L81-L87

Expected behavior/output

  • The selector is only render if more than one currency is defined.
  • The selector shows only actual currencies.

Environment

  • TYPO3 version(s): 12.4 (also valid for main)
  • cart version: 9.x-dev
  • Is your TYPO3 installation set up with Composer (Composer Mode): yes
  • OS: running in ddev

Possible Solution 1 Move default = 1 one level up and rename it to defaultCurrency.

Advantage: This way it would have the same scheme as countries: https://github.com/extcode/cart/blob/bf1a2765a3def05fc7f19d86944a90b313119407/Configuration/TypoScript/setup.typoscript#L79 Disadvantage: It would pollute the TypoScript of the level above and it is not encapsulated within currencies.

Possible Solution 2 Use scheme of shippings and payments: https://github.com/extcode/cart/blob/bf1a2765a3def05fc7f19d86944a90b313119407/Configuration/TypoScript/setup.typoscript#L258-L261

Which would result in

currencies {
    preset = 1
    options {
        1 {
             code = EUR
              sign = €
              translation = 1.00
        }
    }
}

Advantage: It is encapsulated, furthermore shippings, payments and somehow share logic.

rintisch avatar Dec 17 '23 08:12 rintisch