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.

Cleanup of Addresses/Countries/States

Damian Legawiec840f67fdbf0f
diff --git a/api/app/controllers/spree/api/v3/store/addresses_controller.rb b/api/app/controllers/spree/api/v3/store/addresses_controller.rb
index 9008e89237..03227a2dc3 100644
--- a/api/app/controllers/spree/api/v3/store/addresses_controller.rb
+++ b/api/app/controllers/spree/api/v3/store/addresses_controller.rb
@@ -54,7 +54,7 @@ module Spree
def permitted_params
params.require(:address).permit(
:firstname, :lastname, :address1, :address2, :city,
- :zipcode, :phone, :company, :country_iso, :state_code
+ :zipcode, :phone, :company, :country_iso, :state_abbr, :state_name
)
end
end
diff --git a/api/app/controllers/spree/api/v3/store/countries_controller.rb b/api/app/controllers/spree/api/v3/store/countries_controller.rb
index 8e72f719c9..1163f93db9 100644
--- a/api/app/controllers/spree/api/v3/store/countries_controller.rb
+++ b/api/app/controllers/spree/api/v3/store/countries_controller.rb
@@ -43,7 +43,7 @@ module Spree
if include_states
data[:states] = country.states.order(:name).map do |state|
- { iso: state.abbr, name: state.name }
+ { abbr: state.abbr, name: state.name }
end
end
diff --git a/api/app/serializers/spree/api/v3/address_serializer.rb b/api/app/serializers/spree/api/v3/address_serializer.rb
index 4925de44e3..8552254fef 100644
--- a/api/app/serializers/spree/api/v3/address_serializer.rb
+++ b/api/app/serializers/spree/api/v3/address_serializer.rb
@@ -5,22 +5,16 @@ module Spree
typelize firstname: 'string | null', lastname: 'string | null', full_name: :string,
address1: 'string | null', address2: 'string | null',
city: 'string | null', zipcode: 'string | null', phone: 'string | null',
- company: 'string | null', state_code: 'string | null',
+ company: 'string | null', state_abbr: 'string | null', state_name: 'string | null',
state_text: 'string | null', country_iso: :string, country_name: :string
attributes :firstname, :lastname, :full_name, :address1, :address2,
- :city, :zipcode, :phone, :company, :state_text, :country_name
+ :city, :zipcode, :phone, :company, :country_name, :country_iso, :state_text,
+ :state_abbr
- # Country code (ISO 3166-1 alpha-2)
- attribute :country_iso do |address|
- address.country_iso
- end
-
- # State code in ISO 3166-2 format (e.g., "US-CA", "DE-BY")
- attribute :state_code do |address|
- next nil unless address.state
-
- "#{address.country&.iso}-#{address.state.abbr}"
+ # State name - used for countries without predefined states
+ attribute :state_name do |address|
+ address.state_name.presence || address.state&.name
end
end
end
diff --git a/api/app/serializers/spree/api/v3/state_serializer.rb b/api/app/serializers/spree/api/v3/state_serializer.rb
index 1f6ac13777..6c1343eb65 100644
--- a/api/app/serializers/spree/api/v3/state_serializer.rb
+++ b/api/app/serializers/spree/api/v3/state_serializer.rb
@@ -5,15 +5,9 @@ module Spree
include Alba::Resource
include Typelizer::DSL
- # ISO 3166-2 subdivision code (without country prefix)
- # No id field - iso is the identifier
- typelize iso: :string, name: :string
+ typelize abbr: :string, name: :string
- attribute :iso do |state|
- state.abbr
- end
-
- attributes :name
+ attributes :abbr, :name
end
end
end
diff --git a/api/spec/controllers/spree/api/v3/store/addresses_controller_spec.rb b/api/spec/controllers/spree/api/v3/store/addresses_controller_spec.rb
index 49151027ef..76b1f13a25 100644
--- a/api/spec/controllers/spree/api/v3/store/addresses_controller_spec.rb
+++ b/api/spec/controllers/spree/api/v3/store/addresses_controller_spec.rb
@@ -5,7 +5,7 @@ RSpec.describe Spree::Api::V3::Store::AddressesController, type: :controller do
include_context 'API v3 Store'
- let(:country) { create(:country) }
+ let(:country) { create(:country, states_required: true) }
let(:state) { create(:state, country: country) }
let!(:address) { create(:address, user: user, country: country, state: state) }
@@ -43,10 +43,10 @@ RSpec.describe Spree::Api::V3::Store::AddressesController, type: :controller do
describe 'GET #show' do
it 'returns the address' do
- get :show, params: { id: address.id }
+ get :show, params: { id: address.prefix_id }
expect(response).to have_http_status(:ok)
- expect(json_response['id']).to eq(address.id)
+ expect(json_response['id']).to eq(address.prefix_id)
expect(json_response['firstname']).to eq(address.firstname)
expect(json_response['lastname']).to eq(address.lastname)
end
@@ -64,7 +64,7 @@ RSpec.describe Spree::Api::V3::Store::AddressesController, type: :controller do
other_user = create(:user)
other_address = create(:address, user: other_user)
- get :show, params: { id: other_address.id }
+ get :show, params: { id: other_address.prefix_id }
expect(response).to have_http_status(:not_found)
expect(json_response['error']['code']).to eq('record_not_found')
@@ -82,8 +82,8 @@ RSpec.describe Spree::Api::V3::Store::AddressesController, type: :controller do
city: 'New York',
zipcode: '10001',
phone: '555-1234',
- country_id: country.id,
- state_id: state.id
+ country_iso: country.iso,
+ state_abbr: state.abbr
}
}
end
@@ -104,6 +104,64 @@ RSpec.describe Spree::Api::V3::Store::AddressesController, type: :controller do
expect(Spree::Address.last.user_id).to eq(user.id)
end
+ context 'with state_abbr for country with states required' do
+ let(:address_params) do
+ {
+ address: {
+ firstname: 'Jane',
+ lastname: 'Smith',
+ address1: '456 Oak Ave',
+ city: 'Los Angeles',
+ zipcode: '90001',
+ phone: '555-5678',
+ country_iso: country.iso,
+ state_abbr: state.abbr
+ }
+ }
+ end
+
+ it 'creates address using country_iso and state_abbr' do
+ expect {
+ post :create, params: address_params
+ }.to change(Spree::Address, :count).by(1)
+
+ expect(response).to have_http_status(:created)
+ expect(json_response['firstname']).to eq('Jane')
+ expect(json_response['country_iso']).to eq(country.iso)
+ expect(json_response['state_abbr']).to eq(state.abbr)
+ expect(json_response['state_name']).to eq(state.name)
+ end
+ end
+
+ context 'with state_name for country without states required' do
+ let(:country_without_states) { create(:country, states_required: false) }
+ let(:state_name_params) do
+ {
+ address: {
+ firstname: 'Hans',
+ lastname: 'Mueller',
+ address1: '789 Berlin Str',
+ city: 'Berlin',
+ zipcode: '10115',
+ phone: '555-9999',
+ country_iso: country_without_states.iso,
+ state_name: 'Berlin'
+ }
+ }
+ end
+
+ it 'creates address with state_name' do
+ expect {
+ post :create, params: state_name_params
+ }.to change(Spree::Address, :count).by(1)
+
+ expect(response).to have_http_status(:created)
+ expect(json_response['firstname']).to eq('Hans')
+ expect(json_response['state_abbr']).to be_nil
+ expect(json_response['state_name']).to eq('Berlin')
+ end
+ end
+
context 'validation errors' do
it 'returns errors for missing required fields' do
post :create, params: { address: { firstname: 'John' } }
@@ -122,7 +180,7 @@ RSpec.describe Spree::Api::V3::Store::AddressesController, type: :controller do
end
it 'returns errors for invalid country' do
- post :create, params: { address: valid_params[:address].merge(country_id: 0) }
+ post :create, params: { address: valid_params[:address].merge(country_iso: 'XX') }
expect(response).to have_http_status(:unprocessable_entity)
expect(json_response['error']['code']).to eq('validation_error')
@@ -144,7 +202,7 @@ RSpec.describe Spree::Api::V3::Store::AddressesController, type: :controller do
describe 'PATCH #update' do
it 'updates the address' do
- patch :update, params: { id: address.id, address: { address1: 'Updated Street' } }
+ patch :update, params: { id: address.prefix_id, address: { address1: 'Updated Street' } }
expect(response).to have_http_status(:ok)
expect(address.reload.address1).to eq('Updated Street')
@@ -152,7 +210,7 @@ RSpec.describe Spree::Api::V3::Store::AddressesController, type: :controller do
it 'updates multiple fields' do
patch :update, params: {
- id: address.id,
+ id: address.prefix_id,
address: { firstname: 'Jane', lastname: 'Smith', city: 'Boston' }
}
@@ -165,7 +223,7 @@ RSpec.describe Spree::Api::V3::Store::AddressesController, type: :controller do
context 'validation errors' do
it 'returns errors for invalid update' do
- patch :update, params: { id: address.id, address: { firstname: '' } }
+ patch :update, params: { id: address.prefix_id, address: { firstname: '' } }
expect(response).to have_http_status(:unprocessable_entity)
expect(json_response['error']['code']).to eq('validation_error')
@@ -178,7 +236,7 @@ RSpec.describe Spree::Api::V3::Store::AddressesController, type: :controller do
other_user = create(:user)
other_address = create(:address, user: other_user)
- patch :update, params: { id: other_address.id, address: { address1: 'Hack Street' } }
+ patch :update, params: { id: other_address.prefix_id, address: { address1: 'Hack Street' } }
expect(response).to have_http_status(:not_found)
expect(json_response['error']['code']).to eq('record_not_found')
@@ -190,7 +248,7 @@ RSpec.describe Spree::Api::V3::Store::AddressesController, type: :controller do
describe 'DELETE #destroy' do
it 'deletes the address' do
expect {
- delete :destroy, params: { id: address.id }
+ delete :destroy, params: { id: address.prefix_id }
}.to change(Spree::Address, :count).by(-1)
expect(response).to have_http_status(:no_content)
@@ -209,7 +267,7 @@ RSpec.describe Spree::Api::V3::Store::AddressesController, type: :controller do
other_user = create(:user)
other_address = create(:address, user: other_user)
- delete :destroy, params: { id: other_address.id }
+ delete :destroy, params: { id: other_address.prefix_id }
expect(response).to have_http_status(:not_found)
expect(json_response['error']['code']).to eq('record_not_found')
diff --git a/api/spec/integration/spree/api/v3/store/addresses_spec.rb b/api/spec/integration/spree/api/v3/store/addresses_spec.rb
index 3717970f1d..7db2a4019d 100644
--- a/api/spec/integration/spree/api/v3/store/addresses_spec.rb
+++ b/api/spec/integration/spree/api/v3/store/addresses_spec.rb
@@ -69,10 +69,12 @@ RSpec.describe 'Addresses API', type: :request, swagger_doc: 'api-reference/stor
city: { type: :string },
zipcode: { type: :string },
phone: { type: :string },
- country_iso: { type: :string, description: 'ISO country code (e.g., "US", "DE")' },
- state_code: { type: :string, description: 'State abbreviation/code (e.g., "CA", "NY") - required if country has states' }
+ company: { type: :string },
+ country_iso: { type: :string, description: 'ISO 3166-1 alpha-2 country code (e.g., "US", "DE")' },
+ state_abbr: { type: :string, description: 'ISO 3166-2 subdivision code without country prefix (e.g., "CA", "NY")' },
+ state_name: { type: :string, description: 'State name - for countries without predefined states' }
},
- required: %w[firstname lastname address1 city zipcode phone country_iso]
+ required: %w[firstname lastname address1 city zipcode country_iso]
}
}
}
@@ -90,7 +92,7 @@ RSpec.describe 'Addresses API', type: :request, swagger_doc: 'api-reference/stor
zipcode: '10001',
phone: '+1 555 123 4567',
country_iso: country.iso,
- state_code: state.abbr
+ state_abbr: state.abbr
}
}
end
@@ -102,6 +104,7 @@ RSpec.describe 'Addresses API', type: :request, swagger_doc: 'api-reference/stor
expect(data['firstname']).to eq('John')
expect(data['city']).to eq('New York')
expect(data['country_iso']).to eq(country.iso)
+ expect(data['state_abbr']).to eq(state.abbr)
end
end
diff --git a/api/spec/integration/spree/api/v3/store/countries_spec.rb b/api/spec/integration/spree/api/v3/store/countries_spec.rb
index 2933beb2d7..8994d0a7c4 100644
--- a/api/spec/integration/spree/api/v3/store/countries_spec.rb
+++ b/api/spec/integration/spree/api/v3/store/countries_spec.rb
@@ -90,10 +90,10 @@ RSpec.describe 'Countries API', type: :request, swagger_doc: 'api-reference/stor
items: {
type: :object,
properties: {
- iso: { type: :string, description: 'ISO 3166-2 subdivision code (without country prefix)' },
+ abbr: { type: :string, description: 'State abbreviation code' },
name: { type: :string }
},
- required: %w[iso name]
+ required: %w[abbr name]
}
}
},
@@ -104,8 +104,8 @@ RSpec.describe 'Countries API', type: :request, swagger_doc: 'api-reference/stor
expect(data['iso']).to eq('US')
expect(data['states']).to be_an(Array)
# Check that states have the expected structure
- state_isos = data['states'].map { |s| s['iso'] }
- expect(state_isos).to include('CA', 'NY')
+ state_abbrs = data['states'].map { |s| s['abbr'] }
+ expect(state_abbrs).to include('CA', 'NY')
end
end
diff --git a/api/spec/swagger_helper.rb b/api/spec/swagger_helper.rb
index 68b568ac52..06a1ce2708 100644
--- a/api/spec/swagger_helper.rb
+++ b/api/spec/swagger_helper.rb
@@ -89,7 +89,6 @@ RSpec.configure do |config|
{ name: 'Taxonomies', description: 'Category hierarchies' },
{ name: 'Taxons', description: 'Individual categories' },
{ name: 'Countries', description: 'Available shipping countries' },
- { name: 'States', description: 'States and provinces' },
{ name: 'Orders', description: 'Shopping cart and checkout' },
{ name: 'Line Items', description: 'Cart item management' },
{ name: 'Payments', description: 'Payment processing' },
diff --git a/core/app/services/spree/addresses/helper.rb b/core/app/services/spree/addresses/helper.rb
index b58c8d406c..64c9837001 100644
--- a/core/app/services/spree/addresses/helper.rb
+++ b/core/app/services/spree/addresses/helper.rb
@@ -21,13 +21,28 @@ module Spree
end
def fill_state_id(params)
- state_name = params[:state_name]
- return params unless state_name.present?
+ # Always extract state_abbr - it's not a model attribute
+ state_abbr = params.delete(:state_abbr)
country ||= Spree::Country.find(params[:country_id]) if params[:country_id].present?
return params unless country
- params[:state_id] = country.states.find_by(name: state_name)&.id
+ # Support state_abbr (state abbreviation code, e.g., "CA", "NY")
+ if state_abbr.present?
+ params[:state_id] = country.states.find_by(abbr: state_abbr)&.id
+ return params
+ end
+
+ # Support state_name for countries where states are not required
+ if params[:state_name].present? && !country.states_required?
+ # Keep state_name as-is for countries without required states
+ return params
+ elsif params[:state_name].present?
+ # Try to find state by name if states are required
+ params[:state_id] = country.states.find_by(name: params[:state_name])&.id
+ params.delete(:state_name)
+ end
+
params
end
diff --git a/docs/api-reference/store.yaml b/docs/api-reference/store.yaml
index c177b0036c..139bf05e99 100644
--- a/docs/api-reference/store.yaml
+++ b/docs/api-reference/store.yaml
@@ -145,20 +145,25 @@ paths:
type: string
phone:
type: string
- country_id:
+ company:
type: string
- state_id:
+ country_iso:
type: string
+ description: ISO 3166-1 alpha-2 country code (e.g., "US", "DE")
+ state_abbr:
+ type: string
+ description: ISO 3166-2 subdivision code without country prefix
+ (e.g., "CA", "NY")
state_name:
type: string
+ description: State name - for countries without predefined states
required:
- firstname
- lastname
- address1
- city
- zipcode
- - phone
- - country_id
+ - country_iso
"/api/v3/store/customers/me/addresses/{id}":
get:
summary: Get an address
@@ -412,34 +417,19 @@ paths:
"$ref": "#/components/schemas/ErrorResponse"
"/api/v3/store/countries":
get:
- summary: List countries
+ summary: List checkout countries
tags:
- Countries
security:
- api_key: []
- description: Returns a list of countries available for shipping
+ description: Returns countries available for checkout from the store checkout
+ zone
parameters:
- name: x-spree-api-key
in: header
required: true
schema:
type: string
- - name: page
- in: query
- required: false
- schema:
- type: integer
- - name: per_page
- in: query
- required: false
- schema:
- type: integer
- - name: q[name_cont]
- in: query
- required: false
- description: Filter by name
- schema:
- type: string
responses:
'200':
description: countries found
@@ -451,33 +441,52 @@ paths:
data:
type: array
items:
- "$ref": "#/components/schemas/StoreCountry"
- meta:
- "$ref": "#/components/schemas/PaginationMeta"
+ type: object
+ properties:
+ iso:
+ type: string
+ description: ISO 3166-1 alpha-2 code
+ iso3:
+ type: string
+ description: ISO 3166-1 alpha-3 code
+ name:
+ type: string
+ states_required:
+ type: boolean
+ zipcode_required:
+ type: boolean
+ required:
+ - iso
+ - iso3
+ - name
+ - states_required
+ - zipcode_required
+ required:
+ - data
'401':
description: unauthorized
content:
application/json:
schema:
"$ref": "#/components/schemas/ErrorResponse"
- "/api/v3/store/countries/{id}":
+ "/api/v3/store/countries/{iso}":
get:
- summary: Get a country
+ summary: Get a country with states
tags:
- Countries
security:
- api_key: []
- description: Returns a single country by prefixed ID
+ description: Returns a single country by ISO code with its states
parameters:
- name: x-spree-api-key
in: header
required: true
schema:
type: string
- - name: id
+ - name: iso
in: path
required: true
- description: Country ID (prefixed, e.g., country_abc123)
+ description: Country ISO 3166-1 alpha-2 code (e.g., "US", "DE", "CA")
schema:
type: string
responses:
@@ -486,7 +495,40 @@ paths:
content:
application/json:
schema:
- "$ref": "#/components/schemas/StoreCountry"
+ type: object
+ properties:
+ iso:
+ type: string
+ description: ISO 3166-1 alpha-2 code
+ iso3:
+ type: string
+ description: ISO 3166-1 alpha-3 code
+ name:
+ type: string
+ states_required:
+ type: boolean
+ zipcode_required:
+ type: boolean
+ states:
+ type: array
+ items:
+ type: object
+ properties:
+ abbr:
+ type: string
+ description: State abbreviation code
+ name:
+ type: string
+ required:
+ - abbr
+ - name
+ required:
+ - iso
+ - iso3
+ - name
+ - states_required
+ - zipcode_required
+ - states
'404':
description: country not found
content:
@@ -620,12 +662,6 @@ paths:
application/json:
schema:
"$ref": "#/components/schemas/StoreLineItem"
- '422':
- description: validation error - invalid variant
- content:
- application/json:
- schema:
- "$ref": "#/components/schemas/ErrorResponse"
'404':
description: order not found
content:
@@ -689,12 +725,6 @@ paths:
application/json:
schema:
"$ref": "#/components/schemas/StoreLineItem"
- '422':
- description: invalid quantity
- content:
- application/json:
- schema:
- "$ref": "#/components/schemas/ErrorResponse"
requestBody:
content:
application/json:
@@ -944,8 +974,8 @@ paths:
application/json:
schema:
"$ref": "#/components/schemas/StoreOrder"
- '422':
- description: validation error
+ '403':
+ description: cannot update completed order
content:
application/json:
schema:
@@ -1091,39 +1121,7 @@ paths:
application/json:
schema:
"$ref": "#/components/schemas/ErrorResponse"
- "/api/v3/store/orders/{id}/cancel":
- patch:
- summary: Cancel the order
- tags:
- - Orders
- security:
- - api_key: []
- bearer_auth: []
- description: Cancels a completed order
- parameters:
- - name: x-spree-api-key
- in: header
- required: true
- schema:
- type: string
- - name: Authorization
- in: header
- required: false
- schema:
- type: string
- - name: id
- in: path
- required: true
- schema:
- type: string
- responses:
- '200':
- description: order cancelled
- content:
- application/json:
- schema:
- "$ref": "#/components/schemas/StoreOrder"
- "/api/v3/store/orders/{id}/store_credits":
+ "/api/v3/store/orders/{order_id}/store_credits":
post:
summary: Add store credit
tags:
@@ -1143,7 +1141,7 @@ paths:
required: true
schema:
type: string
- - name: id
+ - name: order_id
in: path
required: true
schema:
@@ -1194,7 +1192,7 @@ paths:
required: true
schema:
type: string
- - name: id
+ - name: order_id
in: path
required: true
schema:
@@ -1255,7 +1253,10 @@ paths:
items:
"$ref": "#/components/schemas/StorePaymentMethod"
meta:
- "$ref": "#/components/schemas/PaginationMeta"
+ type: object
+ properties:
+ count:
+ type: integer
'404':
description: order not found
content:
@@ -1310,8 +1311,8 @@ paths:
type: array
items:
"$ref": "#/components/schemas/StorePayment"
- meta:
- "$ref": "#/components/schemas/PaginationMeta"
+ required:
+ - data
'404':
description: order not found
content:
@@ -1514,7 +1515,7 @@ paths:
- Products
security:
- api_key: []
- description: Returns a single product by prefixed ID
+ description: Returns a single product by slug or prefix ID
parameters:
- name: x-spree-api-key
in: header
@@ -1525,7 +1526,7 @@ paths:
- name: id
in: path
required: true
- description: Product ID (prefixed, e.g., prod_abc123)
+ description: Product slug (e.g., ruby-on-rails-tote) or prefix ID (e.g., product_abc123)
schema:
type: string
- name: includes
@@ -1536,7 +1537,7 @@ paths:
type: string
responses:
'200':
- description: product found
+ description: product found by prefix ID
content:
application/json:
schema:
@@ -1572,9 +1573,10 @@ paths:
required: true
schema:
type: string
- - name: order_token
+ - name: token
in: query
required: false
+ description: Order token for guest access
schema:
type: string
responses:
@@ -1625,12 +1627,13 @@ paths:
- name: id
in: path
required: true
- description: Shipment ID or number
+ description: Shipment ID
schema:
type: string
- - name: order_token
+ - name: token
in: query
required: false
+ description: Order token for guest access
schema:
type: string
- name: includes
@@ -1679,11 +1682,13 @@ paths:
- name: id
in: path
required: true
+ description: Shipment ID
schema:
type: string
- - name: order_token
+ - name: token
in: query
required: false
+ description: Order token for guest access
schema:
type: string
responses:
@@ -1693,8 +1698,8 @@ paths:
application/json:
schema:
"$ref": "#/components/schemas/StoreShipment"
- '422':
- description: invalid shipping rate
+ '404':
+ description: shipping rate not found
content:
application/json:
schema:
@@ -1705,94 +1710,16 @@ paths:
schema:
type: object
properties:
- shipping_rate_id:
- type: string
- description: Shipping rate ID to select
+ shipment:
+ type: object
+ properties:
+ selected_shipping_rate_id:
+ type: string
+ description: Shipping rate ID to select
+ required:
+ - selected_shipping_rate_id
required:
- - shipping_rate_id
- "/api/v3/store/states":
- get:
- summary: List states
- tags:
- - States
- security:
- - api_key: []
- description: Returns a list of states/provinces, optionally filtered by country
- parameters:
- - name: x-spree-api-key
- in: header
- required: true
- schema:
- type: string
- - name: country_id
- in: query
- required: false
- description: Filter by country ID (prefixed)
- schema:
- type: string
- - name: page
- in: query
- required: false
- schema:
- type: integer
- - name: per_page
- in: query
- required: false
- schema:
- type: integer
- responses:
- '200':
- description: states filtered by country
- content:
- application/json:
- schema:
- type: object
- properties:
- data:
- type: array
- items:
- "$ref": "#/components/schemas/StoreState"
- meta:
- "$ref": "#/components/schemas/PaginationMeta"
- '401':
- description: unauthorized
- content:
- application/json:
- schema:
- "$ref": "#/components/schemas/ErrorResponse"
- "/api/v3/store/states/{id}":
- get:
- summary: Get a state
- tags:
- - States
- security:
- - api_key: []
- description: Returns a single state by ID
- parameters:
- - name: x-spree-api-key
- in: header
- required: true
- schema:
- type: string
- - name: id
- in: path
- required: true
- description: State ID (prefixed)
- schema:
- type: string
- responses:
- '200':
- description: state found
- content:
- application/json:
- schema:
- "$ref": "#/components/schemas/StoreState"
- '404':
- description: state not found
- content:
- application/json:
- schema:
- "$ref": "#/components/schemas/ErrorResponse"
+ - shipment
"/api/v3/store/store":
get:
summary: Get current store
@@ -1917,7 +1844,7 @@ paths:
- Taxons
security:
- api_key: []
- description: Returns a single taxon by ID or permalink
+ description: Returns a single taxon by permalink or prefix ID
parameters:
- name: x-spree-api-key
in: header
@@ -1927,7 +1854,8 @@ paths:
- name: id
in: path
required: true
- description: Taxon ID (prefixed) or permalink
+ description: Taxon permalink (e.g., categories/clothing/shirts) or prefix
+ ID (e.g., taxon_abc123)
schema:
type: string
- name: includes
@@ -1938,7 +1866,7 @@ paths:
type: string
responses:
'200':
- description: taxon found by permalink
+ description: taxon found by prefix ID
content:
application/json:
schema:
@@ -2264,8 +2192,6 @@ tags:
description: Individual categories
- name: Countries
description: Available shipping countries
-- name: States
- description: States and provinces
- name: Orders
description: Shopping cart and checkout
- name: Line Items
@@ -2385,25 +2311,25 @@ components:
company:
type: string
nullable: true
- state_id:
+ country_name:
+ type: string
+ country_iso:
type: string
- nullable: true
state_text:
type: string
nullable: true
- country_id:
+ state_abbr:
type: string
- country_iso:
- type: string
- country_name:
+ nullable: true
+ state_name:
type: string
+ nullable: true
x-typelizer: true
required:
- id
- full_name
- - country_id
- - country_iso
- country_name
+ - country_iso
AdminOrder:
type: object
properties:
@@ -2846,14 +2772,10 @@ components:
StoreCountry:
type: object
properties:
- id:
- type: string
iso:
type: string
iso3:
type: string
- iso_name:
- type: string
name:
type: string
states_required:
@@ -2866,10 +2788,8 @@ components:
"$ref": "#/components/schemas/StoreState"
x-typelizer: true
required:
- - id
- iso
- iso3
- - iso_name
- name
- states_required
- zipcode_required
@@ -2999,9 +2919,6 @@ components:
type: string
display_discounted_amount:
type: string
- compare_at_amount:
- type: string
- nullable: true
display_compare_at_amount:
type: string
nullable: true
@@ -3009,6 +2926,9 @@ components:
type: string
updated_at:
type: string
+ compare_at_amount:
+ type: string
+ nullable: true
images:
type: array
items:
@@ -3394,33 +3314,13 @@ components:
tracking_url:
type: string
nullable: true
- shipped_at:
- type: string
- nullable: true
cost:
type: string
display_cost:
type: string
- adjustment_total:
- type: string
- display_adjustment_total:
- type: string
- additional_tax_total:
- type: string
- display_additional_tax_total:
- type: string
- promo_total:
- type: string
- display_promo_total:
- type: string
- included_tax_total:
- type: string
- display_included_tax_total:
- type: string
- total:
- type: string
- display_total:
+ shipped_at:
type: string
+ nullable: true
created_at:
type: string
updated_at:
@@ -3440,16 +3340,6 @@ components:
- state
- cost
- display_cost
- - adjustment_total
- - display_adjustment_total
- - additional_tax_total
- - display_additional_tax_total
- - promo_total
- - display_promo_total
- - included_tax_total
- - display_included_tax_total
- - total
- - display_total
- created_at
- updated_at
- shipping_method
@@ -3498,20 +3388,14 @@ components:
StoreState:
type: object
properties:
- id:
- type: string
- country_id:
+ abbr:
type: string
name:
type: string
- abbr:
- type: string
x-typelizer: true
required:
- - id
- - country_id
- - name
- abbr
+ - name
StoreStockLocation:
type: object
properties:
@@ -3650,17 +3534,17 @@ components:
meta_keywords:
type: string
nullable: true
- parent_id:
- type: string
- nullable: true
- taxonomy_id:
- type: string
children_count:
type: number
created_at:
type: string
updated_at:
type: string
+ parent_id:
+ type: string
+ nullable: true
+ taxonomy_id:
+ type: string
description:
type: string
description_html:
@@ -3692,10 +3576,10 @@ components:
- lft
- rgt
- depth
- - taxonomy_id
- children_count
- created_at
- updated_at
+ - taxonomy_id
- description
- description_html
- is_root
diff --git a/sdk/src/types/generated/StoreAddress.ts b/sdk/src/types/generated/StoreAddress.ts
index e7959b9f71..e595dce228 100644
--- a/sdk/src/types/generated/StoreAddress.ts
+++ b/sdk/src/types/generated/StoreAddress.ts
@@ -1,4 +1,4 @@
-// Typelizer digest 5625baecb7d36641a0990de91c3c03c7
+// Typelizer digest 62e9946ae4558d489bdd831c767368f5
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
@@ -13,10 +13,11 @@ type StoreAddress = {
zipcode: string | null;
phone: string | null;
company: string | null;
- state_text: string | null;
country_name: string;
country_iso: string;
- state_code: string | null;
+ state_text: string | null;
+ state_abbr: string | null;
+ state_name: string | null;
}
export default StoreAddress;
diff --git a/sdk/src/types/generated/StoreState.ts b/sdk/src/types/generated/StoreState.ts
index 89a260616d..7004e48064 100644
--- a/sdk/src/types/generated/StoreState.ts
+++ b/sdk/src/types/generated/StoreState.ts
@@ -1,9 +1,9 @@
-// Typelizer digest 29bade6d72448ee72050b9751ecebf7a
+// Typelizer digest 27257c698e603c5e59077f2f7f7a4d02
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
type StoreState = {
- iso: string;
+ abbr: string;
name: string;
}
diff --git a/sdk/src/types/index.ts b/sdk/src/types/index.ts
index 5419fccc70..eeb86a37e2 100644
--- a/sdk/src/types/index.ts
+++ b/sdk/src/types/index.ts
@@ -88,9 +88,13 @@ export interface AddressParams {
address2?: string;
city: string;
zipcode: string;
- phone: string;
- country_id: string;
- state_id?: string;
+ phone?: string;
+ company?: string;
+ /** ISO 3166-1 alpha-2 country code (e.g., "US", "DE") */
+ country_iso: string;
+ /** ISO 3166-2 subdivision code without country prefix (e.g., "CA", "NY") */
+ state_abbr?: string;
+ /** State name - used for countries without predefined states */
state_name?: string;
}