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.

Withhold the buyer's email from the seller order

Damian Legawiec8c3881608b24
diff --git a/docs/api-reference/seller.yaml b/docs/api-reference/seller.yaml
index a394623dae..050e0520f4 100644
--- a/docs/api-reference/seller.yaml
+++ b/docs/api-reference/seller.yaml
@@ -13896,7 +13896,6 @@ paths:
data:
- id: or_UkLWZg9DAJ
number: R1001
customer_note:
currency: USD
total_quantity: 1
@@ -14046,7 +14045,6 @@ paths:
example:
id: or_UkLWZg9DAJ
number: R1001
customer_note:
currency: USD
total_quantity: 1
@@ -14185,7 +14183,6 @@ paths:
example:
id: or_UkLWZg9DAJ
number: R1001
customer_note:
currency: USD
total_quantity: 1
@@ -15382,9 +15379,6 @@ components:
type: string
number:
type: string
- email:
- type: string
- nullable: true
customer_note:
type: string
nullable: true
@@ -15439,7 +15433,6 @@ components:
required:
- id
- number
- - email
- customer_note
- currency
- total_quantity
diff --git a/packages/seller-sdk/src/types/generated/Order.ts b/packages/seller-sdk/src/types/generated/Order.ts
index 672819bd46..948a6fba11 100644
--- a/packages/seller-sdk/src/types/generated/Order.ts
+++ b/packages/seller-sdk/src/types/generated/Order.ts
@@ -1,4 +1,4 @@
-// Typelizer digest 4c6809e63915964d3a02857daa2a7874
+// Typelizer digest afcb8676be0f97d4e914ccad7121c0f6
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
import type {OrderLineItem, Fulfillment, Address} from '@/types'
@@ -6,7 +6,6 @@ import type {OrderLineItem, Fulfillment, Address} from '@/types'
type Order = {
id: string;
number: string;
- email: string | null;
customer_note: string | null;
currency: string;
total_quantity: number;
diff --git a/spree/api/app/serializers/spree/api/v3/seller/order_serializer.rb b/spree/api/app/serializers/spree/api/v3/seller/order_serializer.rb
index 43728755f2..624afffdc6 100644
--- a/spree/api/app/serializers/spree/api/v3/seller/order_serializer.rb
+++ b/spree/api/app/serializers/spree/api/v3/seller/order_serializer.rb
@@ -9,12 +9,18 @@ module Spree
# how the customer paid the marketplace is not the seller's business,
# and what they are owed is the commission ledger, not this.
#
- # The customer's contact details are here because the seller packs and
- # posts the parcel, so they need the address and a way to reach the
- # buyer about it.
+ # The addresses are here because the seller is merchant of record for
+ # their child order (docs/plans/6.0-multi-vendor-marketplace.md): the
+ # shipping address to post the parcel, the billing address because the
+ # invoice for that sale is theirs to issue. Both marketplace platforms
+ # we surveyed give a seller the same two.
+ #
+ # The buyer's email is not. A seller reaching the customer about a
+ # delivery has the phone on the shipping address; an email address is
+ # the one contact detail that lets a marketplace's customer be taken
+ # off it, and it is not needed to pack, post or invoice.
class OrderSerializer < V3::BaseSerializer
typelize number: :string,
- email: [:string, nullable: true],
customer_note: [:string, nullable: true],
currency: :string,
total_quantity: :number,
@@ -25,7 +31,7 @@ module Spree
tax_total: [:string, nullable: true], display_tax_total: [:string, nullable: true],
total: [:string, nullable: true], display_total: [:string, nullable: true]
- attributes :number, :email, :customer_note, :currency, :total_quantity,
+ attributes :number, :customer_note, :currency, :total_quantity,
:status, :fulfillment_status, :payment_status,
completed_at: :iso8601, created_at: :iso8601, updated_at: :iso8601
diff --git a/spree/api/spec/controllers/spree/api/v3/seller/orders_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/seller/orders_controller_spec.rb
index 6bca076cb5..c99e6993d6 100644
--- a/spree/api/spec/controllers/spree/api/v3/seller/orders_controller_spec.rb
+++ b/spree/api/spec/controllers/spree/api/v3/seller/orders_controller_spec.rb
@@ -95,6 +95,25 @@ RSpec.describe Spree::Api::V3::Seller::OrdersController, type: :controller do
expect(json_response).not_to have_key('payments')
end
+ # The seller is merchant of record for their child order, so they invoice
+ # the buyer and need the billing address to do it — both marketplace
+ # platforms we surveyed give a seller the same two addresses.
+ it 'carries the addresses the seller ships and invoices to' do
+ get :show, params: { id: mine.prefixed_id }, as: :json
+
+ expect(json_response).to include('shipping_address', 'billing_address')
+ end
+
+ # A phone on the shipping address is how a seller reaches a buyer about a
+ # delivery. An email is what takes a marketplace's customer off it, and
+ # packing, posting and invoicing need none.
+ it "withholds the buyer's email" do
+ get :show, params: { id: mine.prefixed_id }, as: :json
+
+ expect(json_response).not_to have_key('email')
+ expect(json_response['shipping_address']).to have_key('phone')
+ end
+
it "404s on another seller's order" do
get :show, params: { id: theirs.prefixed_id }, as: :json