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.

CR remarks

Nathaniel Nande12b269c32eff
diff --git a/api/app/controllers/spree/api/v2/storefront/countries_controller.rb b/api/app/controllers/spree/api/v2/storefront/countries_controller.rb
index 0f6c180417..883736f7a8 100644
--- a/api/app/controllers/spree/api/v2/storefront/countries_controller.rb
+++ b/api/app/controllers/spree/api/v2/storefront/countries_controller.rb
@@ -29,10 +29,10 @@ module Spree
end
def resource_serializer_params
- default_params = { include_states: true }
- default_params.merge!(current_store: current_store) if params[:include_checkout_zone_applicable_states]
-
- default_params
+ {
+ include_states: true,
+ current_store: current_store
+ }
end
def collection
diff --git a/api/app/serializers/spree/v2/storefront/country_serializer.rb b/api/app/serializers/spree/v2/storefront/country_serializer.rb
index 75b222e343..4666c37183 100644
--- a/api/app/serializers/spree/v2/storefront/country_serializer.rb
+++ b/api/app/serializers/spree/v2/storefront/country_serializer.rb
@@ -13,10 +13,10 @@ module Spree
has_many :states, if: proc { |_record, params| params && params[:include_states] }
- attribute :checkout_zone_applicable_states, if: proc { |_record, params| params && params[:current_store].present? } do |object, params|
- current_store = params[:current_store]
-
- current_store.states_available_for_checkout(object)
+ has_many :checkout_zone_applicable_states,
+ serializer: ::Spree::V2::Storefront::StateSerializer,
+ if: proc { |_record, params| params && params[:current_store].present? } do |object, params|
+ params[:current_store].states_available_for_checkout(object)
end
end
end
diff --git a/frontend/app/assets/javascripts/spree/frontend/checkout/address.js b/frontend/app/assets/javascripts/spree/frontend/checkout/address.js
index e58bc44714..77d7474af1 100644
--- a/frontend/app/assets/javascripts/spree/frontend/checkout/address.js
+++ b/frontend/app/assets/javascripts/spree/frontend/checkout/address.js
@@ -6,11 +6,11 @@ Spree.ready(function ($) {
if (countryId != null) {
if (Spree.Checkout[countryId] == null) {
$.ajax({
- async: false, method: 'GET', url: Spree.pathFor('/api/v2/storefront/countries/' + countryId + '?include=states&include_checkout_zone_applicable_states=true'), dataType: 'json'
+ async: false, method: 'GET', url: Spree.pathFor('/api/v2/storefront/countries/' + countryId + '?include=checkout_zone_applicable_states'), dataType: 'json'
}).done(function (data) {
- var json = data.data.attributes.checkout_zone_applicable_states; var xStates = [];
+ var json = data.included; var xStates = [];
for (var i = 0; i < json.length; i++) {
- var obj = json[i]; xStates.push({ 'id': obj.id, 'name': obj.name })
+ var obj = json[i]; xStates.push({ 'id': obj.id, 'name': obj.attributes.name })
}
Spree.Checkout[countryId] = {
states: xStates,