Module: Spree::Purchase::Locale
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/spree/purchase/locale.rb
Instance Method Summary collapse
- #ensure_locale ⇒ Object
-
#locale_must_be_supported_by_store ⇒ Object
Validates that the order's locale is within the store's supported locales.
Instance Method Details
#ensure_locale ⇒ Object
13 14 15 16 17 |
# File 'app/models/concerns/spree/purchase/locale.rb', line 13 def ensure_locale return if locale.present? self.locale = Spree::Current.locale.presence || market&.default_locale end |
#locale_must_be_supported_by_store ⇒ Object
Validates that the order's locale is within the store's supported locales. Mirrors currency_must_be_supported_by_store.
21 22 23 24 25 26 27 |
# File 'app/models/concerns/spree/purchase/locale.rb', line 21 def locale_must_be_supported_by_store return if locale.blank? || store.blank? unless store.supported_locales_list.include?(locale) errors.add(:locale, :locale_not_supported_by_store, message: I18n.t('spree.locale_not_supported_by_store')) end end |