Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Expose supported_locales in API v1 and v2

Damian Legawieca0e62e10a774
diff --git a/api/app/helpers/spree/api/api_helpers.rb b/api/app/helpers/spree/api/api_helpers.rb
index f5c72221a7..c3d384ca62 100644
--- a/api/app/helpers/spree/api/api_helpers.rb
+++ b/api/app/helpers/spree/api/api_helpers.rb
@@ -163,7 +163,7 @@ module Spree
:id, :name, :url, :meta_description, :meta_keywords, :seo_title,
:mail_from_address, :customer_support_email, :default_currency,
:code, :default, :facebook, :twitter, :instagram,
- :supported_currencies
+ :supported_currencies, :default_locale, :supported_locales
]
@@tag_attributes = [:id, :name]
diff --git a/api/app/serializers/spree/v2/storefront/store_serializer.rb b/api/app/serializers/spree/v2/storefront/store_serializer.rb
index e50192a7d3..9fdcf3dce3 100644
--- a/api/app/serializers/spree/v2/storefront/store_serializer.rb
+++ b/api/app/serializers/spree/v2/storefront/store_serializer.rb
@@ -6,7 +6,7 @@ module Spree
attributes :name, :url, :meta_description, :meta_keywords, :seo_title, :default_currency, :default, :supported_currencies, :facebook,
:twitter, :instagram, :default_locale, :customer_support_email, :default_country_id, :description,
- :address, :contact_phone
+ :address, :contact_phone, :supported_locales
has_one :default_country, serializer: :country, record_type: :country, id_method_name: :default_country_id
end
diff --git a/api/spec/controllers/spree/api/v1/stores_controller_spec.rb b/api/spec/controllers/spree/api/v1/stores_controller_spec.rb
index 9266089127..ff30d9f538 100644
--- a/api/spec/controllers/spree/api/v1/stores_controller_spec.rb
+++ b/api/spec/controllers/spree/api/v1/stores_controller_spec.rb
@@ -37,6 +37,8 @@ module Spree
'customer_support_email' => '[email protected]',
'default_currency' => 'USD',
'supported_currencies' => 'USD,EUR,GBP',
+ 'default_locale' => 'en',
+ 'supported_locales' => 'en',
'code' => store.code,
'default' => true,
'facebook' => 'spreecommerce',
@@ -54,6 +56,8 @@ module Spree
'customer_support_email' => '[email protected]',
'default_currency' => 'USD',
'supported_currencies' => 'USD,EUR,GBP',
+ 'default_locale' => 'en',
+ 'supported_locales' => 'en',
'code' => non_default_store.code,
'default' => false,
'facebook' => 'spreecommerce',
@@ -76,7 +80,9 @@ module Spree
'mail_from_address' => '[email protected]',
'customer_support_email' => '[email protected]',
'default_currency' => 'USD',
+ 'default_locale' => 'en',
'supported_currencies' => 'USD,EUR,GBP',
+ 'supported_locales' => 'en',
'code' => store.code,
'default' => true,
'facebook' => 'spreecommerce',
diff --git a/api/spec/requests/spree/api/v2/storefront/stores_spec.rb b/api/spec/requests/spree/api/v2/storefront/stores_spec.rb
index 0aaa26a0df..8c49988d00 100644
--- a/api/spec/requests/spree/api/v2/storefront/stores_spec.rb
+++ b/api/spec/requests/spree/api/v2/storefront/stores_spec.rb
@@ -20,6 +20,7 @@ describe 'Storefront API v2 Stores spec', type: :request do
expect(json_response['data']).to have_attribute(:twitter).with_value(store.twitter)
expect(json_response['data']).to have_attribute(:instagram).with_value(store.instagram)
expect(json_response['data']).to have_attribute(:default_locale).with_value(store.default_locale)
+ expect(json_response['data']).to have_attribute(:supported_locales).with_value(store.supported_locales)
expect(json_response['data']).to have_attribute(:description).with_value(store.description)
expect(json_response['data']).to have_attribute(:address).with_value(store.address)
expect(json_response['data']).to have_attribute(:contact_phone).with_value(store.contact_phone)
diff --git a/core/lib/spree/permitted_attributes.rb b/core/lib/spree/permitted_attributes.rb
index c2f3864243..8f355e3401 100644
--- a/core/lib/spree/permitted_attributes.rb
+++ b/core/lib/spree/permitted_attributes.rb
@@ -99,7 +99,7 @@ module Spree
@@store_attributes = [:name, :url, :seo_title, :code, :meta_keywords, :logo,
:meta_description, :default_currency, :mail_from_address,
:customer_support_email, :facebook, :twitter, :instagram,
- :description, :address, :contact_phone,
+ :description, :address, :contact_phone, :supported_locales,
:default_locale, :default_country_id, :supported_currencies,
:new_order_notifications_email, :mailer_logo, :checkout_zone_id, :seo_robots]