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.

Added the marketplace timezone to the seller profile

Damian Legawiecb58bcf146f67
diff --git a/docs/api-reference/seller.yaml b/docs/api-reference/seller.yaml
index 902648e3dd..a467879a93 100644
--- a/docs/api-reference/seller.yaml
+++ b/docs/api-reference/seller.yaml
@@ -14003,6 +14003,7 @@ paths:
logo_url:
square_logo_url:
cover_photo_url:
+ preferred_timezone: UTC
status: approved
legal_name:
registration_number:
@@ -14075,6 +14076,7 @@ paths:
logo_url:
square_logo_url:
cover_photo_url:
+ preferred_timezone: UTC
status: approved
legal_name:
registration_number:
@@ -21192,6 +21194,9 @@ components:
cover_photo_url:
type: string
nullable: true
+ preferred_timezone:
+ type: string
+ nullable: true
status:
anyOf:
- type: string
@@ -21264,6 +21269,7 @@ components:
- logo_url
- square_logo_url
- cover_photo_url
+ - preferred_timezone
- status
- legal_name
- registration_number
diff --git a/packages/seller-sdk/src/types/generated/Profile.ts b/packages/seller-sdk/src/types/generated/Profile.ts
index 1aa3df3514..674d1ebb0e 100644
--- a/packages/seller-sdk/src/types/generated/Profile.ts
+++ b/packages/seller-sdk/src/types/generated/Profile.ts
@@ -1,4 +1,4 @@
-// Typelizer digest e36e1371647923d22dd8b46f559b7b3f
+// Typelizer digest 72248d28723538db9f2f68bcf6df620b
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
import type {Policy, Address, SellerStatus} from '@/types'
@@ -12,6 +12,7 @@ type Profile = {
logo_url: string | null;
square_logo_url: string | null;
cover_photo_url: string | null;
+ preferred_timezone: string | null;
status: SellerStatus;
legal_name: string | null;
registration_number: string | null;
diff --git a/spree/api/app/serializers/spree/api/v3/seller/profile_serializer.rb b/spree/api/app/serializers/spree/api/v3/seller/profile_serializer.rb
index 7afae05b44..f0d8802d27 100644
--- a/spree/api/app/serializers/spree/api/v3/seller/profile_serializer.rb
+++ b/spree/api/app/serializers/spree/api/v3/seller/profile_serializer.rb
@@ -16,9 +16,11 @@ module Spree
on_holiday: :boolean, sellable: :boolean,
products_count: :number,
default_currency: :string,
- supported_currencies: [:string, multi: true]
+ supported_currencies: [:string, multi: true],
+ preferred_timezone: [:string, nullable: true]
- attributes :status, :legal_name, :registration_number,
+ attributes :preferred_timezone,
+ :status, :legal_name, :registration_number,
:contact_email, :billing_email,
:tax_remittance, :payouts_schedule_interval,
holiday_mode_until: :iso8601,
diff --git a/spree/api/spec/controllers/spree/api/v3/seller/profile_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/seller/profile_controller_spec.rb
index aff3a1eb5b..e55b2dbab5 100644
--- a/spree/api/spec/controllers/spree/api/v3/seller/profile_controller_spec.rb
+++ b/spree/api/spec/controllers/spree/api/v3/seller/profile_controller_spec.rb
@@ -22,6 +22,16 @@ RSpec.describe Spree::Api::V3::Seller::ProfileController, type: :controller do
end
describe 'GET #show' do
+ # A seller keeps no clock of their own, so the panel reads timestamps in the
+ # marketplace's zone rather than in whichever one the browser sits in.
+ it "carries the store's timezone" do
+ store.update!(preferred_timezone: 'Europe/Warsaw')
+
+ get :show, as: :json
+
+ expect(json_response['preferred_timezone']).to eq('Europe/Warsaw')
+ end
+
it 'returns the seller their own record' do
get :show, as: :json
diff --git a/spree/core/app/models/spree/seller.rb b/spree/core/app/models/spree/seller.rb
index 8e76d06eaf..cb1f7fbc9d 100644
--- a/spree/core/app/models/spree/seller.rb
+++ b/spree/core/app/models/spree/seller.rb
@@ -320,6 +320,11 @@ module Spree
set_external_id(provider.reference_system, account_reference)
end
+ # A seller keeps no clock of their own: a date means whatever the
+ # marketplace says it means, so their panel reads timestamps in the
+ # store's zone rather than in whichever one their browser sits in.
+ delegate :preferred_timezone, to: :store, allow_nil: true
+
# Sellers holding an account with one provider, for the reverse lookup a
# provider webhook does — it knows the account, not the seller.
#