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.

Add Prices and Price Lists API

Damian Legawiecd6ebee6af217
diff --git a/CLAUDE.md b/CLAUDE.md
index 7adee5a4e7..a3e9ef1ec0 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -82,9 +82,11 @@ Shipped plans:
- CanCanCan for authorization: listings use `accessible_by(current_ability, :show)`, other actions use `authorize!`
- Always use scope fetching for security (e.g. `current_store.orders` not `Spree::Order`)
- Ransack for filtering/searching, Pagy for pagination
-- Business logic belongs in models and concerns, not controllers
- Use services only when necessary — prefer standard Rails models and concerns
-- Do not call `Spree::User` directly, use `Spree.user_class`; same for `Spree.admin_user_class`
+- DO NOT call `Spree::User` directly, use `Spree.user_class`; same for `Spree.admin_user_class`
+- DO NOT put logic into controllers or serializers - this should live in models and services
+- ALWAYS use Yard comments for classes and public methods, with `@param` and `@return` types
+- DO NOT generate too much comment noise, be very strict and selective about what gets a comment — only non-obvious public methods, never private methods or internal helpers
### Code Organization
@@ -568,8 +570,10 @@ Re-run `parallel_setup` after schema changes.
- RSpec + Factory Bot
- Prefer `build` over `create` for speed
- Factories live in `lib/spree/testing_support/factories/`
+- ALWAYS use factories in tests, never call `Model#create` directly
- Pragmatic — no tests for standard Rails validations, only custom ones
- Controller specs: always add `render_views`, use `stub_authorization!` for auth
+- Use controller specs for testing edge cases, API integration tests are only for happy path/simple 422 failures to generate OpenAPI examples; otherwise they get too brittle and high-maintenance
- Time-based tests: use `Timecop`
- Don't over-engineer or repeat tests
diff --git a/docs/api-reference/admin.yaml b/docs/api-reference/admin.yaml
index 86ddc636e4..29528f7996 100644
--- a/docs/api-reference/admin.yaml
+++ b/docs/api-reference/admin.yaml
@@ -82,12 +82,12 @@ paths:
example:
data:
- id: admin_UkLWZg9DAJ
- first_name: Jamal
- last_name: Doyle
- full_name: Jamal Doyle
- created_at: '2026-05-24T17:36:33.885Z'
- updated_at: '2026-05-24T17:36:33.885Z'
+ first_name: Charley
+ last_name: Kunze
+ full_name: Charley Kunze
+ created_at: '2026-05-25T19:03:37.284Z'
+ updated_at: '2026-05-25T19:03:37.284Z'
roles:
- id: role_UkLWZg9DAJ
name: admin
@@ -145,12 +145,12 @@ paths:
application/json:
example:
id: admin_UkLWZg9DAJ
- first_name: Mercedez
- last_name: Bailey
- full_name: Mercedez Bailey
- created_at: '2026-05-24T17:36:34.235Z'
- updated_at: '2026-05-24T17:36:34.235Z'
+ first_name: Kaitlyn
+ last_name: Bergstrom
+ full_name: Kaitlyn Bergstrom
+ created_at: '2026-05-25T19:03:37.662Z'
+ updated_at: '2026-05-25T19:03:37.662Z'
roles:
- id: role_UkLWZg9DAJ
name: admin
@@ -203,12 +203,12 @@ paths:
application/json:
example:
id: admin_UkLWZg9DAJ
first_name: Renamed
- last_name: Lindgren
- full_name: Renamed Lindgren
- created_at: '2026-05-24T17:36:34.526Z'
- updated_at: '2026-05-24T17:36:34.545Z'
+ last_name: Paucek
+ full_name: Renamed Paucek
+ created_at: '2026-05-25T19:03:37.973Z'
+ updated_at: '2026-05-25T19:03:37.992Z'
roles:
- id: role_UkLWZg9DAJ
name: admin
@@ -317,32 +317,32 @@ paths:
key_type: publishable
token_prefix:
scopes: []
- created_at: '2026-05-24T17:36:34.854Z'
- updated_at: '2026-05-24T17:36:34.854Z'
+ created_at: '2026-05-25T19:03:38.293Z'
+ updated_at: '2026-05-25T19:03:38.293Z'
revoked_at:
last_used_at:
- plaintext_token: pk_wqTPmhFDQiJbhbgokeP9tPzK
+ plaintext_token: pk_NNvStJYr3CzbJP4pmogaXP7W
created_by_email:
- id: key_gbHJdmfrXB
name: Backend integration
key_type: secret
- token_prefix: sk_GAnG4mX7L
+ token_prefix: sk_RinHwH3Ae
scopes:
- write_all
- created_at: '2026-05-24T17:36:34.855Z'
- updated_at: '2026-05-24T17:36:34.855Z'
+ created_at: '2026-05-25T19:03:38.294Z'
+ updated_at: '2026-05-25T19:03:38.294Z'
revoked_at:
last_used_at:
plaintext_token:
created_by_email:
- id: key_EfhxLZ9ck8
- name: occaecati
+ name: doloremque
key_type: secret
- token_prefix: sk_Zf75n9zm3
+ token_prefix: sk_YHVKja5WY
scopes:
- write_all
- created_at: '2026-05-24T17:36:34.857Z'
- updated_at: '2026-05-24T17:36:34.857Z'
+ created_at: '2026-05-25T19:03:38.295Z'
+ updated_at: '2026-05-25T19:03:38.295Z'
revoked_at:
last_used_at:
plaintext_token:
@@ -405,15 +405,15 @@ paths:
id: key_VqXmZF31wY
name: CI key
key_type: secret
- token_prefix: sk_ryCceerpp
+ token_prefix: sk_rmCoUu1AF
scopes:
- read_orders
- created_at: '2026-05-24T17:36:35.441Z'
- updated_at: '2026-05-24T17:36:35.441Z'
+ created_at: '2026-05-25T19:03:38.854Z'
+ updated_at: '2026-05-25T19:03:38.854Z'
revoked_at:
last_used_at:
- plaintext_token: sk_ryCceerpp5vqodztxueeWXmc
- created_by_email: [email protected]
+ plaintext_token: sk_rmCoUu1AFif9FBbzokNsPq6s
+ created_by_email: [email protected]
'422':
description: validation error
content:
@@ -499,11 +499,11 @@ paths:
key_type: publishable
token_prefix:
scopes: []
- created_at: '2026-05-24T17:36:35.723Z'
- updated_at: '2026-05-24T17:36:35.723Z'
+ created_at: '2026-05-25T19:03:39.136Z'
+ updated_at: '2026-05-25T19:03:39.136Z'
revoked_at:
last_used_at:
- plaintext_token: pk_yXJtU7SvnfLbkPvuuiUnKaEo
+ plaintext_token: pk_6Rr9GzApsPiynpq4GxmzkCjB
created_by_email:
delete:
summary: Delete an API key
@@ -593,12 +593,12 @@ paths:
id: key_gbHJdmfrXB
name: Backend integration
key_type: secret
- token_prefix: sk_q6euaWxod
+ token_prefix: sk_ZrsgB7yLr
scopes:
- write_all
- created_at: '2026-05-24T17:36:36.279Z'
- updated_at: '2026-05-24T17:36:36.554Z'
- revoked_at: '2026-05-24T17:36:36.553Z'
+ created_at: '2026-05-25T19:03:39.699Z'
+ updated_at: '2026-05-25T19:03:40.000Z'
+ revoked_at: '2026-05-25T19:03:39.998Z'
last_used_at:
plaintext_token:
created_by_email:
@@ -653,15 +653,15 @@ paths:
- id: coupon_UkLWZg9DAJ
code: AAA111
state: unused
- created_at: '2026-05-24T17:36:36.570Z'
- updated_at: '2026-05-24T17:36:36.570Z'
+ created_at: '2026-05-25T19:03:40.016Z'
+ updated_at: '2026-05-25T19:03:40.016Z'
promotion_id: promo_UkLWZg9DAJ
order_id:
- id: coupon_gbHJdmfrXB
code: BBB222
state: unused
- created_at: '2026-05-24T17:36:36.571Z'
- updated_at: '2026-05-24T17:36:36.571Z'
+ created_at: '2026-05-25T19:03:40.017Z'
+ updated_at: '2026-05-25T19:03:40.017Z'
promotion_id: promo_UkLWZg9DAJ
order_id:
meta:
@@ -739,8 +739,8 @@ paths:
field_type: short_text
resource_type: Spree::Product
storefront_visible: true
- created_at: '2026-05-24T17:36:36.857Z'
- updated_at: '2026-05-24T17:36:36.857Z'
+ created_at: '2026-05-25T19:03:40.309Z'
+ updated_at: '2026-05-25T19:03:40.309Z'
- id: cfdef_gbHJdmfrXB
namespace: custom
key: order_notes
@@ -748,8 +748,8 @@ paths:
field_type: short_text
resource_type: Spree::Order
storefront_visible: true
- created_at: '2026-05-24T17:36:36.857Z'
- updated_at: '2026-05-24T17:36:36.857Z'
+ created_at: '2026-05-25T19:03:40.310Z'
+ updated_at: '2026-05-25T19:03:40.310Z'
meta:
page: 1
limit: 25
@@ -812,8 +812,8 @@ paths:
field_type: short_text
resource_type: Spree::Product
storefront_visible: true
- created_at: '2026-05-24T17:36:37.407Z'
- updated_at: '2026-05-24T17:36:37.407Z'
+ created_at: '2026-05-25T19:03:40.868Z'
+ updated_at: '2026-05-25T19:03:40.868Z'
requestBody:
content:
application/json:
@@ -896,8 +896,8 @@ paths:
field_type: short_text
resource_type: Spree::Product
storefront_visible: true
- created_at: '2026-05-24T17:36:37.410Z'
- updated_at: '2026-05-24T17:36:37.410Z'
+ created_at: '2026-05-25T19:03:40.871Z'
+ updated_at: '2026-05-25T19:03:40.871Z'
patch:
summary: Update a custom field definition
tags:
@@ -936,8 +936,8 @@ paths:
field_type: short_text
resource_type: Spree::Product
storefront_visible: false
- created_at: '2026-05-24T17:36:37.685Z'
- updated_at: '2026-05-24T17:36:37.959Z'
+ created_at: '2026-05-25T19:03:41.147Z'
+ updated_at: '2026-05-25T19:03:41.422Z'
requestBody:
content:
application/json:
@@ -1061,14 +1061,14 @@ paths:
name: VIPs
description: Top spenders
customers_count: 0
- created_at: '2026-05-24T17:36:38.239Z'
- updated_at: '2026-05-24T17:36:38.239Z'
+ created_at: '2026-05-25T19:03:41.705Z'
+ updated_at: '2026-05-25T19:03:41.705Z'
- id: cg_gbHJdmfrXB
name: Wholesale
description:
customers_count: 0
- created_at: '2026-05-24T17:36:38.240Z'
- updated_at: '2026-05-24T17:36:38.240Z'
+ created_at: '2026-05-25T19:03:41.706Z'
+ updated_at: '2026-05-25T19:03:41.706Z'
meta:
page: 1
limit: 25
@@ -1153,8 +1153,8 @@ paths:
name: Wholesale 2
description: B2B accounts
customers_count: 1
- created_at: '2026-05-24T17:36:39.101Z'
- updated_at: '2026-05-24T17:36:39.101Z'
+ created_at: '2026-05-25T19:03:42.566Z'
+ updated_at: '2026-05-25T19:03:42.566Z'
schema:
"$ref": "#/components/schemas/CustomerGroup"
'422':
@@ -1260,24 +1260,24 @@ paths:
name: VIPs
description: Top spenders
customers_count: 1
- created_at: '2026-05-24T17:36:39.681Z'
- updated_at: '2026-05-24T17:36:39.681Z'
+ created_at: '2026-05-25T19:03:43.157Z'
+ updated_at: '2026-05-25T19:03:43.157Z'
customers:
- id: cus_UkLWZg9DAJ
- first_name: Janett
- last_name: Marvin
+ first_name: Cammie
+ last_name: Nicolas
phone:
accepts_email_marketing: false
- full_name: Janett Marvin
+ full_name: Cammie Nicolas
available_store_credit_total: '0'
display_available_store_credit_total: "$0.00"
metadata: {}
last_sign_in_at:
current_sign_in_at:
- created_at: '2026-05-24T17:36:39.940Z'
- updated_at: '2026-05-24T17:36:39.940Z'
+ created_at: '2026-05-25T19:03:43.418Z'
+ updated_at: '2026-05-25T19:03:43.418Z'
sign_in_count: 0
failed_attempts: 0
last_sign_in_ip:
@@ -1355,8 +1355,8 @@ paths:
name: VIP customers (Q1)
description: Top spenders
customers_count: 0
- created_at: '2026-05-24T17:36:40.533Z'
- updated_at: '2026-05-24T17:36:40.811Z'
+ created_at: '2026-05-25T19:03:43.991Z'
+ updated_at: '2026-05-25T19:03:44.265Z'
schema:
"$ref": "#/components/schemas/CustomerGroup"
'422':
@@ -1509,8 +1509,8 @@ paths:
state_name: New York
label:
metadata: {}
- created_at: '2026-05-24T17:36:41.658Z'
- updated_at: '2026-05-24T17:36:41.658Z'
+ created_at: '2026-05-25T19:03:45.099Z'
+ updated_at: '2026-05-25T19:03:45.099Z'
customer_id: cus_UkLWZg9DAJ
meta:
page: 1
@@ -1598,8 +1598,8 @@ paths:
state_name: New York
label: Office
metadata: {}
- created_at: '2026-05-24T17:36:43.149Z'
- updated_at: '2026-05-24T17:36:43.149Z'
+ created_at: '2026-05-25T19:03:46.463Z'
+ updated_at: '2026-05-25T19:03:46.463Z'
customer_id: cus_UkLWZg9DAJ
requestBody:
content:
@@ -1710,8 +1710,8 @@ paths:
state_name: New York
label:
metadata: {}
- created_at: '2026-05-24T17:36:43.466Z'
- updated_at: '2026-05-24T17:36:44.249Z'
+ created_at: '2026-05-25T19:03:46.734Z'
+ updated_at: '2026-05-25T19:03:47.299Z'
customer_id: cus_UkLWZg9DAJ
requestBody:
content:
@@ -1844,8 +1844,8 @@ paths:
customer_id: cus_UkLWZg9DAJ
payment_method_id: pm_UkLWZg9DAJ
metadata: {}
- created_at: '2026-05-24T17:36:45.523Z'
- updated_at: '2026-05-24T17:36:45.523Z'
+ created_at: '2026-05-25T19:03:48.447Z'
+ updated_at: '2026-05-25T19:03:48.447Z'
meta:
page: 1
limit: 25
@@ -1932,8 +1932,8 @@ paths:
customer_id: cus_UkLWZg9DAJ
payment_method_id: pm_UkLWZg9DAJ
metadata: {}
- created_at: '2026-05-24T17:36:46.077Z'
- updated_at: '2026-05-24T17:36:46.077Z'
+ created_at: '2026-05-25T19:03:49.025Z'
+ updated_at: '2026-05-25T19:03:49.025Z'
delete:
summary: Delete a customer credit card
tags:
@@ -2052,8 +2052,8 @@ paths:
currency: USD
memo:
metadata: {}
- created_at: '2026-05-24T17:36:47.452Z'
- updated_at: '2026-05-24T17:36:47.452Z'
+ created_at: '2026-05-25T19:03:50.414Z'
+ updated_at: '2026-05-25T19:03:50.414Z'
customer_id: cus_UkLWZg9DAJ
created_by_id: admin_UkLWZg9DAJ
category_id: sccat_UkLWZg9DAJ
@@ -2128,8 +2128,8 @@ paths:
currency: USD
memo: Goodwill
metadata: {}
- created_at: '2026-05-24T17:36:48.578Z'
- updated_at: '2026-05-24T17:36:48.578Z'
+ created_at: '2026-05-25T19:03:51.570Z'
+ updated_at: '2026-05-25T19:03:51.570Z'
customer_id: cus_UkLWZg9DAJ
created_by_id: admin_gbHJdmfrXB
category_id: sccat_UkLWZg9DAJ
@@ -2220,8 +2220,8 @@ paths:
currency: USD
memo: Updated
metadata: {}
- created_at: '2026-05-24T17:36:49.119Z'
- updated_at: '2026-05-24T17:36:49.399Z'
+ created_at: '2026-05-25T19:03:52.139Z'
+ updated_at: '2026-05-25T19:03:52.443Z'
customer_id: cus_UkLWZg9DAJ
created_by_id: admin_UkLWZg9DAJ
category_id: sccat_UkLWZg9DAJ
@@ -2375,8 +2375,8 @@ paths:
metadata: {}
last_sign_in_at:
current_sign_in_at:
- created_at: '2026-05-24T17:36:50.510Z'
- updated_at: '2026-05-24T17:36:50.510Z'
+ created_at: '2026-05-25T19:03:53.541Z'
+ updated_at: '2026-05-25T19:03:53.541Z'
sign_in_count: 0
failed_attempts: 0
last_sign_in_ip:
@@ -2459,8 +2459,8 @@ paths:
metadata: {}
last_sign_in_at:
current_sign_in_at:
- created_at: '2026-05-24T17:36:51.382Z'
- updated_at: '2026-05-24T17:36:51.382Z'
+ created_at: '2026-05-25T19:03:54.370Z'
+ updated_at: '2026-05-25T19:03:54.370Z'
sign_in_count: 0
failed_attempts: 0
last_sign_in_ip:
@@ -2576,8 +2576,8 @@ paths:
metadata: {}
last_sign_in_at:
current_sign_in_at:
- created_at: '2026-05-24T17:36:51.654Z'
- updated_at: '2026-05-24T17:36:51.654Z'
+ created_at: '2026-05-25T19:03:54.641Z'
+ updated_at: '2026-05-25T19:03:54.641Z'
sign_in_count: 0
failed_attempts: 0
last_sign_in_ip:
@@ -2651,8 +2651,8 @@ paths:
metadata: {}
last_sign_in_at:
current_sign_in_at:
- created_at: '2026-05-24T17:36:52.193Z'
- updated_at: '2026-05-24T17:36:52.471Z'
+ created_at: '2026-05-25T19:03:55.185Z'
+ updated_at: '2026-05-25T19:03:55.464Z'
sign_in_count: 0
failed_attempts: 0
last_sign_in_ip:
@@ -3082,11 +3082,11 @@ paths:
example:
data:
- id: exp_UkLWZg9DAJ
- number: EF797270070
+ number: EF168281244
type: Spree::Exports::Products
format: csv
- created_at: '2026-05-24T17:36:56.574Z'
- updated_at: '2026-05-24T17:36:56.574Z'
+ created_at: '2026-05-25T19:03:59.549Z'
+ updated_at: '2026-05-25T19:03:59.549Z'
user_id: admin_UkLWZg9DAJ
done: false
filename:
@@ -3153,11 +3153,11 @@ paths:
application/json:
example:
id: exp_gbHJdmfrXB
- number: EF700540072
+ number: EF913292887
type: Spree::Exports::Products
format: csv
- created_at: '2026-05-24T17:36:56.866Z'
- updated_at: '2026-05-24T17:36:56.866Z'
+ created_at: '2026-05-25T19:03:59.868Z'
+ updated_at: '2026-05-25T19:03:59.868Z'
user_id: admin_UkLWZg9DAJ
done: false
filename:
@@ -3244,11 +3244,11 @@ paths:
application/json:
example:
id: exp_UkLWZg9DAJ
- number: EF052905723
+ number: EF741996303
type: Spree::Exports::Products
format: csv
- created_at: '2026-05-24T17:36:57.139Z'
- updated_at: '2026-05-24T17:36:57.139Z'
+ created_at: '2026-05-25T19:04:00.140Z'
+ updated_at: '2026-05-25T19:04:00.140Z'
user_id: admin_UkLWZg9DAJ
done: false
filename:
@@ -3431,8 +3431,8 @@ paths:
codes_count: 2
currency: USD
prefix: WELCOME
- created_at: '2026-05-24T17:36:57.736Z'
- updated_at: '2026-05-24T17:36:57.736Z'
+ created_at: '2026-05-25T19:04:00.740Z'
+ updated_at: '2026-05-25T19:04:00.740Z'
amount: '50.0'
expires_at:
created_by_id:
@@ -3513,8 +3513,8 @@ paths:
codes_count: 5
currency: USD
prefix: NEWCAMP
- created_at: '2026-05-24T17:36:58.306Z'
- updated_at: '2026-05-24T17:36:58.306Z'
+ created_at: '2026-05-25T19:04:01.301Z'
+ updated_at: '2026-05-25T19:04:01.301Z'
amount: '25.0'
expires_at: '2030-12-31'
created_by_id: admin_UkLWZg9DAJ
@@ -3615,8 +3615,8 @@ paths:
codes_count: 2
currency: USD
prefix: WELCOME
- created_at: '2026-05-24T17:36:58.593Z'
- updated_at: '2026-05-24T17:36:58.593Z'
+ created_at: '2026-05-25T19:04:01.592Z'
+ updated_at: '2026-05-25T19:04:01.592Z'
amount: '50.0'
expires_at:
created_by_id:
@@ -3719,7 +3719,7 @@ paths:
example:
data:
- id: gc_UkLWZg9DAJ
- code: CC7B2B4D3AB3008C
+ code: 87D5F01BB0D0D24F
status: active
currency: USD
amount: '50.0'
@@ -3733,12 +3733,12 @@ paths:
redeemed_at:
expired: false
active: true
- created_at: '2026-05-24T17:36:59.157Z'
- updated_at: '2026-05-24T17:36:59.157Z'
+ created_at: '2026-05-25T19:04:02.161Z'
+ updated_at: '2026-05-25T19:04:02.161Z'
customer_id:
created_by_id:
- id: gc_gbHJdmfrXB
- code: DDB3EA9E5861FC28
+ code: 13282B2AA8873673
status: active
currency: USD
amount: '25.0'
@@ -3752,8 +3752,8 @@ paths:
redeemed_at:
expired: false
active: true
- created_at: '2026-05-24T17:36:59.158Z'
- updated_at: '2026-05-24T17:36:59.158Z'
+ created_at: '2026-05-25T19:04:02.162Z'
+ updated_at: '2026-05-25T19:04:02.162Z'
customer_id:
created_by_id:
meta:
@@ -3838,7 +3838,7 @@ paths:
application/json:
example:
id: gc_EfhxLZ9ck8
- code: A45E3AF0F74D82E8
+ code: 0BB8CA18901867D2
status: active
currency: USD
amount: '25.0'
@@ -3852,8 +3852,8 @@ paths:
redeemed_at:
expired: false
active: true
- created_at: '2026-05-24T17:36:59.731Z'
- updated_at: '2026-05-24T17:36:59.731Z'
+ created_at: '2026-05-25T19:04:02.732Z'
+ updated_at: '2026-05-25T19:04:02.732Z'
customer_id:
created_by_id: admin_UkLWZg9DAJ
schema:
@@ -3959,7 +3959,7 @@ paths:
application/json:
example:
id: gc_UkLWZg9DAJ
- code: 62E9760F39DB00B8
+ code: A8D6737DEBB081A9
status: active
currency: USD
amount: '50.0'
@@ -3973,8 +3973,8 @@ paths:
redeemed_at:
expired: false
active: true
- created_at: '2026-05-24T17:37:00.039Z'
- updated_at: '2026-05-24T17:37:00.039Z'
+ created_at: '2026-05-25T19:04:03.022Z'
+ updated_at: '2026-05-25T19:04:03.022Z'
customer_id:
created_by_id:
schema:
@@ -4034,7 +4034,7 @@ paths:
application/json:
example:
id: gc_UkLWZg9DAJ
- code: 80360376B43E9B35
+ code: 8D8176F6C0B59E6B
status: active
currency: USD
amount: '75.0'
@@ -4048,8 +4048,8 @@ paths:
redeemed_at:
expired: false
active: true
- created_at: '2026-05-24T17:37:00.647Z'
- updated_at: '2026-05-24T17:37:00.941Z'
+ created_at: '2026-05-25T19:04:03.609Z'
+ updated_at: '2026-05-25T19:04:03.886Z'
customer_id:
created_by_id:
schema:
@@ -4161,15 +4161,15 @@ paths:
example:
data:
- id: inv_UkLWZg9DAJ
status: pending
- created_at: '2026-05-24T17:37:01.802Z'
- updated_at: '2026-05-24T17:37:01.802Z'
- expires_at: '2026-06-07T17:37:01.798Z'
+ created_at: '2026-05-25T19:04:04.719Z'
+ updated_at: '2026-05-25T19:04:04.719Z'
+ expires_at: '2026-06-08T19:04:04.717Z'
role_id: role_UkLWZg9DAJ
role_name: admin
- inviter_email: [email protected]
- acceptance_url: "/accept-invitation/inv_UkLWZg9DAJ?token=zySacMBFavnzmtA9ZV4NQdhg"
+ inviter_email: [email protected]
+ acceptance_url: "/accept-invitation/inv_UkLWZg9DAJ?token=U3Ff8Bf2dQKhmysmeTzBhfmM"
invitee_exists: false
store:
id: store_UkLWZg9DAJ
@@ -4230,13 +4230,13 @@ paths:
id: inv_gbHJdmfrXB
status: pending
- created_at: '2026-05-24T17:37:02.111Z'
- updated_at: '2026-05-24T17:37:02.111Z'
- expires_at: '2026-06-07T17:37:02.108Z'
+ created_at: '2026-05-25T19:04:05.015Z'
+ updated_at: '2026-05-25T19:04:05.015Z'
+ expires_at: '2026-06-08T19:04:05.013Z'
role_id: role_UkLWZg9DAJ
role_name: admin
- inviter_email: [email protected]
- acceptance_url: "/accept-invitation/inv_gbHJdmfrXB?token=EzFbcPeHADJwGwapUkFjCjut"
+ inviter_email: [email protected]
+ acceptance_url: "/accept-invitation/inv_gbHJdmfrXB?token=fePPvxw9ZMV6MEnBpAz94PWr"
invitee_exists: false
store:
id: store_UkLWZg9DAJ
@@ -4343,19 +4343,193 @@ paths:
application/json:
example:
id: inv_UkLWZg9DAJ
status: pending
- created_at: '2026-05-24T17:37:02.736Z'
- updated_at: '2026-05-24T17:37:02.736Z'
- expires_at: '2026-06-07T17:37:02.733Z'
+ created_at: '2026-05-25T19:04:05.564Z'
+ updated_at: '2026-05-25T19:04:05.564Z'
+ expires_at: '2026-06-08T19:04:05.563Z'
role_id: role_UkLWZg9DAJ
role_name: admin
- inviter_email: [email protected]
- acceptance_url: "/accept-invitation/inv_UkLWZg9DAJ?token=KRTKCjz8LLoWUjxZrWFrAzKU"
+ inviter_email: [email protected]
+ acceptance_url: "/accept-invitation/inv_UkLWZg9DAJ?token=WNrcckqxoTLbdt8b32GDSXy3"
invitee_exists: false
store:
id: store_UkLWZg9DAJ
name: Spree Test Store
+ "/api/v3/admin/markets":
+ get:
+ summary: List markets
+ tags:
+ - Pricing
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: |-
+ Returns the markets configured for the current store. Read-only:
+ write surface lives in the legacy Rails admin pending the
+ Channel / Catalog rework (see `docs/plans/6.0-channels-catalogs-b2b.md`).
+
+
+ **Required scope:** `read_settings` (for API-key authentication).
+ x-codeSamples:
+ - lang: javascript
+ label: Spree Admin SDK
+ source: |-
+ import { createAdminClient } from '@spree/admin-sdk'
+
+ const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+ })
+
+ const { data: markets } = await client.markets.list()
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: page
+ in: query
+ required: false
+ schema:
+ type: integer
+ - name: limit
+ in: query
+ required: false
+ schema:
+ type: integer
+ - name: q[name_cont]
+ in: query
+ required: false
+ schema:
+ type: string
+ - name: sort
+ in: query
+ required: false
+ schema:
+ type: string
+ - name: expand
+ in: query
+ required: false
+ description: 'Comma-separated associations to embed. Supported: `countries`.'
+ schema:
+ type: string
+ responses:
+ '200':
+ description: markets found
+ content:
+ application/json:
+ example:
+ data:
+ - id: mkt_UkLWZg9DAJ
+ name: EU
+ currency: USD
+ default_locale: en
+ tax_inclusive: false
+ default: false
+ supported_locales:
+ - en
+ created_at: '2026-05-25T19:04:05.613Z'
+ updated_at: '2026-05-25T19:04:05.613Z'
+ meta:
+ page: 1
+ limit: 25
+ count: 1
+ pages: 1
+ from: 1
+ to: 1
+ in: 1
+ previous:
+ next:
+ schema:
+ type: object
+ properties:
+ data:
+ type: array
+ items:
+ "$ref": "#/components/schemas/Market"
+ meta:
+ "$ref": "#/components/schemas/PaginationMeta"
+ required:
+ - data
+ - meta
+ "/api/v3/admin/markets/{id}":
+ parameters:
+ - name: id
+ in: path
+ required: true
+ schema:
+ type: string
+ get:
+ summary: Get a market
+ tags:
+ - Pricing
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: "**Required scope:** `read_settings` (for API-key authentication)."
+ x-codeSamples:
+ - lang: javascript
+ label: Spree Admin SDK
+ source: |-
+ import { createAdminClient } from '@spree/admin-sdk'
+
+ const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+ })
+
+ const market = await client.markets.get('market_xxx')
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: expand
+ in: query
+ required: false
+ schema:
+ type: string
+ responses:
+ '200':
+ description: market found
+ content:
+ application/json:
+ example:
+ id: mkt_UkLWZg9DAJ
+ name: EU
+ currency: USD
+ default_locale: en
+ tax_inclusive: false
+ default: false
+ supported_locales:
+ - en
+ created_at: '2026-05-25T19:04:05.942Z'
+ updated_at: '2026-05-25T19:04:05.942Z'
+ schema:
+ "$ref": "#/components/schemas/Market"
+ '404':
+ description: market not found
+ content:
+ application/json:
+ example:
+ error:
+ code: record_not_found
+ message: Market not found
+ schema:
+ "$ref": "#/components/schemas/ErrorResponse"
"/api/v3/admin/me":
get:
summary: Get current admin user and permissions
@@ -4401,12 +4575,12 @@ paths:
example:
user:
id: admin_UkLWZg9DAJ
- first_name: Venessa
- last_name: Bechtelar
- full_name: Venessa Bechtelar
- created_at: '2026-05-24T17:37:03.068Z'
- updated_at: '2026-05-24T17:37:03.068Z'
+ first_name: Alix
+ last_name: Cormier
+ full_name: Alix Cormier
+ created_at: '2026-05-25T19:04:06.794Z'
+ updated_at: '2026-05-25T19:04:06.794Z'
roles:
- id: role_UkLWZg9DAJ
name: admin
@@ -4556,8 +4730,8 @@ paths:
kind: dropdown
metadata: {}
filterable: true
- created_at: '2026-05-24T17:37:03.133Z'
- updated_at: '2026-05-24T17:37:03.133Z'
+ created_at: '2026-05-25T19:04:06.835Z'
+ updated_at: '2026-05-25T19:04:06.835Z'
meta:
page: 1
limit: 25
@@ -4648,8 +4822,8 @@ paths:
kind: dropdown
metadata: {}
filterable: true
- created_at: '2026-05-24T17:37:03.722Z'
- updated_at: '2026-05-24T17:37:03.722Z'
+ created_at: '2026-05-25T19:04:07.413Z'
+ updated_at: '2026-05-25T19:04:07.413Z'
schema:
"$ref": "#/components/schemas/OptionType"
'422':
@@ -4770,8 +4944,8 @@ paths:
kind: dropdown
metadata: {}
filterable: true
- created_at: '2026-05-24T17:37:04.014Z'
- updated_at: '2026-05-24T17:37:04.014Z'
+ created_at: '2026-05-25T19:04:07.702Z'
+ updated_at: '2026-05-25T19:04:07.702Z'
schema:
"$ref": "#/components/schemas/OptionType"
'404':
@@ -4843,8 +5017,8 @@ paths:
kind: dropdown
metadata: {}
filterable: true
- created_at: '2026-05-24T17:37:04.617Z'
- updated_at: '2026-05-24T17:37:04.942Z'
+ created_at: '2026-05-25T19:04:08.266Z'
+ updated_at: '2026-05-25T19:04:08.546Z'
schema:
"$ref": "#/components/schemas/OptionType"
'422':
@@ -5003,7 +5177,7 @@ paths:
example:
data:
- id: ful_UkLWZg9DAJ
- number: H88303288332
+ number: H83621674503
tracking: U10000
tracking_url:
cost: '10.0'
@@ -5028,8 +5202,8 @@ paths:
metadata: {}
adjustment_total: '0.0'
pre_tax_amount: '0.0'
- created_at: '2026-05-24T17:37:06.032Z'
- updated_at: '2026-05-24T17:37:06.286Z'
+ created_at: '2026-05-25T19:04:09.505Z'
+ updated_at: '2026-05-25T19:04:09.570Z'
order_id: or_UkLWZg9DAJ
stock_location_id: sloc_UkLWZg9DAJ
meta:
@@ -5112,7 +5286,7 @@ paths:
application/json:
example:
id: ful_UkLWZg9DAJ
- number: H51674325797
+ number: H70407525674
tracking: U10000
tracking_url:
cost: '10.0'
@@ -5137,8 +5311,8 @@ paths:
metadata: {}
adjustment_total: '0.0'
pre_tax_amount: '0.0'
- created_at: '2026-05-24T17:37:07.105Z'
- updated_at: '2026-05-24T17:37:07.185Z'
+ created_at: '2026-05-25T19:04:10.193Z'
+ updated_at: '2026-05-25T19:04:10.259Z'
order_id: or_UkLWZg9DAJ
stock_location_id: sloc_UkLWZg9DAJ
patch:
@@ -5197,7 +5371,7 @@ paths:
application/json:
example:
id: ful_UkLWZg9DAJ
- number: H16091268662
+ number: H75251004587
tracking: 1Z999AA10123456784
tracking_url: https://wwwapps.ups.com/WebTracking/track?track=yes&trackNums=1Z999AA10123456784
cost: '10.0'
@@ -5222,8 +5396,8 @@ paths:
metadata: {}
adjustment_total: '0.0'
pre_tax_amount: '0.0'
- created_at: '2026-05-24T17:37:07.854Z'
- updated_at: '2026-05-24T17:37:08.221Z'
+ created_at: '2026-05-25T19:04:10.854Z'
+ updated_at: '2026-05-25T19:04:11.185Z'
order_id: or_UkLWZg9DAJ
stock_location_id: sloc_UkLWZg9DAJ
requestBody:
@@ -5292,7 +5466,7 @@ paths:
application/json:
example:
id: ful_UkLWZg9DAJ
- number: H47615606663
+ number: H47211209656
tracking: U10000
tracking_url:
cost: '10.0'
@@ -5309,7 +5483,7 @@ paths:
display_tax_total: "$0.00"
status: shipped
fulfillment_type: shipping
- fulfilled_at: '2026-05-24T17:37:08Z'
+ fulfilled_at: '2026-05-25T19:04:11Z'
items:
- item_id: li_UkLWZg9DAJ
variant_id: variant_UkLWZg9DAJ
@@ -5317,8 +5491,8 @@ paths:
metadata: {}
adjustment_total: '0.0'
pre_tax_amount: '0.0'
- created_at: '2026-05-24T17:37:08.572Z'
- updated_at: '2026-05-24T17:37:08.932Z'
+ created_at: '2026-05-25T19:04:11.493Z'
+ updated_at: '2026-05-25T19:04:11.840Z'
order_id: or_UkLWZg9DAJ
stock_location_id: sloc_UkLWZg9DAJ
"/api/v3/admin/orders/{order_id}/fulfillments/{id}/cancel":
@@ -5376,7 +5550,7 @@ paths:
application/json:
example:
id: ful_UkLWZg9DAJ
- number: H68010739823
+ number: H58682751279
tracking: U10000
tracking_url:
cost: '10.0'
@@ -5401,8 +5575,8 @@ paths:
metadata: {}
adjustment_total: '0.0'
pre_tax_amount: '0.0'
- created_at: '2026-05-24T17:37:09.263Z'
- updated_at: '2026-05-24T17:37:09.602Z'
+ created_at: '2026-05-25T19:04:12.164Z'
+ updated_at: '2026-05-25T19:04:12.508Z'
order_id: or_UkLWZg9DAJ
stock_location_id: sloc_UkLWZg9DAJ
"/api/v3/admin/orders/{order_id}/fulfillments/{id}/resume":
@@ -5460,7 +5634,7 @@ paths:
application/json:
example:
id: ful_UkLWZg9DAJ
- number: H15965565794
+ number: H41615282915
tracking: U10000
tracking_url:
cost: '10.0'
@@ -5485,8 +5659,8 @@ paths:
metadata: {}
adjustment_total: '0.0'
pre_tax_amount: '0.0'
- created_at: '2026-05-24T17:37:09.918Z'
- updated_at: '2026-05-24T17:37:10.280Z'
+ created_at: '2026-05-25T19:04:12.829Z'
+ updated_at: '2026-05-25T19:04:13.180Z'
order_id: or_UkLWZg9DAJ
stock_location_id: sloc_UkLWZg9DAJ
"/api/v3/admin/orders/{order_id}/fulfillments/{id}/split":
@@ -5547,7 +5721,7 @@ paths:
example:
data:
- id: ful_gbHJdmfrXB
- number: H74934116654
+ number: H41242832182
tracking:
tracking_url:
cost: '10.0'
@@ -5572,8 +5746,8 @@ paths:
metadata: {}
adjustment_total: '0.0'
pre_tax_amount: '0.0'
- created_at: '2026-05-24T17:37:10.976Z'
- updated_at: '2026-05-24T17:37:11.028Z'
+ created_at: '2026-05-25T19:04:13.876Z'
+ updated_at: '2026-05-25T19:04:13.923Z'
order_id: or_UkLWZg9DAJ
stock_location_id: sloc_gbHJdmfrXB
requestBody:
@@ -5645,7 +5819,7 @@ paths:
application/json:
example:
id: gc_UkLWZg9DAJ
- code: 0F0327B1613F79BD
+ code: 73E9905C2F1D246C
status: active
currency: USD
amount: '10.0'
@@ -5659,8 +5833,8 @@ paths:
redeemed_at:
expired: false
active: true
- created_at: '2026-05-24T17:37:11.389Z'
- updated_at: '2026-05-24T17:37:11.722Z'
+ created_at: '2026-05-25T19:04:14.259Z'
+ updated_at: '2026-05-25T19:04:14.559Z'
customer_id:
created_by_id:
requestBody:
@@ -5793,8 +5967,8 @@ paths:
variant_id: variant_gbHJdmfrXB
quantity: 2
currency: USD
- name: Product 106366
- slug: product-106366
+ name: Product 108069
+ slug: product-108069
options_text: 'Size: S'
price: '10.0'
display_price: "$10.00"
@@ -5826,12 +6000,12 @@ paths:
option_type_label: Size
image_url:
metadata: {}
- created_at: '2026-05-24T17:37:12.441Z'
- updated_at: '2026-05-24T17:37:12.441Z'
+ created_at: '2026-05-25T19:04:15.243Z'
+ updated_at: '2026-05-25T19:04:15.243Z'
digital_links: []
metadata: {}
- created_at: '2026-05-24T17:37:12.736Z'
- updated_at: '2026-05-24T17:37:12.736Z'
+ created_at: '2026-05-25T19:04:15.528Z'
+ updated_at: '2026-05-25T19:04:15.528Z'
cost_price: '17.0'
tax_category_id: taxcat_UkLWZg9DAJ
meta:
@@ -5898,8 +6072,8 @@ paths:
variant_id: variant_VqXmZF31wY
quantity: 3
currency: USD
- name: Product 12521
- slug: product-12521
+ name: Product 125746
+ slug: product-125746
options_text: 'Size: S'
price: '19.99'
display_price: "$19.99"
@@ -5931,12 +6105,12 @@ paths:
option_type_label: Size
image_url:
metadata: {}
- created_at: '2026-05-24T17:37:13.688Z'
- updated_at: '2026-05-24T17:37:13.688Z'
+ created_at: '2026-05-25T19:04:16.437Z'
+ updated_at: '2026-05-25T19:04:16.437Z'
digital_links: []
metadata: {}
- created_at: '2026-05-24T17:37:13.721Z'
- updated_at: '2026-05-24T17:37:13.721Z'
+ created_at: '2026-05-25T19:04:16.478Z'
+ updated_at: '2026-05-25T19:04:16.478Z'
cost_price: '17.0'
tax_category_id: taxcat_UkLWZg9DAJ
requestBody:
@@ -6025,8 +6199,8 @@ paths:
variant_id: variant_gbHJdmfrXB
quantity: 2
currency: USD
- name: Product 131812
- slug: product-131812
+ name: Product 134328
+ slug: product-134328
options_text: 'Size: S'
price: '10.0'
display_price: "$10.00"
@@ -6058,12 +6232,12 @@ paths:
option_type_label: Size
image_url:
metadata: {}
- created_at: '2026-05-24T17:37:13.789Z'
- updated_at: '2026-05-24T17:37:13.789Z'
+ created_at: '2026-05-25T19:04:16.552Z'
+ updated_at: '2026-05-25T19:04:16.552Z'
digital_links: []
metadata: {}
- created_at: '2026-05-24T17:37:14.071Z'
- updated_at: '2026-05-24T17:37:14.071Z'
+ created_at: '2026-05-25T19:04:16.835Z'
+ updated_at: '2026-05-25T19:04:16.835Z'
cost_price: '17.0'
tax_category_id: taxcat_UkLWZg9DAJ
patch:
@@ -6125,8 +6299,8 @@ paths:
variant_id: variant_gbHJdmfrXB
quantity: 5
currency: USD
- name: Product 143486
- slug: product-143486
+ name: Product 146043
+ slug: product-146043
options_text: 'Size: S'
price: '19.99'
display_price: "$19.99"
@@ -6158,12 +6332,12 @@ paths:
option_type_label: Size
image_url:
metadata: {}
- created_at: '2026-05-24T17:37:14.389Z'
- updated_at: '2026-05-24T17:37:14.389Z'
+ created_at: '2026-05-25T19:04:17.158Z'
+ updated_at: '2026-05-25T19:04:17.158Z'
digital_links: []
metadata: {}
- created_at: '2026-05-24T17:37:14.684Z'
- updated_at: '2026-05-24T17:37:15.018Z'
+ created_at: '2026-05-25T19:04:17.446Z'
+ updated_at: '2026-05-25T19:04:17.742Z'
cost_price: '17.0'
tax_category_id: taxcat_UkLWZg9DAJ
requestBody:
@@ -6289,8 +6463,8 @@ paths:
data:
- id: py_UkLWZg9DAJ
payment_method_id: pm_UkLWZg9DAJ
- response_code: BGS-ab886544a797
- number: PFOT94SE
+ response_code: BGS-3ece195ef92b
+ number: PLFNF8W9
amount: '110.0'
display_amount: "$110.00"
status: completed
@@ -6308,14 +6482,14 @@ paths:
customer_id:
payment_method_id: pm_gbHJdmfrXB
metadata: {}
- created_at: '2026-05-24T17:37:16.011Z'
- updated_at: '2026-05-24T17:37:16.014Z'
+ created_at: '2026-05-25T19:04:18.741Z'
+ updated_at: '2026-05-25T19:04:18.744Z'
metadata: {}
avs_response:
cvv_response_code:
cvv_response_message:
- created_at: '2026-05-24T17:37:16.013Z'
- updated_at: '2026-05-24T17:37:16.013Z'
+ created_at: '2026-05-25T19:04:18.743Z'
+ updated_at: '2026-05-25T19:04:18.743Z'
captured_amount: '0.0'
order_id: or_UkLWZg9DAJ
meta:
@@ -6382,7 +6556,7 @@ paths:
id: py_gbHJdmfrXB
payment_method_id: pm_EfhxLZ9ck8
response_code:
- number: PY1TKFJ5
+ number: PF9XNZOK
amount: '110.0'
display_amount: "$110.00"
status: checkout
@@ -6393,8 +6567,8 @@ paths:
avs_response:
cvv_response_code:
cvv_response_message:
- created_at: '2026-05-24T17:37:17.285Z'
- updated_at: '2026-05-24T17:37:17.285Z'
+ created_at: '2026-05-25T19:04:20.060Z'
+ updated_at: '2026-05-25T19:04:20.060Z'
captured_amount: '0.0'
order_id: or_gbHJdmfrXB
requestBody:
@@ -6484,8 +6658,8 @@ paths:
example:
id: py_UkLWZg9DAJ
payment_method_id: pm_UkLWZg9DAJ
- response_code: BGS-ecd6e3a829e6
- number: P6DLMTIN
+ response_code: BGS-097c72fbdafa
+ number: PVJS99Y7
amount: '110.0'
display_amount: "$110.00"
status: completed
@@ -6503,14 +6677,14 @@ paths:
customer_id:
payment_method_id: pm_gbHJdmfrXB
metadata: {}
- created_at: '2026-05-24T17:37:17.639Z'
- updated_at: '2026-05-24T17:37:17.642Z'
+ created_at: '2026-05-25T19:04:20.423Z'
+ updated_at: '2026-05-25T19:04:20.426Z'
metadata: {}
avs_response:
cvv_response_code:
cvv_response_message:
- created_at: '2026-05-24T17:37:17.641Z'
- updated_at: '2026-05-24T17:37:17.641Z'
+ created_at: '2026-05-25T19:04:20.425Z'
+ updated_at: '2026-05-25T19:04:20.425Z'
captured_amount: '0.0'
order_id: or_UkLWZg9DAJ
"/api/v3/admin/orders/{order_id}/payments/{id}/capture":
@@ -6569,8 +6743,8 @@ paths:
example:
id: py_UkLWZg9DAJ
payment_method_id: pm_UkLWZg9DAJ
- response_code: BGS-6e39b35672d4
- number: PJJ3CQHY
+ response_code: BGS-f1bc88b29118
+ number: P84XH1SZ
amount: '110.0'
display_amount: "$110.00"
status: completed
@@ -6588,14 +6762,14 @@ paths:
customer_id:
payment_method_id: pm_gbHJdmfrXB
metadata: {}
- created_at: '2026-05-24T17:37:18.265Z'
- updated_at: '2026-05-24T17:37:18.268Z'
+ created_at: '2026-05-25T19:04:21.070Z'
+ updated_at: '2026-05-25T19:04:21.072Z'
metadata: {}
avs_response:
cvv_response_code:
cvv_response_message:
- created_at: '2026-05-24T17:37:18.267Z'
- updated_at: '2026-05-24T17:37:18.596Z'
+ created_at: '2026-05-25T19:04:21.071Z'
+ updated_at: '2026-05-25T19:04:21.416Z'
captured_amount: '110.0'
order_id: or_UkLWZg9DAJ
'422':
@@ -6664,8 +6838,8 @@ paths:
example:
id: py_UkLWZg9DAJ
payment_method_id: pm_UkLWZg9DAJ
- response_code: void-BGS-f655707373af
- number: PYU6OBOS
+ response_code: void-BGS-b89f3f6ea6fb
+ number: PGIXCHU8
amount: '110.0'
display_amount: "$110.00"
status: void
@@ -6683,14 +6857,14 @@ paths:
customer_id:
payment_method_id: pm_gbHJdmfrXB
metadata: {}
- created_at: '2026-05-24T17:37:19.623Z'
- updated_at: '2026-05-24T17:37:19.625Z'
+ created_at: '2026-05-25T19:04:22.506Z'
+ updated_at: '2026-05-25T19:04:22.508Z'
metadata: {}
avs_response:
cvv_response_code:
cvv_response_message:
- created_at: '2026-05-24T17:37:19.624Z'
- updated_at: '2026-05-24T17:37:19.923Z'
+ created_at: '2026-05-25T19:04:22.507Z'
+ updated_at: '2026-05-25T19:04:22.805Z'
captured_amount: '0.0'
order_id: or_UkLWZg9DAJ
"/api/v3/admin/orders/{order_id}/refunds":
@@ -6818,14 +6992,14 @@ paths:
application/json:
example:
id: re_UkLWZg9DAJ
- transaction_id: BGS-71407c2949ff
+ transaction_id: BGS-20078f8c4615
amount: '5.0'
payment_id: py_UkLWZg9DAJ
refund_reason_id: rr_UkLWZg9DAJ
reimbursement_id:
metadata: {}
- created_at: '2026-05-24T17:37:21.214Z'
- updated_at: '2026-05-24T17:37:21.214Z'
+ created_at: '2026-05-25T19:04:24.162Z'
+ updated_at: '2026-05-25T19:04:24.162Z'
requestBody:
content:
application/json:
@@ -6897,8 +7071,8 @@ paths:
id: or_UkLWZg9DAJ
market_id:
channel_id: ch_UkLWZg9DAJ
- number: R479485011
+ number: R068431070
customer_note:
currency: USD
locale: en
@@ -6941,8 +7115,8 @@ paths:
metadata: {}
canceled_at:
approved_at:
- created_at: '2026-05-24T17:37:21.511Z'
- updated_at: '2026-05-24T17:37:21.557Z'
+ created_at: '2026-05-25T19:04:24.459Z'
+ updated_at: '2026-05-25T19:04:24.517Z'
preferred_stock_location_id:
tags: []
internal_note:
@@ -7113,8 +7287,8 @@ paths:
- id: or_UkLWZg9DAJ
market_id:
channel_id: ch_UkLWZg9DAJ
- number: R977527427
+ number: R735314054
customer_note:
currency: USD
locale: en
@@ -7157,8 +7331,8 @@ paths:
metadata: {}
canceled_at:
approved_at:
- created_at: '2026-05-24T17:37:23.272Z'
- updated_at: '2026-05-24T17:37:23.272Z'
+ created_at: '2026-05-25T19:04:26.257Z'
+ updated_at: '2026-05-25T19:04:26.257Z'
preferred_stock_location_id:
tags: []
internal_note:
@@ -7301,7 +7475,7 @@ paths:
id: or_gbHJdmfrXB
market_id:
channel_id: ch_UkLWZg9DAJ
- number: R518772568
+ number: R333487155
customer_note:
currency: USD
@@ -7345,8 +7519,8 @@ paths:
metadata: {}
canceled_at:
approved_at:
- created_at: '2026-05-24T17:37:24.939Z'
- updated_at: '2026-05-24T17:37:24.942Z'
+ created_at: '2026-05-25T19:04:27.940Z'
+ updated_at: '2026-05-25T19:04:27.943Z'
preferred_stock_location_id: sloc_UkLWZg9DAJ
tags: []
internal_note:
@@ -7530,8 +7704,8 @@ paths:
id: or_UkLWZg9DAJ
market_id:
channel_id: ch_UkLWZg9DAJ
- number: R351185598
+ number: R936227067
customer_note:
currency: USD
locale: en
@@ -7574,8 +7748,8 @@ paths:
metadata: {}
canceled_at:
approved_at:
- created_at: '2026-05-24T17:37:25.214Z'
- updated_at: '2026-05-24T17:37:25.214Z'
+ created_at: '2026-05-25T19:04:28.215Z'
+ updated_at: '2026-05-25T19:04:28.215Z'
preferred_stock_location_id:
tags: []
internal_note:
@@ -7646,7 +7820,7 @@ paths:
id: or_UkLWZg9DAJ
market_id:
channel_id: ch_UkLWZg9DAJ
- number: R963129287
+ number: R121358504
customer_note:
currency: USD
@@ -7690,8 +7864,8 @@ paths:
metadata: {}
canceled_at:
approved_at:
- created_at: '2026-05-24T17:37:26.302Z'
- updated_at: '2026-05-24T17:37:26.584Z'
+ created_at: '2026-05-25T19:04:29.315Z'
+ updated_at: '2026-05-25T19:04:29.599Z'
preferred_stock_location_id:
tags: []
internal_note:
@@ -7872,8 +8046,8 @@ paths:
id: or_UkLWZg9DAJ
market_id:
channel_id: ch_UkLWZg9DAJ
- number: R325816233
+ number: R908661878
customer_note:
currency: USD
locale: en
@@ -7900,7 +8074,7 @@ paths:
display_delivery_total: "$100.00"
fulfillment_status: ready
payment_status: paid
- completed_at: '2026-05-24T17:37:27.485Z'
+ completed_at: '2026-05-25T19:04:30.505Z'
store_credit_total: '0.0'
display_store_credit_total: "$0.00"
covered_by_store_credit: false
@@ -7916,8 +8090,8 @@ paths:
metadata: {}
canceled_at:
approved_at:
- created_at: '2026-05-24T17:37:27.437Z'
- updated_at: '2026-05-24T17:37:27.507Z'
+ created_at: '2026-05-25T19:04:30.459Z'
+ updated_at: '2026-05-25T19:04:30.527Z'
preferred_stock_location_id:
tags: []
internal_note:
@@ -7998,8 +8172,8 @@ paths:
id: or_UkLWZg9DAJ
market_id:
channel_id: ch_UkLWZg9DAJ
- number: R715045671
+ number: R902515776
customer_note:
currency: USD
locale: en
@@ -8026,7 +8200,7 @@ paths:
display_delivery_total: "$10.00"
fulfillment_status: canceled
payment_status: void
- completed_at: '2026-05-24T17:37:28.733Z'
+ completed_at: '2026-05-25T19:04:31.771Z'
store_credit_total: '0.0'
display_store_credit_total: "$0.00"
covered_by_store_credit: false
@@ -8040,10 +8214,10 @@ paths:
payment_total: '0.0'
display_payment_total: "$0.00"
metadata: {}
- canceled_at: '2026-05-24T17:37:29.026Z'
+ canceled_at: '2026-05-25T19:04:32.064Z'
approved_at:
- created_at: '2026-05-24T17:37:28.686Z'
- updated_at: '2026-05-24T17:37:29.069Z'
+ created_at: '2026-05-25T19:04:31.709Z'
+ updated_at: '2026-05-25T19:04:32.107Z'
preferred_stock_location_id:
tags: []
internal_note:
@@ -8102,8 +8276,8 @@ paths:
id: or_UkLWZg9DAJ
market_id:
channel_id: ch_UkLWZg9DAJ
- number: R801788034
+ number: R224402224
customer_note:
currency: USD
locale: en
@@ -8130,7 +8304,7 @@ paths:
display_delivery_total: "$100.00"
fulfillment_status:
payment_status:
- completed_at: '2026-05-24T17:37:29.425Z'
+ completed_at: '2026-05-25T19:04:32.458Z'
store_credit_total: '0.0'
display_store_credit_total: "$0.00"
covered_by_store_credit: false
@@ -8145,9 +8319,9 @@ paths:
display_payment_total: "$0.00"
metadata: {}
canceled_at:
- approved_at: '2026-05-24T17:37:29.716Z'
- created_at: '2026-05-24T17:37:29.365Z'
- updated_at: '2026-05-24T17:37:29.425Z'
+ approved_at: '2026-05-25T19:04:32.747Z'
+ created_at: '2026-05-25T19:04:32.407Z'
+ updated_at: '2026-05-25T19:04:32.458Z'
preferred_stock_location_id:
tags: []
internal_note:
@@ -8206,8 +8380,8 @@ paths:
id: or_UkLWZg9DAJ
market_id:
channel_id: ch_UkLWZg9DAJ
- number: R074770237
+ number: R580040222
customer_note:
currency: USD
locale: en
@@ -8234,7 +8408,7 @@ paths:
display_delivery_total: "$10.00"
fulfillment_status: canceled
payment_status: void
- completed_at: '2026-05-24T17:37:30.041Z'
+ completed_at: '2026-05-25T19:04:33.084Z'
store_credit_total: '0.0'
display_store_credit_total: "$0.00"
covered_by_store_credit: false
@@ -8248,10 +8422,10 @@ paths:
payment_total: '0.0'
display_payment_total: "$0.00"
metadata: {}
- canceled_at: '2026-05-24T17:37:30.319Z'
+ canceled_at: '2026-05-25T19:04:33.362Z'
approved_at:
- created_at: '2026-05-24T17:37:29.994Z'
- updated_at: '2026-05-24T17:37:30.411Z'
+ created_at: '2026-05-25T19:04:33.031Z'
+ updated_at: '2026-05-25T19:04:33.439Z'
preferred_stock_location_id:
tags: []
internal_note:
@@ -8310,8 +8484,8 @@ paths:
id: or_UkLWZg9DAJ
market_id:
channel_id: ch_UkLWZg9DAJ
- number: R726922313
+ number: R160629193
customer_note:
currency: USD
locale: en
@@ -8338,7 +8512,7 @@ paths:
display_delivery_total: "$100.00"
fulfillment_status:
payment_status:
- completed_at: '2026-05-24T17:37:30.745Z'
+ completed_at: '2026-05-25T19:04:33.776Z'
store_credit_total: '0.0'
display_store_credit_total: "$0.00"
covered_by_store_credit: false
@@ -8354,8 +8528,8 @@ paths:
metadata: {}
canceled_at:
approved_at:
- created_at: '2026-05-24T17:37:30.693Z'
- updated_at: '2026-05-24T17:37:30.745Z'
+ created_at: '2026-05-25T19:04:33.722Z'
+ updated_at: '2026-05-25T19:04:33.776Z'
preferred_stock_location_id:
tags: []
internal_note:
@@ -8413,49 +8587,1150 @@ paths:
schema:
type: string
responses:
- '200':
- description: payment methods found
- content:
- application/json:
- example:
- data:
- - id: pm_UkLWZg9DAJ
- name: Check
- description:
- type: check
- session_required: false
- source_required: false
- metadata: {}
- active: true
- auto_capture:
- storefront_visible: true
- position: 1
- created_at: '2026-05-24T17:37:31.151Z'
- updated_at: '2026-05-24T17:37:31.153Z'
- preferences: {}
- preference_schema: []
- meta:
- page: 1
- limit: 25
- count: 1
- pages: 1
- from: 1
- to: 1
- in: 1
- previous:
- next:
- "/api/v3/admin/payment_methods/types":
- get:
- summary: List available payment provider types
+ '200':
+ description: payment methods found
+ content:
+ application/json:
+ example:
+ data:
+ - id: pm_UkLWZg9DAJ
+ name: Check
+ description:
+ type: check
+ session_required: false
+ source_required: false
+ metadata: {}
+ active: true
+ auto_capture:
+ storefront_visible: true
+ position: 1
+ created_at: '2026-05-25T19:04:34.075Z'
+ updated_at: '2026-05-25T19:04:34.076Z'
+ preferences: {}
+ preference_schema: []
+ meta:
+ page: 1
+ limit: 25
+ count: 1
+ pages: 1
+ from: 1
+ to: 1
+ in: 1
+ previous:
+ next:
+ "/api/v3/admin/payment_methods/types":
+ get:
+ summary: List available payment provider types
+ tags:
+ - Configuration
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: |-
+ Returns the registered Spree::PaymentMethod subclasses that can be used to create new payment methods. Useful for populating a "Provider" dropdown in admin UIs.
+
+ **Required scope:** `read_settings` (for API-key authentication).
+ x-codeSamples:
+ - lang: javascript
+ label: Spree Admin SDK
+ source: |-
+ import { createAdminClient } from '@spree/admin-sdk'
+
+ const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+ })
+
+ const { data: types } = await client.paymentMethods.types()
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ schema:
+ type: string
+ responses:
+ '200':
+ description: provider types found
+ content:
+ application/json:
+ example:
+ data:
+ - type: bogus
+ label: Bogus
+ description:
+ preference_schema:
+ - key: dummy_key
+ type: string
+ default: PUBLICKEY123
+ - key: dummy_secret_key
+ type: password
+ default:
+ - type: custom_payment_source_method
+ label: Custom Payment Source Method
+ description:
+ preference_schema: []
+ "/api/v3/admin/payment_methods/{id}":
+ get:
+ summary: Show a payment method
+ tags:
+ - Configuration
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: |-
+ Returns a payment method by ID.
+
+ **Required scope:** `read_settings` (for API-key authentication).
+ x-codeSamples:
+ - lang: javascript
+ label: Spree Admin SDK
+ source: |-
+ import { createAdminClient } from '@spree/admin-sdk'
+
+ const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+ })
+
+ const paymentMethod = await client.paymentMethods.get('pm_UkLWZg9DAJ')
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: id
+ in: path
+ required: true
+ schema:
+ type: string
+ - name: expand
+ in: query
+ required: false
+ description: Comma-separated associations to expand. Use dot notation for
+ nested expand (max 4 levels).
+ schema:
+ type: string
+ - name: fields
+ in: query
+ required: false
+ description: Comma-separated list of fields to include (e.g., name,type,active).
+ id is always included.
+ schema:
+ type: string
+ responses:
+ '200':
+ description: payment method found
+ content:
+ application/json:
+ example:
+ id: pm_UkLWZg9DAJ
+ name: Check
+ description:
+ type: check
+ session_required: false
+ source_required: false
+ metadata: {}
+ active: true
+ auto_capture:
+ storefront_visible: true
+ position: 1
+ created_at: '2026-05-25T19:04:34.649Z'
+ updated_at: '2026-05-25T19:04:34.650Z'
+ preferences: {}
+ preference_schema: []
+ "/api/v3/admin/price_lists":
+ get:
+ summary: List price lists
+ tags:
+ - Pricing
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: |-
+ Returns the price lists configured for the current store.
+
+ **Required scope:** `read_products` (for API-key authentication).
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: page
+ in: query
+ required: false
+ schema:
+ type: integer
+ - name: limit
+ in: query
+ required: false
+ schema:
+ type: integer
+ - name: q[name_cont]
+ in: query
+ required: false
+ schema:
+ type: string
+ - name: q[status_eq]
+ in: query
+ required: false
+ schema:
+ type: string
+ - name: sort
+ in: query
+ required: false
+ schema:
+ type: string
+ - name: expand
+ in: query
+ required: false
+ description: 'Comma-separated associations to embed. Supported: `price_rules`.'
+ schema:
+ type: string
+ responses:
+ '200':
+ description: price lists found
+ content:
+ application/json:
+ example:
+ data:
+ - id: pl_UkLWZg9DAJ
+ name: Wholesale
+ description:
+ status: draft
+ position: 1
+ match_policy: all
+ starts_at:
+ ends_at:
+ created_at: '2026-05-25T19:04:34.943Z'
+ updated_at: '2026-05-25T19:04:34.943Z'
+ currently_active: false
+ products_count: 0
+ prices_count: 0
+ product_ids: []
+ - id: pl_gbHJdmfrXB
+ name: Holiday
+ description:
+ status: draft
+ position: 2
+ match_policy: all
+ starts_at:
+ ends_at:
+ created_at: '2026-05-25T19:04:34.944Z'
+ updated_at: '2026-05-25T19:04:34.944Z'
+ currently_active: false
+ products_count: 0
+ prices_count: 0
+ product_ids: []
+ meta:
+ page: 1
+ limit: 25
+ count: 2
+ pages: 1
+ from: 1
+ to: 2
+ in: 2
+ previous:
+ next:
+ schema:
+ type: object
+ properties:
+ data:
+ type: array
+ items:
+ "$ref": "#/components/schemas/PriceList"
+ meta:
+ "$ref": "#/components/schemas/PaginationMeta"
+ required:
+ - data
+ - meta
+ post:
+ summary: Create a price list
+ tags:
+ - Pricing
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: |-
+ Creates a new draft price list.
+
+ **Required scope:** `write_products` (for API-key authentication).
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ schema:
+ type: string
+ responses:
+ '201':
+ description: price list created (server-to-server — rules + prices, no product_ids)
+ content:
+ application/json:
+ example:
+ id: pl_EfhxLZ9ck8
+ name: EU wholesale
+ description:
+ status: draft
+ position: 3
+ match_policy: all
+ starts_at:
+ ends_at:
+ created_at: '2026-05-25T19:04:35.982Z'
+ updated_at: '2026-05-25T19:04:35.984Z'
+ currently_active: false
+ products_count: 1
+ prices_count: 2
+ product_ids:
+ - prod_UkLWZg9DAJ
+ schema:
+ "$ref": "#/components/schemas/PriceList"
+ '422':
+ description: validation error
+ content:
+ application/json:
+ example:
+ error:
+ code: validation_error
+ message: Name can't be blank
+ details:
+ name:
+ - can't be blank
+ schema:
+ "$ref": "#/components/schemas/ErrorResponse"
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: object
+ required:
+ - name
+ properties:
+ name:
+ type: string
+ example: EU wholesale
+ description:
+ type: string
+ nullable: true
+ starts_at:
+ type: string
+ nullable: true
+ example: '2026-06-01T00:00:00Z'
+ ends_at:
+ type: string
+ nullable: true
+ example: '2026-09-01T00:00:00Z'
+ match_policy:
+ type: string
+ enum:
+ - all
+ - any
+ example: all
+ position:
+ type: integer
+ example: 1
+ product_ids:
+ type: array
+ items:
+ type: string
+ description: Prefixed product ids to seed the list with.
+ example:
+ - prod_aBc123
+ rules:
+ type: array
+ description: STI-typed price rules to attach on create. Existing
+ rules on the same payload via PATCH reconcile by id.
+ items:
+ type: object
+ required:
+ - type
+ properties:
+ type:
+ type: string
+ example: volume_rule
+ preferences:
+ type: object
+ additionalProperties: true
+ prices:
+ type: array
+ description: 'Server-to-server alternative to `product_ids`: ship
+ the exact per-variant prices the list should contain. Each row
+ upserts on the unique key `(variant_id, currency, price_list_id)`.
+ Mix-and-match with `product_ids` is supported but typically unnecessary
+ — `prices` alone tells the server which variants belong to the
+ list and what the override amount is.'
+ items:
+ type: object
+ required:
+ - variant_id
+ - currency
+ properties:
+ variant_id:
+ type: string
+ example: variant_xY9
+ currency:
+ type: string
+ example: USD
+ amount:
+ type: string
+ nullable: true
+ example: '19.99'
+ compare_at_amount:
+ type: string
+ nullable: true
+ example: '24.99'
+ "/api/v3/admin/price_lists/{id}":
+ parameters:
+ - name: id
+ in: path
+ required: true
+ schema:
+ type: string
+ get:
+ summary: Get a price list
+ tags:
+ - Pricing
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: "**Required scope:** `read_products` (for API-key authentication)."
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: expand
+ in: query
+ required: false
+ schema:
+ type: string
+ responses:
+ '200':
+ description: price list found
+ content:
+ application/json:
+ example:
+ id: pl_UkLWZg9DAJ
+ name: Wholesale
+ description:
+ status: draft
+ position: 1
+ match_policy: all
+ starts_at:
+ ends_at:
+ created_at: '2026-05-25T19:04:36.293Z'
+ updated_at: '2026-05-25T19:04:36.293Z'
+ currently_active: false
+ products_count: 0
+ prices_count: 0
+ product_ids: []
+ schema:
+ "$ref": "#/components/schemas/PriceList"
+ '404':
+ description: price list not found
+ content:
+ application/json:
+ example:
+ error:
+ code: record_not_found
+ message: Price list not found
+ schema:
+ "$ref": "#/components/schemas/ErrorResponse"
+ patch:
+ summary: Update a price list
+ tags:
+ - Pricing
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: |-
+ Updates a price list. The optional `rules:` array reconciles nested
+ STI-typed price rules in a single round-trip — existing rules update
+ by `id`, new rules build, missing rules destroy. Mirrors the
+ promotion editor's "save the whole thing on Save" pattern.
+
+
+ **Required scope:** `write_products` (for API-key authentication).
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ schema:
+ type: string
+ responses:
+ '200':
+ description: price list updated with nested rules
+ content:
+ application/json:
+ example:
+ id: pl_UkLWZg9DAJ
+ name: Wholesale (Q3)
+ description:
+ status: draft
+ position: 1
+ match_policy: all
+ starts_at:
+ ends_at:
+ created_at: '2026-05-25T19:04:37.933Z'
+ updated_at: '2026-05-25T19:04:38.228Z'
+ currently_active: false
+ products_count: 0
+ prices_count: 0
+ product_ids: []
+ schema:
+ "$ref": "#/components/schemas/PriceList"
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ name:
+ type: string
+ description:
+ type: string
+ nullable: true
+ starts_at:
+ type: string
+ nullable: true
+ ends_at:
+ type: string
+ nullable: true
+ match_policy:
+ type: string
+ enum:
+ - all
+ - any
+ position:
+ type: integer
+ product_ids:
+ type: array
+ items:
+ type: string
+ description: Prefixed product ids — reconciles list membership (adds
+ + removes).
+ example:
+ - prod_aBc123
+ rules:
+ type: array
+ items:
+ type: object
+ required:
+ - type
+ properties:
+ id:
+ type: string
+ nullable: true
+ type:
+ type: string
+ example: volume_rule
+ preferences:
+ type: object
+ additionalProperties: true
+ prices:
+ type: array
+ description: Individual price overrides (the spreadsheet payload).
+ Each row updates an existing Price by `id`; unchanged rows are
+ no-ops server-side.
+ items:
+ type: object
+ required:
+ - id
+ properties:
+ id:
+ type: string
+ example: price_aBc123
+ variant_id:
+ type: string
+ example: variant_xY9
+ currency:
+ type: string
+ example: USD
+ amount:
+ type: string
+ nullable: true
+ example: '12.50'
+ compare_at_amount:
+ type: string
+ nullable: true
+ example: '15.00'
+ delete:
+ summary: Delete a price list
+ tags:
+ - Pricing
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: |-
+ Soft-deletes the price list. Associated prices are removed asynchronously.
+
+ **Required scope:** `write_products` (for API-key authentication).
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ schema:
+ type: string
+ responses:
+ '204':
+ description: price list deleted
+ "/api/v3/admin/price_lists/{id}/activate":
+ parameters:
+ - name: id
+ in: path
+ required: true
+ schema:
+ type: string
+ patch:
+ summary: Activate a price list
+ tags:
+ - Pricing
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: |-
+ Transitions a draft / inactive list to `active`. If `starts_at` is
+ in the future the list is marked `scheduled` instead, matching the
+ legacy admin behaviour.
+
+
+ **Required scope:** `write_products` (for API-key authentication).
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ schema:
+ type: string
+ responses:
+ '200':
+ description: price list activated
+ content:
+ application/json:
+ example:
+ id: pl_UkLWZg9DAJ
+ name: Wholesale
+ description:
+ status: active
+ position: 1
+ match_policy: all
+ starts_at:
+ ends_at:
+ created_at: '2026-05-25T19:04:38.521Z'
+ updated_at: '2026-05-25T19:04:38.798Z'
+ currently_active: true
+ products_count: 0
+ prices_count: 0
+ product_ids: []
+ schema:
+ "$ref": "#/components/schemas/PriceList"
+ "/api/v3/admin/price_lists/{id}/deactivate":
+ parameters:
+ - name: id
+ in: path
+ required: true
+ schema:
+ type: string
+ patch:
+ summary: Deactivate a price list
+ tags:
+ - Pricing
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: "**Required scope:** `write_products` (for API-key authentication)."
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ schema:
+ type: string
+ responses:
+ '200':
+ description: price list deactivated
+ content:
+ application/json:
+ example:
+ id: pl_UkLWZg9DAJ
+ name: Price List 1
+ description:
+ status: inactive
+ position: 1
+ match_policy: all
+ starts_at:
+ ends_at:
+ created_at: '2026-05-25T19:04:38.805Z'
+ updated_at: '2026-05-25T19:04:39.088Z'
+ currently_active: false
+ products_count: 0
+ prices_count: 0
+ product_ids: []
+ schema:
+ "$ref": "#/components/schemas/PriceList"
+ "/api/v3/admin/prices":
+ get:
+ summary: List prices
+ tags:
+ - Pricing
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: |-
+ Generic prices endpoint covering both base prices and price-list
+ overrides. Filter with Ransack: `q[price_list_id_eq]=…`,
+ `q[currency_eq]=USD`, `q[price_list_id_null]=true` (base prices only).
+
+ The admin spreadsheet uses this with server-side pagination so it
+ scales past the metadata-PATCH path on `/price_lists/:id`.
+
+
+ **Required scope:** `read_products` (for API-key authentication).
+ x-codeSamples:
+ - lang: javascript
+ label: Spree Admin SDK
+ source: |-
+ import { createAdminClient } from '@spree/admin-sdk'
+
+ const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+ })
+
+ const { data: prices } = await client.prices.list({
+ price_list_id_eq: 'pl_xxx',
+ currency_eq: 'USD',
+ expand: ['variant'],
+ })
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: page
+ in: query
+ required: false
+ schema:
+ type: integer
+ - name: limit
+ in: query
+ required: false
+ schema:
+ type: integer
+ - name: q[price_list_id_eq]
+ in: query
+ required: false
+ schema:
+ type: string
+ - name: q[price_list_id_null]
+ in: query
+ required: false
+ schema:
+ type: boolean
+ - name: q[currency_eq]
+ in: query
+ required: false
+ schema:
+ type: string
+ - name: q[variant_id_eq]
+ in: query
+ required: false
+ schema:
+ type: string
+ - name: sort
+ in: query
+ required: false
+ description: Comma-separated sort keys. Supports e.g. `variant_product_name,variant_id`.
+ schema:
+ type: string
+ - name: expand
+ in: query
+ required: false
+ description: 'Comma-separated associations to embed. Supported: `variant`.'
+ schema:
+ type: string
+ responses:
+ '200':
+ description: prices found
+ content:
+ application/json:
+ example:
+ data:
+ - id: price_gbHJdmfrXB
+ amount: '19.99'
+ amount_in_cents: 1999
+ compare_at_amount:
+ compare_at_amount_in_cents:
+ currency: USD
+ display_amount: "$19.99"
+ display_compare_at_amount:
+ price_list_id:
+ variant_id: variant_gbHJdmfrXB
+ created_at: '2026-05-25T19:04:39.143Z'
+ updated_at: '2026-05-25T19:04:39.143Z'
+ - id: price_EfhxLZ9ck8
+ amount: '5.0'
+ amount_in_cents: 500
+ compare_at_amount:
+ compare_at_amount_in_cents:
+ currency: USD
+ display_amount: "$5.00"
+ display_compare_at_amount:
+ price_list_id: pl_UkLWZg9DAJ
+ variant_id: variant_gbHJdmfrXB
+ created_at: '2026-05-25T19:04:39.147Z'
+ updated_at: '2026-05-25T19:04:39.147Z'
+ meta:
+ page: 1
+ limit: 25
+ count: 2
+ pages: 1
+ from: 1
+ to: 2
+ in: 2
+ previous:
+ next:
+ schema:
+ type: object
+ properties:
+ data:
+ type: array
+ items:
+ "$ref": "#/components/schemas/Price"
+ meta:
+ "$ref": "#/components/schemas/PaginationMeta"
+ required:
+ - data
+ - meta
+ post:
+ summary: Create a price
+ tags:
+ - Pricing
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: |-
+ Creates a single price. Omit `price_list_id` to create a base price.
+ For more than a handful of rows, prefer `POST /admin/prices/bulk_upsert`.
+
+
+ **Required scope:** `write_products` (for API-key authentication).
+ x-codeSamples:
+ - lang: javascript
+ label: Spree Admin SDK
+ source: |-
+ import { createAdminClient } from '@spree/admin-sdk'
+
+ const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+ })
+
+ const price = await client.prices.create({
+ variant_id: 'variant_xxx',
+ currency: 'USD',
+ amount: '19.99',
+ })
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ schema:
+ type: string
+ responses:
+ '201':
+ description: price created
+ content:
+ application/json:
+ example:
+ id: price_uw2YK1rnl0
+ amount: '9.99'
+ amount_in_cents: 999
+ compare_at_amount:
+ compare_at_amount_in_cents:
+ currency: EUR
+ display_amount: "€9.99"
+ display_compare_at_amount:
+ price_list_id:
+ variant_id: variant_EfhxLZ9ck8
+ created_at: '2026-05-25T19:04:39.801Z'
+ updated_at: '2026-05-25T19:04:39.801Z'
+ schema:
+ "$ref": "#/components/schemas/Price"
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: object
+ required:
+ - variant_id
+ - currency
+ properties:
+ variant_id:
+ type: string
+ example: variant_xY9
+ currency:
+ type: string
+ example: USD
+ amount:
+ type: string
+ nullable: true
+ example: '19.99'
+ compare_at_amount:
+ type: string
+ nullable: true
+ example: '24.99'
+ price_list_id:
+ type: string
+ nullable: true
+ example: pl_aBc123
+ "/api/v3/admin/prices/{id}":
+ parameters:
+ - name: id
+ in: path
+ required: true
+ schema:
+ type: string
+ get:
+ summary: Get a price
+ tags:
+ - Pricing
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: "**Required scope:** `read_products` (for API-key authentication)."
+ x-codeSamples:
+ - lang: javascript
+ label: Spree Admin SDK
+ source: |-
+ import { createAdminClient } from '@spree/admin-sdk'
+
+ const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+ })
+
+ const price = await client.prices.get('price_xxx')
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ schema:
+ type: string
+ responses:
+ '200':
+ description: price found
+ content:
+ application/json:
+ example:
+ id: price_EfhxLZ9ck8
+ amount: '5.0'
+ amount_in_cents: 500
+ compare_at_amount:
+ compare_at_amount_in_cents:
+ currency: USD
+ display_amount: "$5.00"
+ display_compare_at_amount:
+ price_list_id: pl_UkLWZg9DAJ
+ variant_id: variant_gbHJdmfrXB
+ created_at: '2026-05-25T19:04:39.871Z'
+ updated_at: '2026-05-25T19:04:39.871Z'
+ schema:
+ "$ref": "#/components/schemas/Price"
+ '404':
+ description: price not found
+ content:
+ application/json:
+ example:
+ error:
+ code: record_not_found
+ message: Price not found
+ schema:
+ "$ref": "#/components/schemas/ErrorResponse"
+ patch:
+ summary: Update a price
+ tags:
+ - Pricing
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: "**Required scope:** `write_products` (for API-key authentication)."
+ x-codeSamples:
+ - lang: javascript
+ label: Spree Admin SDK
+ source: |-
+ import { createAdminClient } from '@spree/admin-sdk'
+
+ const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+ })
+
+ const price = await client.prices.update('price_xxx', {
+ amount: '12.34',
+ })
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ schema:
+ type: string
+ responses:
+ '200':
+ description: price updated
+ content:
+ application/json:
+ example:
+ id: price_EfhxLZ9ck8
+ amount: '12.34'
+ amount_in_cents: 1234
+ compare_at_amount:
+ compare_at_amount_in_cents:
+ currency: USD
+ display_amount: "$12.34"
+ display_compare_at_amount:
+ price_list_id: pl_UkLWZg9DAJ
+ variant_id: variant_gbHJdmfrXB
+ created_at: '2026-05-25T19:04:40.564Z'
+ updated_at: '2026-05-25T19:04:40.843Z'
+ schema:
+ "$ref": "#/components/schemas/Price"
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ amount:
+ type: string
+ nullable: true
+ compare_at_amount:
+ type: string
+ nullable: true
+ delete:
+ summary: Delete a price
+ tags:
+ - Pricing
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: |-
+ Soft-deletes the price (acts_as_paranoid).
+
+ **Required scope:** `write_products` (for API-key authentication).
+ x-codeSamples:
+ - lang: javascript
+ label: Spree Admin SDK
+ source: |-
+ import { createAdminClient } from '@spree/admin-sdk'
+
+ const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+ })
+
+ await client.prices.delete('price_xxx')
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ schema:
+ type: string
+ responses:
+ '204':
+ description: price deleted
+ "/api/v3/admin/prices/bulk_upsert":
+ post:
+ summary: Bulk-upsert prices
tags:
- - Configuration
+ - Pricing
security:
- api_key: []
bearer_auth: []
description: |-
- Returns the registered Spree::PaymentMethod subclasses that can be used to create new payment methods. Useful for populating a "Provider" dropdown in admin UIs.
+ Upserts a batch of prices in a single SQL round trip.
- **Required scope:** `read_settings` (for API-key authentication).
+ Each row either:
+ * targets an existing price by `id`, OR
+ * matches on the unique key `(variant_id, currency, price_list_id)` —
+ updating the existing row if one exists, creating one otherwise.
+
+ Model callbacks (e.g. PriceHistory) are bypassed; this is a
+ bulk-write fast path for the admin spreadsheet. The response
+ carries `price_count` — the number of rows touched.
+
+
+ **Required scope:** `write_products` (for API-key authentication).
x-codeSamples:
- lang: javascript
label: Spree Admin SDK
@@ -8467,7 +9742,22 @@ paths:
secretKey: 'sk_xxx',
})
- const { data: types } = await client.paymentMethods.types()
+ const { price_count } = await client.prices.bulkUpsert({
+ prices: [
+ {
+ variant_id: 'variant_xxx',
+ currency: 'USD',
+ price_list_id: 'pl_xxx',
+ amount: '11.11',
+ },
+ {
+ variant_id: 'variant_yyy',
+ currency: 'USD',
+ price_list_id: 'pl_xxx',
+ amount: '22.22',
+ },
+ ],
+ })
parameters:
- name: x-spree-api-key
in: header
@@ -8481,37 +9771,73 @@ paths:
type: string
responses:
'200':
- description: provider types found
+ description: prices upserted
content:
application/json:
example:
- data:
- - type: bogus
- label: Bogus
- description:
- preference_schema:
- - key: dummy_key
- type: string
- default: PUBLICKEY123
- - key: dummy_secret_key
- type: password
- default:
- - type: custom_payment_source_method
- label: Custom Payment Source Method
- description:
- preference_schema: []
- "/api/v3/admin/payment_methods/{id}":
- get:
- summary: Show a payment method
+ price_count: 2
+ schema:
+ type: object
+ properties:
+ price_count:
+ type: integer
+ '422':
+ description: missing prices key
+ content:
+ application/json:
+ example:
+ error:
+ code: missing_prices
+ message: prices is required (send an empty array to no-op).
+ schema:
+ "$ref": "#/components/schemas/ErrorResponse"
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: object
+ required:
+ - prices
+ properties:
+ prices:
+ type: array
+ items:
+ type: object
+ properties:
+ id:
+ type: string
+ nullable: true
+ example: price_aBc123
+ variant_id:
+ type: string
+ example: variant_xY9
+ currency:
+ type: string
+ example: USD
+ price_list_id:
+ type: string
+ nullable: true
+ example: pl_aBc123
+ amount:
+ type: string
+ nullable: true
+ example: '19.99'
+ compare_at_amount:
+ type: string
+ nullable: true
+ example: '24.99'
+ "/api/v3/admin/prices/bulk_destroy":
+ delete:
+ summary: Bulk-delete prices
tags:
- - Configuration
+ - Pricing
security:
- api_key: []
bearer_auth: []
description: |-
- Returns a payment method by ID.
+ Soft-deletes each price in `ids`. Returns the count actually destroyed.
- **Required scope:** `read_settings` (for API-key authentication).
+ **Required scope:** `write_products` (for API-key authentication).
x-codeSamples:
- lang: javascript
label: Spree Admin SDK
@@ -8523,7 +9849,9 @@ paths:
secretKey: 'sk_xxx',
})
- const paymentMethod = await client.paymentMethods.get('pm_UkLWZg9DAJ')
+ const { price_count } = await client.prices.bulkDestroy({
+ ids: ['price_xxx', 'price_yyy'],
+ })
parameters:
- name: x-spree-api-key
in: header
@@ -8535,46 +9863,30 @@ paths:
required: true
schema:
type: string
- - name: id
- in: path
- required: true
- schema:
- type: string
- - name: expand
- in: query
- required: false
- description: Comma-separated associations to expand. Use dot notation for
- nested expand (max 4 levels).
- schema:
- type: string
- - name: fields
- in: query
- required: false
- description: Comma-separated list of fields to include (e.g., name,type,active).
- id is always included.
- schema:
- type: string
responses:
'200':
- description: payment method found
+ description: prices deleted
content:
application/json:
example:
- id: pm_UkLWZg9DAJ
- name: Check
- description:
- type: check
- session_required: false
- source_required: false
- metadata: {}
- active: true
- auto_capture:
- storefront_visible: true
- position: 1
- created_at: '2026-05-24T17:37:31.752Z'
- updated_at: '2026-05-24T17:37:31.754Z'
- preferences: {}
- preference_schema: []
+ price_count: 1
+ schema:
+ type: object
+ properties:
+ price_count:
+ type: integer
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: object
+ required:
+ - ids
+ properties:
+ ids:
+ type: array
+ items:
+ type: string
"/api/v3/admin/products/{product_id}/custom_fields":
get:
summary: List product custom fields
@@ -8642,8 +9954,8 @@ paths:
field_type: short_text
key: custom.title
value: wool
- created_at: '2026-05-24T17:37:32.172Z'
- updated_at: '2026-05-24T17:37:32.172Z'
+ created_at: '2026-05-25T19:04:42.312Z'
+ updated_at: '2026-05-25T19:04:42.312Z'
storefront_visible: true
custom_field_definition_id: cfdef_UkLWZg9DAJ
meta:
@@ -8710,8 +10022,8 @@ paths:
field_type: long_text
key: custom.description
value: A longer description
- created_at: '2026-05-24T17:37:32.769Z'
- updated_at: '2026-05-24T17:37:32.769Z'
+ created_at: '2026-05-25T19:04:42.930Z'
+ updated_at: '2026-05-25T19:04:42.930Z'
storefront_visible: true
custom_field_definition_id: cfdef_gbHJdmfrXB
'422':
@@ -8795,8 +10107,8 @@ paths:
field_type: short_text
key: custom.title
value: wool
- created_at: '2026-05-24T17:37:33.120Z'
- updated_at: '2026-05-24T17:37:33.120Z'
+ created_at: '2026-05-25T19:04:43.280Z'
+ updated_at: '2026-05-25T19:04:43.280Z'
storefront_visible: true
custom_field_definition_id: cfdef_UkLWZg9DAJ
patch:
@@ -8843,8 +10155,8 @@ paths:
field_type: short_text
key: custom.title
value: cotton
- created_at: '2026-05-24T17:37:33.439Z'
- updated_at: '2026-05-24T17:37:33.726Z'
+ created_at: '2026-05-25T19:04:43.588Z'
+ updated_at: '2026-05-25T19:04:43.864Z'
storefront_visible: true
custom_field_definition_id: cfdef_UkLWZg9DAJ
requestBody:
@@ -8982,32 +10294,34 @@ paths:
example:
data:
- id: prod_UkLWZg9DAJ
- name: Product 396394
- slug: product-396394
+ name: Product 556768
+ slug: product-556768
meta_title:
meta_description:
meta_keywords:
variant_count: 0
- available_on: '2025-05-24T17:37:34.067Z'
+ available_on: '2025-05-25T19:04:44.190Z'
purchasable: true
in_stock: false
backorderable: true
available: true
- description: Eaque soluta sit officiis sequi. Deleniti perspiciatis
- repudiandae ratione quod illum enim. Tenetur tempora similique
- soluta corporis magni ea itaque dolore. Harum aliquid tempore
- facilis amet deleniti facere. Nisi ducimus nihil a optio veniam
- totam. Libero aut deleniti laudantium aliquam reprehenderit. Nam
- neque assumenda a nisi iusto aliquid perferendis. Quas tenetur
- non consequatur assumenda. Quos explicabo error culpa aspernatur
- quod earum cupiditate omnis. Eaque id iste saepe ratione repellendus.
- Porro cum ducimus eaque occaecati natus cupiditate itaque. Quisquam
- esse dolore distinctio labore. Minima excepturi fugiat quibusdam
- voluptatem.
+ description: Nemo voluptatem hic error nam soluta aliquam quod.
+ Deleniti odio enim doloremque provident voluptatum. Cupiditate
+ quos eum temporibus quisquam quas. Odio mollitia illo sunt adipisci
+ officiis quibusdam vero excepturi. Natus accusamus nostrum libero
+ corporis explicabo illum harum soluta. Blanditiis tempore voluptate
+ ipsam similique voluptates explicabo. Soluta alias adipisci eveniet
+ ipsam. Vel delectus asperiores enim accusamus vitae. Itaque laboriosam
+ repellendus ut et quidem autem. Quas hic eum fuga corrupti fugit
+ quo tempora. Nulla aliquam odio facere ab in reprehenderit voluptates.
+ Nesciunt assumenda blanditiis tempora libero. Cum doloribus ullam
+ illum nisi. Ratione nesciunt numquam sint eum. Dignissimos odit
+ velit omnis nesciunt.
description_html: |-
- Eaque soluta sit officiis sequi. Deleniti perspiciatis repudiandae ratione quod illum enim. Tenetur tempora similique soluta corporis magni ea itaque dolore. Harum aliquid tempore facilis amet deleniti facere.
- Nisi ducimus nihil a optio veniam totam. Libero aut deleniti laudantium aliquam reprehenderit. Nam neque assumenda a nisi iusto aliquid perferendis. Quas tenetur non consequatur assumenda. Quos explicabo error culpa aspernatur quod earum cupiditate omnis.
- Eaque id iste saepe ratione repellendus. Porro cum ducimus eaque occaecati natus cupiditate itaque. Quisquam esse dolore distinctio labore. Minima excepturi fugiat quibusdam voluptatem.
+ Nemo voluptatem hic error nam soluta aliquam quod. Deleniti odio enim doloremque provident voluptatum. Cupiditate quos eum temporibus quisquam quas. Odio mollitia illo sunt adipisci officiis quibusdam vero excepturi.
+ Natus accusamus nostrum libero corporis explicabo illum harum soluta. Blanditiis tempore voluptate ipsam similique voluptates explicabo. Soluta alias adipisci eveniet ipsam.
+ Vel delectus asperiores enim accusamus vitae. Itaque laboriosam repellendus ut et quidem autem. Quas hic eum fuga corrupti fugit quo tempora.
+ Nulla aliquam odio facere ab in reprehenderit voluptates. Nesciunt assumenda blanditiis tempora libero. Cum doloribus ullam illum nisi. Ratione nesciunt numquam sint eum. Dignissimos odit velit omnis nesciunt.
default_variant_id: variant_UkLWZg9DAJ
thumbnail_url:
tags: []
@@ -9022,16 +10336,16 @@ paths:
display_compare_at_amount:
price_list_id:
variant_id: variant_UkLWZg9DAJ
- created_at: '2026-05-24T17:37:34.092Z'
- updated_at: '2026-05-24T17:37:34.092Z'
+ created_at: '2026-05-25T19:04:44.223Z'
+ updated_at: '2026-05-25T19:04:44.223Z'
original_price:
status: active
- make_active_at: '2025-05-24T17:37:34.067Z'
+ make_active_at: '2025-05-25T19:04:44.190Z'
discontinue_on:
metadata: {}
deleted_at:
- created_at: '2026-05-24T17:37:34.079Z'
- updated_at: '2026-05-24T17:37:34.093Z'
+ created_at: '2026-05-25T19:04:44.206Z'
+ updated_at: '2026-05-25T19:04:44.224Z'
tax_category_id: taxcat_UkLWZg9DAJ
meta:
page: 1
@@ -9165,8 +10479,8 @@ paths:
discontinue_on:
metadata: {}
deleted_at:
- created_at: '2026-05-24T17:37:34.756Z'
- updated_at: '2026-05-24T17:37:34.758Z'
+ created_at: '2026-05-25T19:04:44.874Z'
+ updated_at: '2026-05-25T19:04:44.876Z'
tax_category_id:
schema:
"$ref": "#/components/schemas/Product"
@@ -9346,26 +10660,28 @@ paths:
application/json:
example:
id: prod_UkLWZg9DAJ
- name: Product 431256
- slug: product-431256
+ name: Product 593396
+ slug: product-593396
meta_title:
meta_description:
meta_keywords:
variant_count: 0
- available_on: '2025-05-24T17:37:35.110Z'
+ available_on: '2025-05-25T19:04:45.226Z'
purchasable: true
in_stock: false
backorderable: true
available: true
- description: Nemo quam et hic libero natus qui. Saepe repudiandae
- eaque autem provident omnis at quia. Porro fugiat voluptatibus vero
- dolore beatae minus id. Molestias est illo unde quis. Velit quis
- at voluptatem ut quam mollitia saepe nam. Eligendi laudantium quis
- aspernatur ea incidunt culpa. Cupiditate sequi reiciendis aspernatur
- maiores. Tempore blanditiis sint libero odit veniam.
+ description: Culpa nostrum ipsam laudantium reprehenderit dolorum.
+ Inventore reprehenderit nam provident quaerat fugiat deserunt veniam.
+ Iusto sed non possimus tempora. Quaerat ut voluptatum facilis enim
+ omnis ab. Earum nam architecto quo eaque. Placeat officia est laborum
+ vitae vero animi. Eaque harum aspernatur et maiores ipsam corporis
+ officia itaque. Ex eligendi ratione doloribus exercitationem suscipit
+ voluptate quam. Quia explicabo autem maxime officiis illo excepturi.
+ Quos facere iste libero assumenda.
description_html: |-
- Nemo quam et hic libero natus qui. Saepe repudiandae eaque autem provident omnis at quia. Porro fugiat voluptatibus vero dolore beatae minus id. Molestias est illo unde quis.
- Velit quis at voluptatem ut quam mollitia saepe nam. Eligendi laudantium quis aspernatur ea incidunt culpa. Cupiditate sequi reiciendis aspernatur maiores. Tempore blanditiis sint libero odit veniam.
+ Culpa nostrum ipsam laudantium reprehenderit dolorum. Inventore reprehenderit nam provident quaerat fugiat deserunt veniam. Iusto sed non possimus tempora. Quaerat ut voluptatum facilis enim omnis ab. Earum nam architecto quo eaque.
+ Placeat officia est laborum vitae vero animi. Eaque harum aspernatur et maiores ipsam corporis officia itaque. Ex eligendi ratione doloribus exercitationem suscipit voluptate quam. Quia explicabo autem maxime officiis illo excepturi. Quos facere iste libero assumenda.
default_variant_id: variant_UkLWZg9DAJ
thumbnail_url:
tags: []
@@ -9380,16 +10696,16 @@ paths:
display_compare_at_amount:
price_list_id:
variant_id: variant_UkLWZg9DAJ
- created_at: '2026-05-24T17:37:35.137Z'
- updated_at: '2026-05-24T17:37:35.137Z'
+ created_at: '2026-05-25T19:04:45.258Z'
+ updated_at: '2026-05-25T19:04:45.258Z'
original_price:
status: active
- make_active_at: '2025-05-24T17:37:35.110Z'
+ make_active_at: '2025-05-25T19:04:45.226Z'
discontinue_on:
metadata: {}
deleted_at:
- created_at: '2026-05-24T17:37:35.121Z'
- updated_at: '2026-05-24T17:37:35.138Z'
+ created_at: '2026-05-25T19:04:45.243Z'
+ updated_at: '2026-05-25T19:04:45.260Z'
tax_category_id: taxcat_UkLWZg9DAJ
schema:
"$ref": "#/components/schemas/Product"
@@ -9456,29 +10772,22 @@ paths:
example:
id: prod_UkLWZg9DAJ
name: Updated Name
- slug: product-458011
+ slug: product-612429
meta_title:
meta_description:
meta_keywords:
variant_count: 0
- available_on: '2025-05-24T17:37:35.789Z'
+ available_on: '2025-05-25T19:04:45.871Z'
purchasable: true
in_stock: false
backorderable: true
available: true
- description: Non occaecati aut quidem tempore aliquid nisi reprehenderit.
- Amet culpa hic ullam molestiae cupiditate provident. Nostrum magni
- soluta velit eius. Itaque sequi iste repudiandae qui esse. Sapiente
- tenetur doloremque ipsum nesciunt delectus rerum voluptas. Odit
- voluptatem deleniti sunt veniam. Quidem molestiae possimus illo
- debitis alias earum quas accusantium. Possimus ea est unde culpa.
- Alias atque autem ullam voluptatibus iste. Consectetur exercitationem
- autem natus odit eveniet. Quibusdam similique delectus culpa cumque
- iure.
- description_html: |-
- Non occaecati aut quidem tempore aliquid nisi reprehenderit. Amet culpa hic ullam molestiae cupiditate provident. Nostrum magni soluta velit eius. Itaque sequi iste repudiandae qui esse.
- Sapiente tenetur doloremque ipsum nesciunt delectus rerum voluptas. Odit voluptatem deleniti sunt veniam. Quidem molestiae possimus illo debitis alias earum quas accusantium.
- Possimus ea est unde culpa. Alias atque autem ullam voluptatibus iste. Consectetur exercitationem autem natus odit eveniet. Quibusdam similique delectus culpa cumque iure.
+ description: Quasi doloremque labore quaerat cum quos excepturi nisi.
+ Facere minima consectetur assumenda eum officiis perspiciatis ipsa
+ aperiam. Numquam nobis labore et eligendi sit debitis.
+ description_html: Quasi doloremque labore quaerat cum quos excepturi
+ nisi. Facere minima consectetur assumenda eum officiis perspiciatis
+ ipsa aperiam. Numquam nobis labore et eligendi sit debitis.
default_variant_id: variant_UkLWZg9DAJ
thumbnail_url:
tags: []
@@ -9493,16 +10802,16 @@ paths:
display_compare_at_amount:
price_list_id:
variant_id: variant_UkLWZg9DAJ
- created_at: '2026-05-24T17:37:35.810Z'
- updated_at: '2026-05-24T17:37:35.810Z'
+ created_at: '2026-05-25T19:04:45.893Z'
+ updated_at: '2026-05-25T19:04:45.893Z'
original_price:
status: active
- make_active_at: '2025-05-24T17:37:35.789Z'
+ make_active_at: '2025-05-25T19:04:45.871Z'
discontinue_on:
metadata: {}
deleted_at:
- created_at: '2026-05-24T17:37:35.799Z'
- updated_at: '2026-05-24T17:37:36.106Z'
+ created_at: '2026-05-25T19:04:45.882Z'
+ updated_at: '2026-05-25T19:04:46.182Z'
tax_category_id: taxcat_UkLWZg9DAJ
schema:
"$ref": "#/components/schemas/Product"
@@ -10035,8 +11344,8 @@ paths:
example:
data:
- id: pact_UkLWZg9DAJ
- created_at: '2026-05-24T17:37:39.416Z'
- updated_at: '2026-05-24T17:37:39.416Z'
+ created_at: '2026-05-25T19:04:49.539Z'
+ updated_at: '2026-05-25T19:04:49.539Z'
type: free_shipping
promotion_id: promo_UkLWZg9DAJ
preferences: {}
@@ -10097,8 +11406,8 @@ paths:
application/json:
example:
id: pact_UkLWZg9DAJ
- created_at: '2026-05-24T17:37:39.979Z'
- updated_at: '2026-05-24T17:37:39.979Z'
+ created_at: '2026-05-25T19:04:50.094Z'
+ updated_at: '2026-05-25T19:04:50.094Z'
type: free_shipping
promotion_id: promo_UkLWZg9DAJ
preferences: {}
@@ -10208,8 +11517,8 @@ paths:
example:
data:
- id: prorule_UkLWZg9DAJ
- created_at: '2026-05-24T17:37:40.551Z'
- updated_at: '2026-05-24T17:37:40.551Z'
+ created_at: '2026-05-25T19:04:50.664Z'
+ updated_at: '2026-05-25T19:04:50.664Z'
type: currency
promotion_id: promo_UkLWZg9DAJ
preferences:
@@ -10276,8 +11585,8 @@ paths:
application/json:
example:
id: prorule_UkLWZg9DAJ
- created_at: '2026-05-24T17:37:41.133Z'
- updated_at: '2026-05-24T17:37:41.133Z'
+ created_at: '2026-05-25T19:04:51.238Z'
+ updated_at: '2026-05-25T19:04:51.238Z'
type: currency
promotion_id: promo_UkLWZg9DAJ
preferences:
@@ -10350,8 +11659,8 @@ paths:
application/json:
example:
id: prorule_UkLWZg9DAJ
- created_at: '2026-05-24T17:37:41.423Z'
- updated_at: '2026-05-24T17:37:41.701Z'
+ created_at: '2026-05-25T19:04:51.533Z'
+ updated_at: '2026-05-25T19:04:51.808Z'
type: currency
promotion_id: promo_UkLWZg9DAJ
preferences:
@@ -10441,7 +11750,7 @@ paths:
name: Summer Sale
description:
code: summer
- starts_at: '2026-05-24T17:37:41.992Z'
+ starts_at: '2026-05-25T19:04:52.093Z'
expires_at:
usage_limit:
match_policy: all
@@ -10452,8 +11761,8 @@ paths:
code_prefix:
promotion_category_id:
metadata: {}
- created_at: '2026-05-24T17:37:41.993Z'
- updated_at: '2026-05-24T17:37:41.994Z'
+ created_at: '2026-05-25T19:04:52.094Z'
+ updated_at: '2026-05-25T19:04:52.095Z'
store_ids:
- store_UkLWZg9DAJ
action_ids: []
@@ -10559,7 +11868,7 @@ paths:
name: Black Friday
description:
code: blackfriday-os
- starts_at: '2026-05-24T17:37:42.886Z'
+ starts_at: '2026-05-25T19:04:53.049Z'
expires_at:
usage_limit:
match_policy: all
@@ -10570,8 +11879,8 @@ paths:
code_prefix:
promotion_category_id:
metadata: {}
- created_at: '2026-05-24T17:37:42.887Z'
- updated_at: '2026-05-24T17:37:42.905Z'
+ created_at: '2026-05-25T19:04:53.052Z'
+ updated_at: '2026-05-25T19:04:53.094Z'
store_ids:
- store_UkLWZg9DAJ
action_ids:
@@ -10724,7 +12033,7 @@ paths:
name: Summer Sale
description:
code: summer
- starts_at: '2026-05-24T17:37:43.209Z'
+ starts_at: '2026-05-25T19:04:53.387Z'
expires_at:
usage_limit:
match_policy: all
@@ -10735,8 +12044,8 @@ paths:
code_prefix:
promotion_category_id:
metadata: {}
- created_at: '2026-05-24T17:37:43.209Z'
- updated_at: '2026-05-24T17:37:43.211Z'
+ created_at: '2026-05-25T19:04:53.388Z'
+ updated_at: '2026-05-25T19:04:53.388Z'
store_ids:
- store_UkLWZg9DAJ
action_ids: []
@@ -10832,7 +12141,7 @@ paths:
name: Summer Sale
description:
code: summer
- starts_at: '2026-05-24T17:37:44.083Z'
+ starts_at: '2026-05-25T19:04:54.288Z'
expires_at:
usage_limit:
match_policy: all
@@ -10843,8 +12152,8 @@ paths:
code_prefix:
promotion_category_id:
metadata: {}
- created_at: '2026-05-24T17:37:44.084Z'
- updated_at: '2026-05-24T17:37:44.366Z'
+ created_at: '2026-05-25T19:04:54.288Z'
+ updated_at: '2026-05-25T19:04:54.568Z'
store_ids:
- store_UkLWZg9DAJ
action_ids: []
@@ -11080,15 +12389,15 @@ paths:
label: Country
description:
preference_schema:
+ - key: country_iso
+ type: string
+ default:
- key: country_isos
type: array
default: []
- key: country_id
type: integer
default:
- - key: country_iso
- type: string
- default:
- type: currency
label: Currency
description:
@@ -11196,8 +12505,8 @@ paths:
data:
- id: role_UkLWZg9DAJ
name: admin
- created_at: '2026-05-24T17:37:45.227Z'
- updated_at: '2026-05-24T17:37:45.227Z'
+ created_at: '2026-05-25T19:04:55.423Z'
+ updated_at: '2026-05-25T19:04:55.423Z'
meta:
page: 1
limit: 25
@@ -11310,14 +12619,14 @@ paths:
example:
data:
- id: sloc_UkLWZg9DAJ
- state_abbr: STATE_ABBR_30
+ state_abbr: STATE_ABBR_43
name: Brooklyn warehouse
address1: 1600 Pennsylvania Ave NW
city: Washington
zipcode: '20500'
country_iso: US
country_name: United States of America
- state_text: STATE_ABBR_30
+ state_text: STATE_ABBR_43
admin_name:
address2:
state_name:
@@ -11332,8 +12641,8 @@ paths:
pickup_stock_policy: local
pickup_ready_in_minutes:
pickup_instructions:
- created_at: '2026-05-24T17:37:45.507Z'
- updated_at: '2026-05-24T17:37:45.507Z'
+ created_at: '2026-05-25T19:04:55.701Z'
+ updated_at: '2026-05-25T19:04:55.701Z'
meta:
page: 1
limit: 25
@@ -11444,8 +12753,8 @@ paths:
pickup_stock_policy: local
pickup_ready_in_minutes: 30
pickup_instructions:
- created_at: '2026-05-24T17:37:46.092Z'
- updated_at: '2026-05-24T17:37:46.092Z'
+ created_at: '2026-05-25T19:04:56.268Z'
+ updated_at: '2026-05-25T19:04:56.268Z'
schema:
"$ref": "#/components/schemas/StockLocation"
'422':
@@ -11597,14 +12906,14 @@ paths:
application/json:
example:
id: sloc_UkLWZg9DAJ
- state_abbr: STATE_ABBR_34
+ state_abbr: STATE_ABBR_47
name: Brooklyn warehouse
address1: 1600 Pennsylvania Ave NW
city: Washington
zipcode: '20500'
country_iso: US
country_name: United States of America
- state_text: STATE_ABBR_34
+ state_text: STATE_ABBR_47
admin_name:
address2:
state_name:
@@ -11619,8 +12928,8 @@ paths:
pickup_stock_policy: local
pickup_ready_in_minutes:
pickup_instructions:
- created_at: '2026-05-24T17:37:46.381Z'
- updated_at: '2026-05-24T17:37:46.381Z'
+ created_at: '2026-05-25T19:04:56.554Z'
+ updated_at: '2026-05-25T19:04:56.554Z'
schema:
"$ref": "#/components/schemas/StockLocation"
'404':
@@ -11683,14 +12992,14 @@ paths:
application/json:
example:
id: sloc_UkLWZg9DAJ
- state_abbr: STATE_ABBR_36
+ state_abbr: STATE_ABBR_49
name: Renamed warehouse
address1: 1600 Pennsylvania Ave NW
city: Washington
zipcode: '20500'
country_iso: US
country_name: United States of America
- state_text: STATE_ABBR_36
+ state_text: STATE_ABBR_49
admin_name:
address2:
state_name:
@@ -11705,8 +13014,8 @@ paths:
pickup_stock_policy: local
pickup_ready_in_minutes: 45
pickup_instructions:
- created_at: '2026-05-24T17:37:46.959Z'
- updated_at: '2026-05-24T17:37:47.265Z'
+ created_at: '2026-05-25T19:04:57.113Z'
+ updated_at: '2026-05-25T19:04:57.386Z'
schema:
"$ref": "#/components/schemas/StockLocation"
'422':
@@ -11909,8 +13218,8 @@ paths:
data:
- id: sccat_UkLWZg9DAJ
name: Goodwill
- created_at: '2026-05-24T17:37:47.897Z'
- updated_at: '2026-05-24T17:37:47.897Z'
+ created_at: '2026-05-25T19:04:57.954Z'
+ updated_at: '2026-05-25T19:04:57.954Z'
non_expiring: false
meta:
page: 1
@@ -12001,8 +13310,8 @@ paths:
example:
id: sccat_UkLWZg9DAJ
name: Goodwill
- created_at: '2026-05-24T17:37:48.191Z'
- updated_at: '2026-05-24T17:37:48.191Z'
+ created_at: '2026-05-25T19:04:58.261Z'
+ updated_at: '2026-05-25T19:04:58.261Z'
non_expiring: false
schema:
"$ref": "#/components/schemas/StoreCreditCategory"
@@ -12067,8 +13376,8 @@ paths:
preferred_timezone: UTC
preferred_weight_unit: lb
preferred_unit_system: imperial
- created_at: '2026-05-24T17:36:33.540Z'
- updated_at: '2026-05-24T17:37:48.768Z'
+ created_at: '2026-05-25T19:03:36.944Z'
+ updated_at: '2026-05-25T19:04:58.853Z'
url: http://www.example.com:3000
supported_currencies:
- USD
@@ -12139,8 +13448,8 @@ paths:
preferred_timezone: UTC
preferred_weight_unit: lb
preferred_unit_system: imperial
- created_at: '2026-05-24T17:36:33.540Z'
- updated_at: '2026-05-24T17:37:49.372Z'
+ created_at: '2026-05-25T19:03:36.944Z'
+ updated_at: '2026-05-25T19:04:59.451Z'
url: http://www.example.com:3000
supported_currencies:
- USD
@@ -12328,7 +13637,7 @@ paths:
data:
- id: variant_UkLWZg9DAJ
product_id: prod_UkLWZg9DAJ
- sku: SKU-65
+ sku: SKU-93
options_text: ''
track_inventory: true
media_count: 0
@@ -12360,16 +13669,16 @@ paths:
weight_unit: lb
dimensions_unit:
deleted_at:
- created_at: '2026-05-24T17:37:50.786Z'
- updated_at: '2026-05-24T17:37:50.796Z'
+ created_at: '2026-05-25T19:05:00.851Z'
+ updated_at: '2026-05-25T19:05:00.865Z'
tax_category_id: taxcat_UkLWZg9DAJ
available_stock: 0
reserved_quantity: 0
total_on_hand: 0
- product_name: Product 596609
+ product_name: Product 757769
- id: variant_gbHJdmfrXB
product_id: prod_UkLWZg9DAJ
- sku: SKU-66
+ sku: SKU-94
options_text: 'Size: S'
track_inventory: true
media_count: 0
@@ -12377,10 +13686,10 @@ paths:
purchasable: true
in_stock: false
backorderable: true
- weight: 79.4
- height: 180.38
- width: 28.4
- depth: 47.4
+ weight: 103.2
+ height: 43.85
+ width: 38.5
+ depth: 2.18
price:
id: price_gbHJdmfrXB
amount: '19.99'
@@ -12395,16 +13704,16 @@ paths:
option_values:
- id: optval_UkLWZg9DAJ
option_type_id: opt_UkLWZg9DAJ
- name: size-7
+ name: size-19
label: S
position: 1
color_code:
- option_type_name: foo-size-16
+ option_type_name: foo-size-28
option_type_label: Size
image_url:
metadata: {}
- created_at: '2026-05-24T17:37:50.805Z'
- updated_at: '2026-05-24T17:37:50.805Z'
+ created_at: '2026-05-25T19:05:00.875Z'
+ updated_at: '2026-05-25T19:05:00.875Z'
metadata: {}
position: 2
cost_price: '17.0'
@@ -12413,13 +13722,13 @@ paths:
weight_unit: lb
dimensions_unit:
deleted_at:
- created_at: '2026-05-24T17:37:50.803Z'
- updated_at: '2026-05-24T17:37:50.816Z'
+ created_at: '2026-05-25T19:05:00.873Z'
+ updated_at: '2026-05-25T19:05:00.887Z'
tax_category_id: taxcat_UkLWZg9DAJ
available_stock: 0
reserved_quantity: 0
total_on_hand: 0
- product_name: Product 596609
+ product_name: Product 757769
meta:
page: 1
limit: 25
@@ -12530,8 +13839,8 @@ paths:
option_type_label: Size
image_url:
metadata: {}
- created_at: '2026-05-24T17:37:51.471Z'
- updated_at: '2026-05-24T17:37:51.471Z'
+ created_at: '2026-05-25T19:05:01.524Z'
+ updated_at: '2026-05-25T19:05:01.524Z'
metadata: {}
position: 3
cost_price:
@@ -12540,13 +13849,13 @@ paths:
weight_unit: lb
dimensions_unit:
deleted_at:
- created_at: '2026-05-24T17:37:51.475Z'
- updated_at: '2026-05-24T17:37:51.477Z'
+ created_at: '2026-05-25T19:05:01.527Z'
+ updated_at: '2026-05-25T19:05:01.529Z'
tax_category_id: taxcat_UkLWZg9DAJ
available_stock: 0
reserved_quantity: 0
total_on_hand: 0
- product_name: Product 606004
+ product_name: Product 767342
'422':
description: validation error
content:
@@ -12725,7 +14034,7 @@ paths:
example:
id: variant_gbHJdmfrXB
product_id: prod_UkLWZg9DAJ
- sku: SKU-72
+ sku: SKU-100
options_text: 'Size: S'
track_inventory: true
media_count: 0
@@ -12733,10 +14042,10 @@ paths:
purchasable: true
in_stock: false
backorderable: true
- weight: 181.11
- height: 171.7
- width: 181.35
- depth: 135.86
+ weight: 27.7
+ height: 35.3
+ width: 95.3
+ depth: 146.85
price:
id: price_gbHJdmfrXB
amount: '19.99'
@@ -12751,16 +14060,16 @@ paths:
option_values:
- id: optval_UkLWZg9DAJ
option_type_id: opt_UkLWZg9DAJ
- name: size-10
+ name: size-22
label: S
position: 1
color_code:
- option_type_name: foo-size-19
+ option_type_name: foo-size-31
option_type_label: Size
image_url:
metadata: {}
- created_at: '2026-05-24T17:37:51.868Z'
- updated_at: '2026-05-24T17:37:51.868Z'
+ created_at: '2026-05-25T19:05:01.986Z'
+ updated_at: '2026-05-25T19:05:01.986Z'
metadata: {}
position: 2
cost_price: '17.0'
@@ -12769,13 +14078,13 @@ paths:
weight_unit: lb
dimensions_unit:
deleted_at:
- created_at: '2026-05-24T17:37:51.866Z'
- updated_at: '2026-05-24T17:37:51.881Z'
+ created_at: '2026-05-25T19:05:01.984Z'
+ updated_at: '2026-05-25T19:05:01.996Z'
tax_category_id: taxcat_UkLWZg9DAJ
available_stock: 0
reserved_quantity: 0
total_on_hand: 0
- product_name: Product 624851
+ product_name: Product 787242
'404':
description: variant not found
content:
@@ -12854,10 +14163,10 @@ paths:
purchasable: true
in_stock: false
backorderable: true
- weight: 58.48
- height: 8.7
- width: 169.3
- depth: 28.62
+ weight: 53.69
+ height: 97.14
+ width: 194.61
+ depth: 158.53
price:
id: price_gbHJdmfrXB
amount: '19.99'
@@ -12872,16 +14181,16 @@ paths:
option_values:
- id: optval_UkLWZg9DAJ
option_type_id: opt_UkLWZg9DAJ
- name: size-12
+ name: size-24
label: S
position: 1
color_code:
- option_type_name: foo-size-21
+ option_type_name: foo-size-33
option_type_label: Size
image_url:
metadata: {}
- created_at: '2026-05-24T17:37:52.555Z'
- updated_at: '2026-05-24T17:37:52.555Z'
+ created_at: '2026-05-25T19:05:02.645Z'
+ updated_at: '2026-05-25T19:05:02.645Z'
metadata: {}
position: 2
cost_price: '17.0'
@@ -12890,13 +14199,13 @@ paths:
weight_unit: lb
dimensions_unit:
deleted_at:
- created_at: '2026-05-24T17:37:52.553Z'
- updated_at: '2026-05-24T17:37:52.843Z'
+ created_at: '2026-05-25T19:05:02.643Z'
+ updated_at: '2026-05-25T19:05:02.933Z'
tax_category_id: taxcat_UkLWZg9DAJ
available_stock: 0
reserved_quantity: 0
total_on_hand: 0
- product_name: Product 641234
+ product_name: Product 802402
requestBody:
content:
application/json:
@@ -15250,6 +16559,97 @@ components:
- compare_at_amount
- created_at
x-typelizer: true
+ PriceList:
+ type: object
+ properties:
+ id:
+ type: string
+ name:
+ type: string
+ description:
+ type: string
+ nullable: true
+ status:
+ type: string
+ position:
+ type: number
+ match_policy:
+ type: string
+ starts_at:
+ type: string
+ nullable: true
+ ends_at:
+ type: string
+ nullable: true
+ created_at:
+ type: string
+ updated_at:
+ type: string
+ currently_active:
+ type: boolean
+ products_count:
+ type: number
+ prices_count:
+ type: number
+ product_ids:
+ type: array
+ items:
+ type: string
+ price_rules:
+ type: array
+ items:
+ "$ref": "#/components/schemas/PriceRule"
+ required:
+ - id
+ - name
+ - description
+ - status
+ - position
+ - match_policy
+ - starts_at
+ - ends_at
+ - created_at
+ - updated_at
+ - currently_active
+ - products_count
+ - prices_count
+ - product_ids
+ x-typelizer: true
+ PriceRule:
+ type: object
+ properties:
+ id:
+ type: string
+ created_at:
+ type: string
+ updated_at:
+ type: string
+ type:
+ type: string
+ price_list_id:
+ type: string
+ preferences:
+ type: object
+ preference_schema:
+ type: array
+ items:
+ "$ref": "#/components/schemas/PreferenceField"
+ label:
+ type: string
+ description:
+ type: string
+ nullable: true
+ required:
+ - id
+ - created_at
+ - updated_at
+ - type
+ - price_list_id
+ - preferences
+ - preference_schema
+ - label
+ - description
+ x-typelizer: true
Price:
type: object
properties:
diff --git a/packages/admin-sdk/src/types/generated/PriceList.ts b/packages/admin-sdk/src/types/generated/PriceList.ts
new file mode 100644
index 0000000000..027196df24
--- /dev/null
+++ b/packages/admin-sdk/src/types/generated/PriceList.ts
@@ -0,0 +1,25 @@
+// Typelizer digest 5012bf582847766ab070b84ed78fe3cf
+//
+// DO NOT MODIFY: This file was automatically generated by Typelizer.
+import type {PriceRule} from '@/types'
+
+interface PriceList {
+ id: string;
+ name: string;
+ description: string | null;
+ status: string;
+ position: number;
+ match_policy: string;
+ starts_at: string | null;
+ ends_at: string | null;
+ deleted_at: string | null;
+ created_at: string;
+ updated_at: string;
+ currently_active: boolean;
+ products_count: number;
+ prices_count: number;
+ product_ids: Array<string>;
+ price_rules?: Array<PriceRule>;
+}
+
+export default PriceList;
diff --git a/packages/admin-sdk/src/types/generated/PriceRule.ts b/packages/admin-sdk/src/types/generated/PriceRule.ts
new file mode 100644
index 0000000000..121d771fcd
--- /dev/null
+++ b/packages/admin-sdk/src/types/generated/PriceRule.ts
@@ -0,0 +1,17 @@
+// Typelizer digest fd105f817869741dc317ffa9f5f09139
+//
+// DO NOT MODIFY: This file was automatically generated by Typelizer.
+
+interface PriceRule {
+ id: string;
+ created_at: string;
+ updated_at: string;
+ type: string;
+ price_list_id: string;
+ preferences: Record<string, unknown>;
+ preference_schema: Array<{ key: string; type: string; default: unknown }>;
+ label: string;
+ description: string | null;
+}
+
+export default PriceRule;
diff --git a/packages/admin-sdk/src/types/generated/index.ts b/packages/admin-sdk/src/types/generated/index.ts
index 435ca8820e..abe9f9292d 100644
--- a/packages/admin-sdk/src/types/generated/index.ts
+++ b/packages/admin-sdk/src/types/generated/index.ts
@@ -1,4 +1,4 @@
-// Typelizer digest fb48a6da6484b901cd424617ea0f9738
+// Typelizer digest 5606af781fc551d60fa237b3b6d313fe
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
export type { default as Address } from './Address'
@@ -34,6 +34,8 @@ export type { default as PaymentMethod } from './PaymentMethod'
export type { default as Payment } from './Payment'
export type { default as PaymentSource } from './PaymentSource'
export type { default as PriceHistory } from './PriceHistory'
+export type { default as PriceList } from './PriceList'
+export type { default as PriceRule } from './PriceRule'
export type { default as Price } from './Price'
export type { default as Product } from './Product'
export type { default as PromotionAction } from './PromotionAction'
diff --git a/spree/admin/spec/controllers/spree/admin/price_rules_controller_spec.rb b/spree/admin/spec/controllers/spree/admin/price_rules_controller_spec.rb
index 22099f45f8..e36d21db44 100644
--- a/spree/admin/spec/controllers/spree/admin/price_rules_controller_spec.rb
+++ b/spree/admin/spec/controllers/spree/admin/price_rules_controller_spec.rb
@@ -21,13 +21,13 @@ RSpec.describe Spree::Admin::PriceRulesController, type: :controller do
end
context 'with type parameter' do
- subject { get :new, params: { price_list_id: price_list.to_param, price_rule: { type: 'Spree::PriceRules::ZoneRule' } } }
+ subject { get :new, params: { price_list_id: price_list.to_param, price_rule: { type: 'Spree::PriceRules::MarketRule' } } }
it 'renders the form for the selected type' do
subject
expect(response).to render_template(:new)
- expect(assigns[:price_rule]).to be_a(Spree::PriceRules::ZoneRule)
+ expect(assigns[:price_rule]).to be_a(Spree::PriceRules::MarketRule)
end
end
end
diff --git a/spree/api/app/controllers/spree/api/v3/admin/price_lists_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/price_lists_controller.rb
new file mode 100644
index 0000000000..3dd97f60e8
--- /dev/null
+++ b/spree/api/app/controllers/spree/api/v3/admin/price_lists_controller.rb
@@ -0,0 +1,156 @@
+module Spree
+ module Api
+ module V3
+ module Admin
+ # Admin CRUD for `Spree::PriceList`, plus the lifecycle transitions
+ # (`activate` / `deactivate`) and the spreadsheet's data feed
+ # (`prices`).
+ #
+ # Everything writable on the list — name, schedule, match policy,
+ # product membership (`product_ids: [...]`), nested rules
+ # (`rules: [...]`), and individual price overrides
+ # (`prices: [...]`) — flows through the regular PATCH payload, so
+ # the SPA saves the entire editor in one round-trip. No separate
+ # add_products / remove_products / add_rule / bulk_update_prices
+ # endpoints.
+ #
+ # Scoped under the `products` API-key scope — price lists are a
+ # product/pricing concern; we don't introduce a separate
+ # `read_price_lists` scope.
+ class PriceListsController < ResourceController
+ scoped_resource :products
+
+ # The base ResourceController limits `set_resource` to
+ # `show/update/destroy`. We need it on the custom member
+ # actions below too, so swap in our own filter — Rails keys
+ # before_actions by method name, so this would otherwise
+ # *replace* the parent's narrower filter and break the standard
+ # actions. Wrapping it under a different name keeps both.
+ before_action :load_member_resource, only: [:activate, :deactivate, :prices]
+
+ # GET /api/v3/admin/price_lists/price_rule_types
+ #
+ # Returns `[{ type, label, description, preference_schema }]`
+ # for every registered subclass in `Spree.pricing.rules`. The
+ # SPA uses this to build the "Add rule" picker + render a
+ # generic preferences form per subclass. Rules themselves are
+ # not a separate REST resource — they ride along on the price
+ # list's PATCH body via `rules: [...]`.
+ def price_rule_types
+ authorize! :read, Spree::PriceRule
+ render json: { data: Spree::PriceRule.subclasses_with_preference_schema }
+ end
+
+ # PATCH /api/v3/admin/price_lists/:id/activate
+ #
+ # State transition: draft|inactive → active (or → scheduled when
+ # `starts_at` is in the future). Mirrors the old Rails admin's
+ # "Activate" button which automatically scheduled future lists.
+ def activate
+ authorize! :update, @resource
+ event = @resource.starts_at.present? && @resource.starts_at.future? ? :schedule : :activate
+
+ if @resource.send(event)
+ render json: serialize_resource(@resource)
+ else
+ render_validation_error(@resource.errors)
+ end
+ end
+
+ # PATCH /api/v3/admin/price_lists/:id/deactivate
+ def deactivate
+ authorize! :update, @resource
+
+ if @resource.deactivate
+ render json: serialize_resource(@resource)
+ else
+ render_validation_error(@resource.errors)
+ end
+ end
+
+ # GET /api/v3/admin/price_lists/:id/prices
+ #
+ # The spreadsheet editor's data source. Returns every Price row
+ # in this list (filtered by `?currency=`), eager-loading
+ # `variant.product` + option values so each cell can render
+ # product name, variant options and SKU without N+1.
+ def prices
+ authorize! :read, @resource
+ currency = params[:currency].presence || current_store.default_currency
+ prices = @resource.prices
+ .includes(variant: [:product, { option_values: :option_type }])
+ .where(currency: currency)
+ .joins(variant: :product)
+ .order(Arel.sql("#{Spree::Product.table_name}.name ASC"))
+ .order(Arel.sql("#{Spree::Variant.table_name}.position ASC"))
+
+ render json: {
+ data: prices.map { |p| serialize_price(p) },
+ meta: { currency: currency, count: prices.size }
+ }
+ end
+
+ protected
+
+ def model_class
+ Spree::PriceList
+ end
+
+ def serializer_class
+ Spree.api.admin_price_list_serializer
+ end
+
+ def scope
+ super.for_store(current_store)
+ end
+
+ def permitted_params
+ normalize_params(
+ params.permit(
+ :name, :description, :position,
+ :starts_at, :ends_at, :match_policy,
+ product_ids: [],
+ rules: [:id, :type, { preferences: {} }],
+ prices: [:id, :variant_id, :currency, :amount, :compare_at_amount]
+ )
+ )
+ end
+
+ private
+
+ # Loads the record without the action-derived authorization
+ # `set_resource` runs (which would check `:activate` /
+ # `:deactivate` / `:prices` — actions that abilities don't
+ # grant). The per-action methods below explicitly call
+ # `authorize!` with the standard action that ability rules
+ # actually mention (`:update` / `:read`).
+ def load_member_resource
+ @resource = find_resource
+ end
+
+ # Hand-rolled flat shape for the spreadsheet — keeps the payload
+ # narrow (no nested variant/product/option_value objects) and
+ # avoids paying for the admin Price serializer when we only need
+ # ~6 fields per row. The grouping the UI does (rows → product
+ # header) is driven entirely off `product_id`/`product_name`.
+ def serialize_price(price)
+ variant = price.variant
+ product = variant.product
+ {
+ id: price.prefixed_id,
+ variant_id: variant.prefixed_id,
+ product_id: product.prefixed_id,
+ product_name: product.name,
+ variant_label: variant.options_text.presence,
+ sku: variant.sku,
+ currency: price.currency,
+ amount: price.amount&.to_s,
+ compare_at_amount: price.compare_at_amount&.to_s
+ }
+ end
+
+ end
+ end
+ end
+ end
+end
diff --git a/spree/api/app/controllers/spree/api/v3/admin/prices_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/prices_controller.rb
new file mode 100644
index 0000000000..2609d57358
--- /dev/null
+++ b/spree/api/app/controllers/spree/api/v3/admin/prices_controller.rb
@@ -0,0 +1,129 @@
+module Spree
+ module Api
+ module V3
+ module Admin
+ # Admin CRUD for `Spree::Price`. Covers both base prices
+ # (`price_list_id: nil`) and price-list overrides under one
+ # resource, filtered via Ransack predicates on the index.
+ class PricesController < ResourceController
+ include Spree::Api::V3::BulkOperations
+
+ scoped_resource :products
+
+ before_action :require_ids!, only: [:bulk_destroy]
+ before_action :require_prices!, only: [:bulk_upsert]
+
+ # Bulk-upserts prices on the unique-key triple
+ # `(variant_id, currency, price_list_id)`.
+ #
+ # @return [void]
+ def bulk_upsert
+ authorize! :create, Spree::Price
+ authorize! :update, Spree::Price
+
+ rows = Array(params[:prices]).map { |row| decode_price_row(row) }
+ invalid = rows.each_with_index.filter_map do |row, idx|
+ missing = %i[variant_id currency].reject { |k| row[k].present? }
+ { index: idx, missing: missing } if missing.any?
+ end
+ if invalid.any?
+ return render_error(
+ code: 'invalid_prices',
+ message: 'Each row must include variant_id and currency.',
+ status: :unprocessable_content,
+ details: { rows: invalid }
+ )
+ end
+
+ result = Spree::Prices::BulkUpsert.call(rows: rows)
+ render json: result.value
+ end
+
+ # Soft-deletes the listed prices.
+ #
+ # @return [void]
+ def bulk_destroy
+ authorize! :destroy, Spree::Price
+
+ destroy_scope = scope.where(id: decode_ids(params[:ids]))
+ destroyed = destroy_scope.count(&:destroy)
+
+ render json: { price_count: destroyed }
+ end
+
+ protected
+
+ def model_class
+ Spree::Price
+ end
+
+ def serializer_class
+ Spree.api.admin_price_serializer
+ end
+
+ def collection_includes
+ {
+ variant: [
+ :tax_category,
+ :prices,
+ product: :tax_category,
+ option_values: :option_type,
+ stock_items: [:stock_location, :active_stock_reservations]
+ ]
+ }
+ end
+
+ # Disabled: Ransack's default `result(distinct: true)` makes
+ # Postgres reject `sort=variant_product_name` because the order
+ # column isn't in the DISTINCT select list. The store scope
+ # already guarantees one Price row per result.
+ def collection_distinct?
+ false
+ end
+
+ def permitted_params
+ normalize_params(
+ params.permit(:variant_id, :currency, :amount, :compare_at_amount, :price_list_id)
+ )
+ end
+
+ private
+
+ def bulk_record_count_key
+ :price_count
+ end
+
+ def require_prices!
+ return if params.key?(:prices)
+
+ render_error(
+ code: 'missing_prices',
+ message: 'prices is required (send an empty array to no-op).',
+ status: :unprocessable_content
+ )
+ end
+
+ def decode_price_row(row)
+ row = row.respond_to?(:to_unsafe_h) ? row.to_unsafe_h : row.to_h
+ row = row.with_indifferent_access
+
+ {
+ id: decode_id(row[:id]),
+ variant_id: decode_id(row[:variant_id]),
+ price_list_id: row.key?(:price_list_id) ? decode_id(row[:price_list_id]) : nil,
+ currency: row[:currency],
+ amount: row[:amount],
+ compare_at_amount: row[:compare_at_amount]
+ }.compact
+ end
+
+ def decode_id(value)
+ return nil if value.blank?
+
+ Spree::PrefixedId.prefixed_id?(value) ? Spree::PrefixedId.decode_prefixed_id(value) : value
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/spree/api/app/controllers/spree/api/v3/resource_controller.rb b/spree/api/app/controllers/spree/api/v3/resource_controller.rb
index 7c5e47ec8a..e81c144bab 100644
--- a/spree/api/app/controllers/spree/api/v3/resource_controller.rb
+++ b/spree/api/app/controllers/spree/api/v3/resource_controller.rb
@@ -253,7 +253,22 @@ module Spree
else
model_class.for_store(current_store)
end
- base_scope = base_scope.accessible_by(current_ability, :show) unless @parent.present?
+ unless @parent.present?
+ action_name = case request.method
+ when 'GET', 'HEAD'
+ :show
+ when 'POST'
+ :create
+ when 'PATCH', 'PUT'
+ :update
+ when 'DELETE'
+ :destroy
+ else
+ raise ActionController::MethodNotAllowed, request.method
+ end
+
+ base_scope = base_scope.accessible_by(current_ability, action_name)
+ end
base_scope = base_scope.includes(scope_includes) if scope_includes.any?
base_scope = base_scope.preload_associations_lazily
model_class.include?(Spree::TranslatableResource) ? base_scope.i18n : base_scope
diff --git a/spree/api/app/serializers/spree/api/v3/admin/price_list_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/price_list_serializer.rb
new file mode 100644
index 0000000000..7ed426a4ac
--- /dev/null
+++ b/spree/api/app/serializers/spree/api/v3/admin/price_list_serializer.rb
@@ -0,0 +1,51 @@
+module Spree
+ module Api
+ module V3
+ module Admin
+ # Serializes Spree::PriceList for the admin pricing surface.
+ # Price lists are admin-only — there's no Store API counterpart;
+ # storefront callers only ever see the *resolved* price (see
+ # PriceSerializer#price_list_id), never the list itself.
+ class PriceListSerializer < V3::BaseSerializer
+ typelize name: :string,
+ description: 'string | null',
+ status: :string,
+ position: :number,
+ starts_at: 'string | null',
+ ends_at: 'string | null',
+ deleted_at: 'string | null',
+ match_policy: :string,
+ currently_active: :boolean,
+ products_count: :number,
+ prices_count: :number,
+ product_ids: [:string, multi: true]
+
+ attributes :name, :description, :status, :position, :match_policy,
+ starts_at: :iso8601, ends_at: :iso8601, deleted_at: :iso8601,
+ created_at: :iso8601, updated_at: :iso8601
+
+ attribute :currently_active, &:currently_active?
+
+ # Cheap counts so the index can render "12 products / 36 prices"
+ # without forcing each row to expand the children.
+ attribute :products_count do |pl|
+ pl.products.count
+ end
+
+ attribute :prices_count do |pl|
+ pl.prices.count
+ end
+
+ # Prefixed product ids in the list — drives the SPA's
+ # Products picker pre-fill, and is the same payload the
+ # client ships back on PATCH to reconcile membership.
+ attribute :product_ids, &:product_prefixed_ids
+
+ many :price_rules,
+ resource: Spree.api.admin_price_rule_serializer,
+ if: proc { expand?('price_rules') }
+ end
+ end
+ end
+ end
+end
diff --git a/spree/api/app/serializers/spree/api/v3/admin/price_rule_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/price_rule_serializer.rb
new file mode 100644
index 0000000000..6aebc75ee5
--- /dev/null
+++ b/spree/api/app/serializers/spree/api/v3/admin/price_rule_serializer.rb
@@ -0,0 +1,40 @@
+module Spree
+ module Api
+ module V3
+ module Admin
+ # Serializes Spree::PriceRule (STI subclasses live under Spree::PriceRules).
+ # Same shape as PromotionRuleSerializer so the SPA can drive both
+ # editors from one generic preference-form component.
+ class PriceRuleSerializer < V3::BaseSerializer
+ typelize type: :string,
+ price_list_id: :string,
+ preferences: 'Record<string, unknown>',
+ preference_schema: 'Array<{ key: string; type: string; default: unknown }>',
+ label: :string,
+ description: 'string | null'
+
+ attributes created_at: :iso8601, updated_at: :iso8601
+
+ attribute :type do |rule|
+ rule.class.api_type
+ end
+
+ attribute :price_list_id do |rule|
+ rule.price_list&.prefixed_id
+ end
+
+ attribute :preferences, &:serialized_preferences
+ attribute :preference_schema, &:serialized_preference_schema
+
+ attribute :label do |rule|
+ rule.class.respond_to?(:human_name) ? rule.class.human_name : rule.class.to_s.demodulize
+ end
+
+ attribute :description do |rule|
+ rule.class.respond_to?(:description) ? rule.class.description : nil
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/spree/api/config/routes.rb b/spree/api/config/routes.rb
index 0b6f7d231b..b6819c3c6d 100644
--- a/spree/api/config/routes.rb
+++ b/spree/api/config/routes.rb
@@ -246,10 +246,27 @@ Spree::Core::Engine.add_routes do
# Customer groups (segmentation; used by promotion rules + bulk customer ops)
resources :customer_groups
- # Gift cards (admin-issued; redemption + apply lives under :orders)
+ # Price lists
+ resources :price_lists do
+ collection do
+ get :price_rule_types
+ end
+ member do
+ patch :activate
+ patch :deactivate
+ end
+ end
+
+ # Prices (generic — covers base prices AND price-list overrides).
+ resources :prices do
+ collection do
+ post :bulk_upsert
+ delete :bulk_destroy
+ end
+ end
+
+ # Gift cards
resources :gift_cards
- # Bulk-issue batches: create generates `codes_count` cards inline
- # (or via background job when >`gift_card_batch_web_limit`).
resources :gift_card_batches, only: [:index, :show, :create]
# Variants (top-level, for search/autocomplete across all products)
diff --git a/spree/api/lib/spree/api/dependencies.rb b/spree/api/lib/spree/api/dependencies.rb
index 29dc882f9f..6ff86ccfec 100644
--- a/spree/api/lib/spree/api/dependencies.rb
+++ b/spree/api/lib/spree/api/dependencies.rb
@@ -213,6 +213,8 @@ module Spree
admin_promotion_action_serializer: 'Spree::Api::V3::Admin::PromotionActionSerializer',
admin_promotion_rule_serializer: 'Spree::Api::V3::Admin::PromotionRuleSerializer',
admin_coupon_code_serializer: 'Spree::Api::V3::Admin::CouponCodeSerializer',
+ admin_price_list_serializer: 'Spree::Api::V3::Admin::PriceListSerializer',
+ admin_price_rule_serializer: 'Spree::Api::V3::Admin::PriceRuleSerializer',
# platform serializers
platform_metafield_serializer: 'Spree::Api::V2::Platform::MetafieldSerializer',
diff --git a/spree/api/lib/spree/api/openapi/schema_helper.rb b/spree/api/lib/spree/api/openapi/schema_helper.rb
index ecccf8fa12..7e6fd5233c 100644
--- a/spree/api/lib/spree/api/openapi/schema_helper.rb
+++ b/spree/api/lib/spree/api/openapi/schema_helper.rb
@@ -221,6 +221,7 @@ module Spree
patch_admin_user_schema(schemas)
patch_promotion_rule_schema(schemas)
patch_promotion_action_schema(schemas)
+ patch_price_rule_schema(schemas)
schemas
end
end
@@ -280,6 +281,13 @@ module Spree
patch_preference_schema(rule)
end
+ def patch_price_rule_schema(schemas)
+ rule = schemas['PriceRule'] || schemas[:PriceRule]
+ return unless rule
+
+ patch_preference_schema(rule)
+ end
+
def patch_promotion_action_schema(schemas)
action = schemas['PromotionAction'] || schemas[:PromotionAction]
return unless action
diff --git a/spree/api/spec/controllers/spree/api/v3/admin/price_lists_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/price_lists_controller_spec.rb
new file mode 100644
index 0000000000..6430fa3514
--- /dev/null
+++ b/spree/api/spec/controllers/spree/api/v3/admin/price_lists_controller_spec.rb
@@ -0,0 +1,183 @@
+require 'spec_helper'
+
+RSpec.describe Spree::Api::V3::Admin::PriceListsController, type: :controller do
+ render_views
+
+ include_context 'API v3 Admin authenticated'
+
+ let!(:price_list) { create(:price_list, store: store, name: 'Wholesale') }
+
+ before { request.headers.merge!(headers) }
+
+ describe 'POST #create — one-shot creation' do
+ let(:customer_group) { create(:customer_group, store: store) }
+
+ context 'admin UI shape (product_ids + rules)' do
+ let(:product1) { create(:product, stores: [store]) }
+ let(:product2) { create(:product, stores: [store]) }
+
+ it 'persists metadata, products, and rules in one request' do
+ post :create,
+ params: {
+ name: 'EU wholesale',
+ description: 'B2B verified customers',
+ match_policy: 'all',
+ product_ids: [product1.prefixed_id, product2.prefixed_id],
+ rules: [
+ {
+ type: 'customer_group_rule',
+ preferences: { customer_group_ids: [customer_group.prefixed_id] }
+ },
+ { type: 'volume_rule', preferences: { min_quantity: 10 } }
+ ]
+ },
+ as: :json
+
+ expect(response).to have_http_status(:created)
+ list = Spree::PriceList.for_store(store).find_by!(name: 'EU wholesale')
+ expect(list.match_policy).to eq('all')
+ expect(list.products).to contain_exactly(product1, product2)
+ expect(list.price_rules.length).to eq(2)
+ cg_rule = list.price_rules.find { |r| r.is_a?(Spree::PriceRules::CustomerGroupRule) }
+ volume_rule = list.price_rules.find { |r| r.is_a?(Spree::PriceRules::VolumeRule) }
+ expect(cg_rule.preferred_customer_group_ids).to contain_exactly(customer_group.id)
+ expect(volume_rule.preferred_min_quantity).to eq(10)
+ end
+ end
+
+ context 'server-to-server shape (rules + prices, no product_ids)' do
+ # The natural API shape when the caller already knows per-variant
+ # prices. Variants in `prices` implicitly become part of the list
+ # via the unique-key upsert — no separate `product_ids` round trip.
+ let(:product) { create(:product, stores: [store]) }
+ let(:variant_a) { product.master }
+ let(:variant_b) { create(:variant, product: product) }
+
+ it 'persists metadata, rules, and prices in one request' do
+ post :create,
+ params: {
+ name: 'EU wholesale',
+ match_policy: 'all',
+ rules: [{ type: 'volume_rule', preferences: { min_quantity: 10 } }],
+ prices: [
+ {
+ variant_id: variant_a.prefixed_id,
+ currency: 'USD',
+ amount: '19.99',
+ compare_at_amount: '24.99'
+ },
+ {
+ variant_id: variant_b.prefixed_id,
+ currency: 'USD',
+ amount: '21.99'
+ }
+ ]
+ },
+ as: :json
+
+ expect(response).to have_http_status(:created)
+ list = Spree::PriceList.for_store(store).find_by!(name: 'EU wholesale')
+
+ rows = list.prices.where(currency: 'USD').to_a
+ a_row = rows.find { |r| r.variant_id == variant_a.id }
+ b_row = rows.find { |r| r.variant_id == variant_b.id }
+ expect(a_row.amount).to eq(BigDecimal('19.99'))
+ expect(a_row.compare_at_amount).to eq(BigDecimal('24.99'))
+ expect(b_row.amount).to eq(BigDecimal('21.99'))
+
+ expect(list.price_rules.length).to eq(1)
+ expect(list.price_rules.first).to be_a(Spree::PriceRules::VolumeRule)
+ end
+ end
+ end
+
+ describe 'PATCH #update — prices nullability contract' do
+ let(:product) { create(:product, stores: [store]) }
+ let(:variant) { product.master }
+ # Seed an existing override so we can prove it survives or gets
+ # cleared depending on the request shape.
+ let!(:price) do
+ price_list.prices.create!(
+ variant: variant,
+ currency: 'USD',
+ amount: BigDecimal('42.00'),
+ compare_at_amount: BigDecimal('50.00')
+ )
+ end
+
+ context 'when the prices key is omitted entirely' do
+ # The naive bug is: `prices=` runs unconditionally and treats a
+ # missing key the same as `[]`, blanking everything out. Guard
+ # against it by leaving the rest of the update alone.
+ it 'leaves existing overrides untouched' do
+ patch :update, params: { id: price_list.prefixed_id, name: 'Renamed' }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(price_list.reload.name).to eq('Renamed')
+ expect(price.reload.amount).to eq(BigDecimal('42.00'))
+ expect(price.compare_at_amount).to eq(BigDecimal('50.00'))
+ end
+ end
+
+ context 'when prices is explicitly an empty array' do
+ # The flip side: an empty array is a clear-intent signal. The
+ # spreadsheet UI uses this when the user wipes every cell and saves.
+ it 'clears amount and compare_at_amount on every existing override' do
+ patch :update, params: { id: price_list.prefixed_id, prices: [] }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(price.reload.amount).to be_nil
+ expect(price.compare_at_amount).to be_nil
+ end
+
+ it 'keeps the price rows themselves' do
+ # The unique index on (variant_id, currency, price_list_id) means
+ # we can't safely hard-delete and re-create the row on the next
+ # save — so the clear-intent path nulls amounts in place.
+ expect {
+ patch :update, params: { id: price_list.prefixed_id, prices: [] }, as: :json
+ }.not_to change { price_list.prices.count }
+ end
+ end
+
+ context 'when prices carries an upsert row' do
+ it 'updates the listed row only' do
+ patch :update,
+ params: {
+ id: price_list.prefixed_id,
+ prices: [{
+ id: price.prefixed_id,
+ variant_id: variant.prefixed_id,
+ currency: 'USD',
+ amount: '19.99',
+ compare_at_amount: '24.99'
+ }]
+ },
+ as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(price.reload.amount).to eq(BigDecimal('19.99'))
+ expect(price.compare_at_amount).to eq(BigDecimal('24.99'))
+ end
+
+ it 'ignores rows whose id is not in this list' do
+ other_list = create(:price_list, store: store)
+ foreign_price = other_list.prices.create!(
+ variant: variant, currency: 'USD', amount: BigDecimal('1.00')
+ )
+
+ patch :update,
+ params: {
+ id: price_list.prefixed_id,
+ prices: [{ id: foreign_price.prefixed_id, amount: '9.99' }]
+ },
+ as: :json
+
+ expect(response).to have_http_status(:ok)
+ # The foreign row was not in this list's `prices` scope, so the
+ # bulk upsert silently skipped it rather than reaching across.
+ expect(foreign_price.reload.amount).to eq(BigDecimal('1.00'))
+ end
+ end
+ end
+end
diff --git a/spree/api/spec/controllers/spree/api/v3/admin/prices_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/prices_controller_spec.rb
new file mode 100644
index 0000000000..195ec42489
--- /dev/null
+++ b/spree/api/spec/controllers/spree/api/v3/admin/prices_controller_spec.rb
@@ -0,0 +1,298 @@
+require 'spec_helper'
+
+RSpec.describe Spree::Api::V3::Admin::PricesController, type: :controller do
+ render_views
+
+ include_context 'API v3 Admin authenticated'
+
+ let(:price_list) { create(:price_list, store: store) }
+ let(:product) { create(:product, stores: [store]) }
+ let(:variant) { product.master }
+
+ before { request.headers.merge!(headers) }
+
+ describe 'GET #index' do
+ # The product factory seeds a USD base price on `master` for the
+ # store's default currency, so we reuse it instead of inserting one
+ # (the unique index on `(variant_id, currency, price_list_id)` blocks
+ # duplicates).
+ let!(:base_price) { variant.prices.find_by!(currency: 'USD', price_list_id: nil) }
+ let!(:list_price) do
+ create(:price, variant: variant, price_list: price_list, currency: 'USD', amount: 5.0)
+ end
+
+ it 'returns prices scoped to the current store' do
+ get :index, as: :json
+
+ expect(response).to have_http_status(:ok)
+ ids = json_response['data'].map { |p| p['id'] }
+ expect(ids).to include(base_price.prefixed_id, list_price.prefixed_id)
+ end
+
+ it 'filters by price_list_id via Ransack' do
+ get :index, params: { q: { price_list_id_eq: price_list.id } }, as: :json
+
+ ids = json_response['data'].map { |p| p['id'] }
+ expect(ids).to eq([list_price.prefixed_id])
+ end
+
+ it 'filters by currency via Ransack' do
+ # A second currency on a different variant — same variant + EUR
+ # would conflict with the factory-seeded USD master price if Spree
+ # auto-mirrored currencies, but it doesn't.
+ eur_variant = create(:variant, product: product)
+ eur_price = create(:price, variant: eur_variant, currency: 'EUR', amount: 9.0)
+
+ get :index, params: { q: { currency_eq: 'USD' } }, as: :json
+
+ ids = json_response['data'].map { |p| p['id'] }
+ expect(ids).not_to include(eur_price.prefixed_id)
+ end
+
+ # Regression: `sort=variant_product_name,variant_id` is what the SPA
+ # spreadsheet ships. The original scope used `joins(... :stores).distinct`
+ # plus Ransack's default `result(distinct: true)`, which Postgres
+ # rejects when ORDER BY references a column outside the DISTINCT
+ # select list (SQLite is permissive and the test missed it). We
+ # assert the SQL no longer carries DISTINCT — that's the durable
+ # invariant across both databases.
+ it 'sorts by variant product name without raising' do
+ other_product = create(:product, stores: [store], name: 'AAA')
+ other_price = other_product.master.prices.find_by!(currency: 'USD', price_list_id: nil)
+
+ get :index, params: { sort: 'variant_product_name,variant_id' }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ ids = json_response['data'].map { |p| p['id'] }
+ expect(ids).to include(base_price.prefixed_id, other_price.prefixed_id)
+ end
+
+ it 'excludes prices from other stores' do
+ other_store = create(:store)
+ other_product = create(:product, stores: [other_store])
+ other_price = other_product.master.prices.find_by!(currency: 'USD', price_list_id: nil)
+
+ get :index, as: :json
+
+ ids = json_response['data'].map { |p| p['id'] }
+ expect(ids).not_to include(other_price.prefixed_id)
+ end
+ end
+
+ describe 'POST #bulk_upsert' do
+ context 'when the prices key is omitted entirely' do
+ it 'returns 422 with a missing_prices error' do
+ post :bulk_upsert, as: :json
+
+ expect(response).to have_http_status(:unprocessable_content)
+ expect(json_response['error']['code']).to eq('missing_prices')
+ end
+ end
+
+ context 'when the unique-key triple matches an existing row' do
+ let!(:existing) do
+ create(:price, variant: variant, price_list: price_list, currency: 'USD', amount: 5.0)
+ end
+
+ it 'updates the matching row via the unique key' do
+ post :bulk_upsert,
+ params: {
+ prices: [
+ {
+ variant_id: variant.prefixed_id,
+ currency: 'USD',
+ price_list_id: price_list.prefixed_id,
+ amount: '7.50'
+ }
+ ]
+ },
+ as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(json_response).to eq('price_count' => 1)
+ expect(existing.reload.amount).to eq(BigDecimal('7.50'))
+ end
+ end
+
+ context 'when no row exists at the unique key' do
+ # `change(Spree::Price, :count).by(1)` is brittle here — variant-level
+ # `infer_price` callbacks can mirror a new currency into the base set,
+ # bumping the count by 2 deterministically. We assert on the *specific*
+ # row instead (target by the unique key) so the test stays focused.
+ it 'creates a new row' do
+ post :bulk_upsert,
+ params: {
+ prices: [
+ {
+ variant_id: variant.prefixed_id,
+ currency: 'EUR',
+ price_list_id: price_list.prefixed_id,
+ amount: '4.20'
+ }
+ ]
+ },
+ as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(json_response).to eq('price_count' => 1)
+ row = Spree::Price.find_by(variant_id: variant.id, currency: 'EUR', price_list_id: price_list.id)
+ expect(row).not_to be_nil
+ expect(row.amount).to eq(BigDecimal('4.20'))
+ end
+
+ it 'creates a base price (price_list_id null)' do
+ post :bulk_upsert,
+ params: {
+ prices: [
+ {
+ variant_id: variant.prefixed_id,
+ currency: 'EUR',
+ amount: '8.99'
+ }
+ ]
+ },
+ as: :json
+
+ expect(response).to have_http_status(:ok)
+ base = Spree::Price.find_by(variant_id: variant.id, currency: 'EUR', price_list_id: nil)
+ expect(base).not_to be_nil
+ expect(base.amount).to eq(BigDecimal('8.99'))
+ end
+ end
+
+ context 'when amounts are locale-formatted strings' do
+ # `Spree::LocalizedNumber.parse` is locale-aware: en-US uses
+ # `.` for the decimal and `,` for the thousands delimiter; many
+ # EU locales swap them. The bulk endpoint must handle either
+ # without coercing to zero.
+
+ it 'parses en-US style "1,234.56" correctly' do
+ I18n.with_locale(:en) do
+ post :bulk_upsert,
+ params: {
+ prices: [{
+ variant_id: variant.prefixed_id,
+ currency: 'USD',
+ price_list_id: price_list.prefixed_id,
+ amount: '1,234.56'
+ }]
+ },
+ as: :json
+ end
+
+ expect(response).to have_http_status(:ok)
+ row = Spree::Price.find_by(
+ variant_id: variant.id, currency: 'USD', price_list_id: price_list.id
+ )
+ expect(row.amount).to eq(BigDecimal('1234.56'))
+ end
+
+ it 'parses an alternate-locale "1.234,56" correctly' do
+ # Stub the i18n format directly rather than switching locales —
+ # not every test env loads non-English locale files, and we're
+ # testing the parser's locale-awareness, not Spree's translations.
+ allow(I18n).to receive(:t).and_call_original
+ allow(I18n).to receive(:t).with(
+ [:'number.currency.format.separator', :'number.currency.format.delimiter']
+ ).and_return([',', '.'])
+
+ post :bulk_upsert,
+ params: {
+ prices: [{
+ variant_id: variant.prefixed_id,
+ currency: 'EUR',
+ price_list_id: price_list.prefixed_id,
+ amount: '1.234,56'
+ }]
+ },
+ as: :json
+
+ expect(response).to have_http_status(:ok)
+ row = Spree::Price.find_by(
+ variant_id: variant.id, currency: 'EUR', price_list_id: price_list.id
+ )
+ expect(row.amount).to eq(BigDecimal('1234.56'))
+ end
+
+ it 'parses compare_at_amount in the same locale as amount' do
+ allow(I18n).to receive(:t).and_call_original
+ allow(I18n).to receive(:t).with(
+ [:'number.currency.format.separator', :'number.currency.format.delimiter']
+ ).and_return([',', '.'])
+
+ post :bulk_upsert,
+ params: {
+ prices: [{
+ variant_id: variant.prefixed_id,
+ currency: 'EUR',
+ price_list_id: price_list.prefixed_id,
+ amount: '99,99',
+ compare_at_amount: '149,99'
+ }]
+ },
+ as: :json
+
+ expect(response).to have_http_status(:ok)
+ row = Spree::Price.find_by(
+ variant_id: variant.id, currency: 'EUR', price_list_id: price_list.id
+ )
+ expect(row.amount).to eq(BigDecimal('99.99'))
+ expect(row.compare_at_amount).to eq(BigDecimal('149.99'))
+ end
+ end
+
+ context 'when targeting a row in a sibling list' do
+ let(:other_list) { create(:price_list, store: store) }
+ let!(:foreign) do
+ create(:price, variant: variant, price_list: other_list, currency: 'USD', amount: 99.0)
+ end
+
+ it 'allows updates within the store but the row stays in its list' do
+ post :bulk_upsert,
+ params: {
+ prices: [{
+ variant_id: variant.prefixed_id,
+ currency: 'USD',
+ price_list_id: other_list.prefixed_id,
+ amount: '50.00'
+ }]
+ },
+ as: :json
+
+ expect(response).to have_http_status(:ok)
+ # `Spree::Price` is a cross-cutting resource — the price-list-list
+ # scope is just a Ransack filter. Targeting a row in another
+ # list is fine; what matters is the row stays where it was.
+ expect(foreign.reload.amount).to eq(BigDecimal('50.00'))
+ expect(foreign.price_list_id).to eq(other_list.id)
+ end
+ end
+ end
+
+ describe 'DELETE #bulk_destroy' do
+ let!(:to_delete) do
+ create(:price, variant: variant, price_list: price_list, currency: 'USD', amount: 5.0)
+ end
+ let!(:to_keep) do
+ create(:price, variant: variant, price_list: price_list, currency: 'EUR', amount: 4.0)
+ end
+
+ it 'soft-deletes the listed prices and reports the count' do
+ delete :bulk_destroy,
+ params: { ids: [to_delete.prefixed_id] },
+ as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(json_response['price_count']).to eq(1)
+ expect(to_delete.reload.deleted_at).not_to be_nil
+ expect(to_keep.reload.deleted_at).to be_nil
+ end
+
+ it 'returns 422 when ids is missing' do
+ delete :bulk_destroy, as: :json
+
+ expect(response).to have_http_status(:unprocessable_content)
+ expect(json_response['error']['code']).to eq('missing_ids')
+ end
+ end
+end
diff --git a/spree/api/spec/controllers/spree/api/v3/resource_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/resource_controller_spec.rb
new file mode 100644
index 0000000000..626a9943a4
--- /dev/null
+++ b/spree/api/spec/controllers/spree/api/v3/resource_controller_spec.rb
@@ -0,0 +1,97 @@
+require 'spec_helper'
+
+# Unit spec for `Spree::Api::V3::ResourceController#scope` — the base
+# scope-resolution method shared by every admin/store resource. The
+# new behavior (post-`scope_for` removal in subclasses) infers the
+# CanCanCan action from `request.method` and narrows the relation
+# via `accessible_by`, but only when there's no `@parent` (nested
+# resources defer to their parent's authorization).
+RSpec.describe Spree::Api::V3::ResourceController, type: :controller do
+ # Minimal subclass — we only need `model_class` and a way to call
+ # `scope` from outside.
+ controller(described_class) do
+ def model_class
+ Spree::TaxCategory
+ end
+
+ public :scope
+ end
+
+ let(:store) { @default_store || create(:store, default: true) }
+ let!(:default_tax_category) { create(:tax_category, name: 'Default', is_default: true) }
+ let!(:other_tax_category) { create(:tax_category, name: 'Other') }
+
+ before do
+ allow(controller).to receive(:current_store).and_return(store)
+ end
+
+ describe '#scope without @parent' do
+ # Each HTTP method should narrow with a different CanCanCan action.
+ # We prove that by giving the ability rule a different visible set
+ # per action and asserting which slice comes back.
+ {
+ 'GET' => :show,
+ 'HEAD' => :show,
+ 'POST' => :create,
+ 'PATCH' => :update,
+ 'PUT' => :update,
+ 'DELETE' => :destroy
+ }.each do |http_method, expected_action|
+ it "narrows via accessible_by(_, :#{expected_action}) on #{http_method}" do
+ ability = Spree::Ability.new(nil)
+ ability.cannot :manage, Spree::TaxCategory
+ # Only the expected action sees the default record; every other
+ # action sees nothing. If the method-to-action mapping is wrong,
+ # the wrong slice will be returned.
+ ability.can expected_action, Spree::TaxCategory, is_default: true
+ allow(controller).to receive(:current_ability).and_return(ability)
+ allow(request).to receive(:method).and_return(http_method)
+
+ ids = controller.scope.pluck(:id)
+
+ expect(ids).to contain_exactly(default_tax_category.id)
+ end
+ end
+
+ it 'raises MethodNotAllowed (405) on unsupported HTTP methods' do
+ allow(controller).to receive(:current_ability).and_return(Spree::Ability.new(nil))
+ allow(request).to receive(:method).and_return('TRACE')
+
+ expect { controller.scope }.to raise_error(ActionController::MethodNotAllowed)
+ end
+
+ it 'returns a model_class relation' do
+ allow(controller).to receive(:current_ability).and_return(Spree::Ability.new(nil))
+ allow(request).to receive(:method).and_return('GET')
+
+ expect(controller.scope).to be_a(ActiveRecord::Relation)
+ expect(controller.scope.klass).to eq(Spree::TaxCategory)
+ end
+ end
+
+ describe '#scope with @parent' do
+ # When loading a nested resource the parent is assumed to have
+ # been authorized at `set_parent` time — the per-action narrowing
+ # is deliberately skipped so the parent's permission set wins.
+ let(:promotion) { create(:promotion) }
+
+ before do
+ controller.instance_variable_set(:@parent, promotion)
+ allow(controller).to receive(:parent_association).and_return(:promotion_rules)
+ # Anything the controller forwards into accessible_by would be a
+ # bug now — block it loudly rather than letting the test pass
+ # quietly by coincidence.
+ allow_any_instance_of(ActiveRecord::Relation).to receive(:accessible_by).and_wrap_original do |_method, *|
+ raise 'accessible_by should not be called when @parent is present'
+ end
+ # `request.method` would matter for the ability branch; assert
+ # the branch is skipped regardless of method.
+ allow(request).to receive(:method).and_return('DELETE')
+ end
+
+ it 'returns the parent association without invoking accessible_by' do
+ expect { controller.scope }.not_to raise_error
+ expect(controller.scope.klass).to eq(Spree::PromotionRule)
+ end
+ end
+end
diff --git a/spree/api/spec/integration/spree/api/v3/admin/price_lists_spec.rb b/spree/api/spec/integration/spree/api/v3/admin/price_lists_spec.rb
new file mode 100644
index 0000000000..db07b2a060
--- /dev/null
+++ b/spree/api/spec/integration/spree/api/v3/admin/price_lists_spec.rb
@@ -0,0 +1,477 @@
+# frozen_string_literal: true
+
+require 'swagger_helper'
+
+RSpec.describe 'Admin Price Lists API', type: :request, swagger_doc: 'api-reference/admin.yaml' do
+ include_context 'API v3 Admin'
+
+ let(:Authorization) { "Bearer #{admin_jwt_token}" }
+ let!(:price_list) { create(:price_list, store: store, name: 'Wholesale') }
+ let!(:other_list) { create(:price_list, store: store, name: 'Holiday') }
+
+ path '/api/v3/admin/price_lists' do
+ get 'List price lists' do
+ tags 'Pricing'
+ produces 'application/json'
+ security [api_key: [], bearer_auth: []]
+ description 'Returns the price lists configured for the current store.'
+ admin_scope :read, :products
+
+ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true
+ parameter name: :Authorization, in: :header, type: :string, required: true
+ parameter name: :page, in: :query, type: :integer, required: false
+ parameter name: :limit, in: :query, type: :integer, required: false
+ parameter name: :'q[name_cont]', in: :query, type: :string, required: false
+ parameter name: :'q[status_eq]', in: :query, type: :string, required: false
+ parameter name: :sort, in: :query, type: :string, required: false
+ parameter name: :expand, in: :query, type: :string, required: false,
+ description: 'Comma-separated associations to embed. Supported: `price_rules`.'
+
+ response '200', 'price lists found' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+
+ schema SwaggerSchemaHelpers.paginated('PriceList')
+
+ run_test! do |response|
+ data = JSON.parse(response.body)
+ ids = data['data'].pluck('id')
+ expect(ids).to include(price_list.prefixed_id, other_list.prefixed_id)
+ end
+ end
+ end
+
+ post 'Create a price list' do
+ tags 'Pricing'
+ consumes 'application/json'
+ produces 'application/json'
+ security [api_key: [], bearer_auth: []]
+ description 'Creates a new draft price list.'
+ admin_scope :write, :products
+
+ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true
+ parameter name: :Authorization, in: :header, type: :string, required: true
+ parameter name: :body, in: :body, schema: {
+ type: :object,
+ required: %w[name],
+ properties: {
+ name: { type: :string, example: 'EU wholesale' },
+ description: { type: :string, nullable: true },
+ starts_at: { type: :string, nullable: true, example: '2026-06-01T00:00:00Z' },
+ ends_at: { type: :string, nullable: true, example: '2026-09-01T00:00:00Z' },
+ match_policy: { type: :string, enum: %w[all any], example: 'all' },
+ position: { type: :integer, example: 1 },
+ product_ids: {
+ type: :array,
+ items: { type: :string },
+ description: 'Prefixed product ids to seed the list with.',
+ example: ['prod_aBc123']
+ },
+ rules: {
+ type: :array,
+ description: 'STI-typed price rules to attach on create. Existing rules ' \
+ 'on the same payload via PATCH reconcile by id.',
+ items: {
+ type: :object,
+ required: %w[type],
+ properties: {
+ type: { type: :string, example: 'volume_rule' },
+ preferences: { type: :object, additionalProperties: true }
+ }
+ }
+ },
+ prices: {
+ type: :array,
+ description: 'Server-to-server alternative to `product_ids`: ship the ' \
+ 'exact per-variant prices the list should contain. Each row ' \
+ 'upserts on the unique key `(variant_id, currency, price_list_id)`. ' \
+ 'Mix-and-match with `product_ids` is supported but typically ' \
+ 'unnecessary — `prices` alone tells the server which variants ' \
+ 'belong to the list and what the override amount is.',
+ items: {
+ type: :object,
+ required: %w[variant_id currency],
+ properties: {
+ variant_id: { type: :string, example: 'variant_xY9' },
+ currency: { type: :string, example: 'USD' },
+ amount: { type: :string, nullable: true, example: '19.99' },
+ compare_at_amount: { type: :string, nullable: true, example: '24.99' }
+ }
+ }
+ }
+ }
+ }
+
+ response '201', 'price list created (one-shot — metadata, schedule, products, rules)' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:product1) { create(:product, stores: [store]) }
+ let(:product2) { create(:product, stores: [store]) }
+ let(:customer_group) { create(:customer_group, store: store) }
+ let(:body) do
+ {
+ name: 'EU wholesale',
+ description: 'B2B verified customers',
+ match_policy: 'all',
+ starts_at: '2026-06-01T00:00:00Z',
+ ends_at: '2026-09-01T00:00:00Z',
+ product_ids: [product1.prefixed_id, product2.prefixed_id],
+ rules: [
+ {
+ type: 'customer_group_rule',
+ preferences: { customer_group_ids: [customer_group.prefixed_id] }
+ },
+ {
+ type: 'volume_rule',
+ preferences: { min_quantity: 10 }
+ }
+ ]
+ }
+ end
+
+ schema '$ref' => '#/components/schemas/PriceList'
+
+ run_test! do |response|
+ data = JSON.parse(response.body)
+ list = Spree::PriceList.for_store(store).find_by_prefix_id!(data['id'])
+ expect(list.name).to eq('EU wholesale')
+ expect(list.match_policy).to eq('all')
+ expect(list.status).to eq('draft')
+ expect(list.products).to contain_exactly(product1, product2)
+ expect(list.price_rules.length).to eq(2)
+ cg_rule = list.price_rules.find { |r| r.is_a?(Spree::PriceRules::CustomerGroupRule) }
+ volume_rule = list.price_rules.find { |r| r.is_a?(Spree::PriceRules::VolumeRule) }
+ expect(cg_rule.preferred_customer_group_ids).to contain_exactly(customer_group.id)
+ expect(volume_rule.preferred_min_quantity).to eq(10)
+ end
+ end
+
+ response '201', 'price list created (server-to-server — rules + prices, no product_ids)' do
+ # The natural API shape when you already know the exact per-variant
+ # prices: skip `product_ids` and ship `prices` directly. Variants
+ # referenced in `prices` implicitly become part of the list.
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:product) { create(:product, stores: [store]) }
+ let(:variant_a) { product.master }
+ let(:variant_b) { create(:variant, product: product) }
+ let(:body) do
+ {
+ name: 'EU wholesale',
+ match_policy: 'all',
+ rules: [
+ { type: 'volume_rule', preferences: { min_quantity: 10 } }
+ ],
+ prices: [
+ {
+ variant_id: variant_a.prefixed_id,
+ currency: 'USD',
+ amount: '19.99',
+ compare_at_amount: '24.99'
+ },
+ {
+ variant_id: variant_b.prefixed_id,
+ currency: 'USD',
+ amount: '21.99'
+ }
+ ]
+ }
+ end
+
+ schema '$ref' => '#/components/schemas/PriceList'
+
+ run_test! do |response|
+ data = JSON.parse(response.body)
+ list = Spree::PriceList.for_store(store).find_by_prefix_id!(data['id'])
+
+ # Two priced rows landed under this list.
+ rows = list.prices.where(currency: 'USD').to_a
+ a_row = rows.find { |r| r.variant_id == variant_a.id }
+ b_row = rows.find { |r| r.variant_id == variant_b.id }
+ expect(a_row.amount).to eq(BigDecimal('19.99'))
+ expect(a_row.compare_at_amount).to eq(BigDecimal('24.99'))
+ expect(b_row.amount).to eq(BigDecimal('21.99'))
+
+ # The rule survived the same payload.
+ expect(list.price_rules.length).to eq(1)
+ expect(list.price_rules.first).to be_a(Spree::PriceRules::VolumeRule)
+ end
+ end
+
+ response '422', 'validation error' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:body) { { name: '' } }
+
+ schema '$ref' => '#/components/schemas/ErrorResponse'
+
+ run_test!
+ end
+ end
+ end
+
+ path '/api/v3/admin/price_lists/{id}' do
+ parameter name: :id, in: :path, type: :string, required: true
+
+ get 'Get a price list' do
+ tags 'Pricing'
+ produces 'application/json'
+ security [api_key: [], bearer_auth: []]
+ admin_scope :read, :products
+
+ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true
+ parameter name: :Authorization, in: :header, type: :string, required: true
+ parameter name: :expand, in: :query, type: :string, required: false
+
+ response '200', 'price list found' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:id) { price_list.prefixed_id }
+
+ schema '$ref' => '#/components/schemas/PriceList'
+
+ run_test! do |response|
+ data = JSON.parse(response.body)
+ expect(data['id']).to eq(price_list.prefixed_id)
+ end
+ end
+
+ response '404', 'price list not found' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:id) { 'pl_nonexistent' }
+
+ schema '$ref' => '#/components/schemas/ErrorResponse'
+
+ run_test!
+ end
+ end
+
+ patch 'Update a price list' do
+ tags 'Pricing'
+ consumes 'application/json'
+ produces 'application/json'
+ security [api_key: [], bearer_auth: []]
+ description <<~DESC
+ Updates a price list. The optional `rules:` array reconciles nested
+ STI-typed price rules in a single round-trip — existing rules update
+ by `id`, new rules build, missing rules destroy. Mirrors the
+ promotion editor's "save the whole thing on Save" pattern.
+ DESC
+ admin_scope :write, :products
+
+ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true
+ parameter name: :Authorization, in: :header, type: :string, required: true
+ parameter name: :body, in: :body, schema: {
+ type: :object,
+ properties: {
+ name: { type: :string },
+ description: { type: :string, nullable: true },
+ starts_at: { type: :string, nullable: true },
+ ends_at: { type: :string, nullable: true },
+ match_policy: { type: :string, enum: %w[all any] },
+ position: { type: :integer },
+ product_ids: {
+ type: :array,
+ items: { type: :string },
+ description: 'Prefixed product ids — reconciles list membership (adds + removes).',
+ example: ['prod_aBc123']
+ },
+ rules: {
+ type: :array,
+ items: {
+ type: :object,
+ required: %w[type],
+ properties: {
+ id: { type: :string, nullable: true },
+ type: { type: :string, example: 'volume_rule' },
+ preferences: { type: :object, additionalProperties: true }
+ }
+ }
+ },
+ prices: {
+ type: :array,
+ description: 'Individual price overrides (the spreadsheet payload). ' \
+ 'Each row updates by `id` if shipped, otherwise upserts ' \
+ 'on the unique key `(variant_id, currency, price_list_id)`.',
+ items: {
+ type: :object,
+ oneOf: [
+ { required: %w[id] },
+ { required: %w[variant_id currency] }
+ ],
+ properties: {
+ id: { type: :string, example: 'price_aBc123' },
+ variant_id: { type: :string, example: 'variant_xY9' },
+ currency: { type: :string, example: 'USD' },
+ amount: { type: :string, nullable: true, example: '12.50' },
+ compare_at_amount: { type: :string, nullable: true, example: '15.00' }
+ }
+ }
+ }
+ }
+ }
+
+ response '200', 'price list updated' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:id) { price_list.prefixed_id }
+ let(:body) { { name: 'Wholesale (Q3)' } }
+
+ schema '$ref' => '#/components/schemas/PriceList'
+
+ run_test! do |response|
+ data = JSON.parse(response.body)
+ expect(data['name']).to eq('Wholesale (Q3)')
+ end
+ end
+
+ response '200', 'price list membership reconciles via product_ids' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:id) { price_list.prefixed_id }
+ let(:kept_product) { create(:product, stores: [store]) }
+ let(:removed_product) { create(:product, stores: [store]) }
+ let(:added_product) { create(:product, stores: [store]) }
+ let(:body) { { product_ids: [kept_product.prefixed_id, added_product.prefixed_id] } }
+
+ before do
+ # Seed the list with kept + removed; PATCH should drop `removed`
+ # and pick up `added` in a single round-trip.
+ price_list.add_products([kept_product.id, removed_product.id])
+ end
+
+ schema '$ref' => '#/components/schemas/PriceList'
+
+ run_test! do
+ products = price_list.reload.products
+ expect(products).to include(kept_product, added_product)
+ expect(products).not_to include(removed_product)
+ end
+ end
+
+ response '200', 'price overrides reconcile via prices' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:id) { price_list.prefixed_id }
+ let(:product) { create(:product, stores: [store]) }
+ let(:variant) { product.master }
+ let!(:placeholder) do
+ create(:price, variant: variant, price_list: price_list, currency: 'USD', amount: nil)
+ end
+ let(:body) do
+ {
+ prices: [
+ {
+ variant_id: variant.prefixed_id,
+ currency: 'USD',
+ amount: '19.99',
+ compare_at_amount: '24.99'
+ }
+ ]
+ }
+ end
+
+ schema '$ref' => '#/components/schemas/PriceList'
+
+ run_test! do
+ rows = Spree::Price.where(
+ variant_id: variant.id, currency: 'USD', price_list_id: price_list.id
+ )
+ expect(rows.count).to eq(1)
+ expect(rows.first.amount).to eq(BigDecimal('19.99'))
+ expect(rows.first.compare_at_amount).to eq(BigDecimal('24.99'))
+ end
+ end
+
+ response '200', 'price list updated with nested rules' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:id) { price_list.prefixed_id }
+ let(:body) do
+ {
+ name: 'Wholesale (Q3)',
+ rules: [
+ { type: 'volume_rule', preferences: { min_quantity: 25 } }
+ ]
+ }
+ end
+
+ schema '$ref' => '#/components/schemas/PriceList'
+
+ run_test! do
+ rules = price_list.reload.price_rules
+ expect(rules.length).to eq(1)
+ expect(rules.first).to be_a(Spree::PriceRules::VolumeRule)
+ expect(rules.first.preferred_min_quantity).to eq(25)
+ end
+ end
+ end
+
+ delete 'Delete a price list' do
+ tags 'Pricing'
+ security [api_key: [], bearer_auth: []]
+ description 'Soft-deletes the price list. Associated prices are removed asynchronously.'
+ admin_scope :write, :products
+
+ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true
+ parameter name: :Authorization, in: :header, type: :string, required: true
+
+ response '204', 'price list deleted' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:id) { price_list.prefixed_id }
+
+ run_test!
+ end
+ end
+ end
+
+ path '/api/v3/admin/price_lists/{id}/activate' do
+ parameter name: :id, in: :path, type: :string, required: true
+
+ patch 'Activate a price list' do
+ tags 'Pricing'
+ produces 'application/json'
+ security [api_key: [], bearer_auth: []]
+ description <<~DESC
+ Transitions a draft / inactive list to `active`. If `starts_at` is
+ in the future the list is marked `scheduled` instead, matching the
+ legacy admin behaviour.
+ DESC
+ admin_scope :write, :products
+
+ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true
+ parameter name: :Authorization, in: :header, type: :string, required: true
+
+ response '200', 'price list activated' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:id) { price_list.prefixed_id }
+
+ schema '$ref' => '#/components/schemas/PriceList'
+
+ run_test! do |response|
+ data = JSON.parse(response.body)
+ expect(data['status']).to eq('active')
+ end
+ end
+ end
+ end
+
+ path '/api/v3/admin/price_lists/{id}/deactivate' do
+ parameter name: :id, in: :path, type: :string, required: true
+
+ patch 'Deactivate a price list' do
+ tags 'Pricing'
+ produces 'application/json'
+ security [api_key: [], bearer_auth: []]
+ admin_scope :write, :products
+
+ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true
+ parameter name: :Authorization, in: :header, type: :string, required: true
+
+ response '200', 'price list deactivated' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:price_list) { create(:price_list, :active, store: store) }
+ let(:id) { price_list.prefixed_id }
+
+ schema '$ref' => '#/components/schemas/PriceList'
+
+ run_test! do |response|
+ data = JSON.parse(response.body)
+ expect(data['status']).to eq('inactive')
+ end
+ end
+ end
+ end
+
+end
diff --git a/spree/api/spec/integration/spree/api/v3/admin/prices_spec.rb b/spree/api/spec/integration/spree/api/v3/admin/prices_spec.rb
new file mode 100644
index 0000000000..7758ccb38c
--- /dev/null
+++ b/spree/api/spec/integration/spree/api/v3/admin/prices_spec.rb
@@ -0,0 +1,331 @@
+# frozen_string_literal: true
+
+require 'swagger_helper'
+
+RSpec.describe 'Admin Prices API', type: :request, swagger_doc: 'api-reference/admin.yaml' do
+ include_context 'API v3 Admin'
+
+ let(:Authorization) { "Bearer #{admin_jwt_token}" }
+ let(:price_list) { create(:price_list, store: store) }
+ let(:product) { create(:product, stores: [store]) }
+ # Use a non-master variant from the start. Touching the master while
+ # also creating sibling variants later in the example triggers the
+ # `remove_prices_from_master_variant` callback (variant.rb), which
+ # `delete_all`s the master's prices and would silently wipe our seed.
+ let!(:variant) { create(:variant, product: product) }
+ let!(:list_price) do
+ create(:price, variant: variant, price_list: price_list, currency: 'USD', amount: 5.0)
+ end
+ let(:base_price) { variant.prices.find_by!(currency: 'USD', price_list_id: nil) }
+
+ path '/api/v3/admin/prices' do
+ get 'List prices' do
+ tags 'Pricing'
+ produces 'application/json'
+ security [api_key: [], bearer_auth: []]
+ description <<~DESC
+ Generic prices endpoint covering both base prices and price-list
+ overrides. Filter with Ransack: `q[price_list_id_eq]=…`,
+ `q[currency_eq]=USD`, `q[price_list_id_null]=true` (base prices only).
+
+ The admin spreadsheet uses this with server-side pagination so it
+ scales past the metadata-PATCH path on `/price_lists/:id`.
+ DESC
+ admin_scope :read, :products
+
+ admin_sdk_example 'prices/list'
+
+ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true
+ parameter name: :Authorization, in: :header, type: :string, required: true
+ parameter name: :page, in: :query, type: :integer, required: false
+ parameter name: :limit, in: :query, type: :integer, required: false
+ parameter name: :'q[price_list_id_eq]', in: :query, type: :string, required: false
+ parameter name: :'q[price_list_id_null]', in: :query, type: :boolean, required: false
+ parameter name: :'q[currency_eq]', in: :query, type: :string, required: false
+ parameter name: :'q[variant_id_eq]', in: :query, type: :string, required: false
+ parameter name: :sort, in: :query, type: :string, required: false,
+ description: 'Comma-separated sort keys. Supports e.g. `variant_product_name,variant_id`.'
+ parameter name: :expand, in: :query, type: :string, required: false,
+ description: 'Comma-separated associations to embed. Supported: `variant`.'
+
+ response '200', 'prices found' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+
+ schema SwaggerSchemaHelpers.paginated('Price')
+
+ run_test! do |response|
+ data = JSON.parse(response.body)
+ ids = data['data'].pluck('id')
+ expect(ids).to include(base_price.prefixed_id, list_price.prefixed_id)
+ end
+ end
+ end
+
+ post 'Create a price' do
+ tags 'Pricing'
+ consumes 'application/json'
+ produces 'application/json'
+ security [api_key: [], bearer_auth: []]
+ description <<~DESC
+ Creates a single price. Omit `price_list_id` to create a base price.
+ For more than a handful of rows, prefer `POST /admin/prices/bulk_upsert`.
+ DESC
+ admin_scope :write, :products
+
+ admin_sdk_example 'prices/create'
+
+ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true
+ parameter name: :Authorization, in: :header, type: :string, required: true
+ parameter name: :body, in: :body, schema: {
+ type: :object,
+ required: %w[variant_id currency],
+ properties: {
+ variant_id: { type: :string, example: 'variant_xY9' },
+ currency: { type: :string, example: 'USD' },
+ amount: { type: :string, nullable: true, example: '19.99' },
+ compare_at_amount: { type: :string, nullable: true, example: '24.99' },
+ price_list_id: { type: :string, nullable: true, example: 'pl_aBc123' }
+ }
+ }
+
+ response '201', 'price created' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:other_variant) { create(:variant, product: product) }
+ let(:body) do
+ {
+ variant_id: other_variant.prefixed_id,
+ currency: 'EUR',
+ amount: '9.99'
+ }
+ end
+
+ schema '$ref' => '#/components/schemas/Price'
+
+ run_test! do |response|
+ data = JSON.parse(response.body)
+ expect(data['currency']).to eq('EUR')
+ expect(data['amount']).to eq('9.99')
+ end
+ end
+ end
+ end
+
+ path '/api/v3/admin/prices/{id}' do
+ parameter name: :id, in: :path, type: :string, required: true
+
+ get 'Get a price' do
+ tags 'Pricing'
+ produces 'application/json'
+ security [api_key: [], bearer_auth: []]
+ admin_scope :read, :products
+
+ admin_sdk_example 'prices/get'
+
+ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true
+ parameter name: :Authorization, in: :header, type: :string, required: true
+
+ response '200', 'price found' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:id) { list_price.prefixed_id }
+
+ schema '$ref' => '#/components/schemas/Price'
+
+ run_test! do |response|
+ data = JSON.parse(response.body)
+ expect(data['id']).to eq(list_price.prefixed_id)
+ end
+ end
+
+ response '404', 'price not found' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:id) { 'price_nonexistent' }
+
+ schema '$ref' => '#/components/schemas/ErrorResponse'
+
+ run_test!
+ end
+ end
+
+ patch 'Update a price' do
+ tags 'Pricing'
+ consumes 'application/json'
+ produces 'application/json'
+ security [api_key: [], bearer_auth: []]
+ admin_scope :write, :products
+
+ admin_sdk_example 'prices/update'
+
+ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true
+ parameter name: :Authorization, in: :header, type: :string, required: true
+ parameter name: :body, in: :body, schema: {
+ type: :object,
+ properties: {
+ amount: { type: :string, nullable: true },
+ compare_at_amount: { type: :string, nullable: true }
+ }
+ }
+
+ response '200', 'price updated' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:id) { list_price.prefixed_id }
+ let(:body) { { amount: '12.34' } }
+
+ schema '$ref' => '#/components/schemas/Price'
+
+ run_test! do
+ expect(list_price.reload.amount).to eq(BigDecimal('12.34'))
+ end
+ end
+ end
+
+ delete 'Delete a price' do
+ tags 'Pricing'
+ security [api_key: [], bearer_auth: []]
+ description 'Soft-deletes the price (acts_as_paranoid).'
+ admin_scope :write, :products
+
+ admin_sdk_example 'prices/delete'
+
+ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true
+ parameter name: :Authorization, in: :header, type: :string, required: true
+
+ response '204', 'price deleted' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:id) { list_price.prefixed_id }
+
+ run_test! do
+ expect(list_price.reload.deleted_at).not_to be_nil
+ end
+ end
+ end
+ end
+
+ path '/api/v3/admin/prices/bulk_upsert' do
+ post 'Bulk-upsert prices' do
+ tags 'Pricing'
+ consumes 'application/json'
+ produces 'application/json'
+ security [api_key: [], bearer_auth: []]
+ description <<~DESC
+ Upserts a batch of prices in a single SQL round trip.
+
+ Each row either:
+ * targets an existing price by `id`, OR
+ * matches on the unique key `(variant_id, currency, price_list_id)` —
+ updating the existing row if one exists, creating one otherwise.
+
+ Model callbacks (e.g. PriceHistory) are bypassed; this is a
+ bulk-write fast path for the admin spreadsheet. The response
+ carries `price_count` — the number of rows touched.
+ DESC
+ admin_scope :write, :products
+
+ admin_sdk_example 'prices/bulk-upsert'
+
+ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true
+ parameter name: :Authorization, in: :header, type: :string, required: true
+ parameter name: :body, in: :body, schema: {
+ type: :object,
+ required: %w[prices],
+ properties: {
+ prices: {
+ type: :array,
+ items: {
+ type: :object,
+ required: %w[variant_id currency],
+ properties: {
+ id: { type: :string, nullable: true, example: 'price_aBc123' },
+ variant_id: { type: :string, example: 'variant_xY9' },
+ currency: { type: :string, example: 'USD' },
+ price_list_id: { type: :string, nullable: true, example: 'pl_aBc123' },
+ amount: { type: :string, nullable: true, example: '19.99' },
+ compare_at_amount: { type: :string, nullable: true, example: '24.99' }
+ }
+ }
+ }
+ }
+ }
+
+ response '200', 'prices upserted' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:other_variant) { create(:variant, product: product) }
+ let(:body) do
+ {
+ prices: [
+ # Update existing row via unique key
+ {
+ variant_id: variant.prefixed_id,
+ currency: 'USD',
+ price_list_id: price_list.prefixed_id,
+ amount: '11.11'
+ },
+ # Insert new row via unique key
+ {
+ variant_id: other_variant.prefixed_id,
+ currency: 'USD',
+ price_list_id: price_list.prefixed_id,
+ amount: '22.22'
+ }
+ ]
+ }
+ end
+
+ schema type: :object, properties: {
+ price_count: { type: :integer }
+ }
+
+ run_test! do |response|
+ data = JSON.parse(response.body)
+ expect(data).to eq('price_count' => 2)
+ end
+ end
+
+ response '422', 'missing prices key' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:body) { {} }
+
+ schema '$ref' => '#/components/schemas/ErrorResponse'
+
+ run_test!
+ end
+ end
+ end
+
+ path '/api/v3/admin/prices/bulk_destroy' do
+ delete 'Bulk-delete prices' do
+ tags 'Pricing'
+ consumes 'application/json'
+ produces 'application/json'
+ security [api_key: [], bearer_auth: []]
+ description 'Soft-deletes each price in `ids`. Returns the count actually destroyed.'
+ admin_scope :write, :products
+
+ admin_sdk_example 'prices/bulk-destroy'
+
+ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true
+ parameter name: :Authorization, in: :header, type: :string, required: true
+ parameter name: :body, in: :body, schema: {
+ type: :object,
+ required: %w[ids],
+ properties: {
+ ids: { type: :array, items: { type: :string } }
+ }
+ }
+
+ response '200', 'prices deleted' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:body) { { ids: [list_price.prefixed_id] } }
+
+ schema type: :object, properties: {
+ price_count: { type: :integer }
+ }
+
+ run_test! do |response|
+ data = JSON.parse(response.body)
+ expect(data).to eq('price_count' => 1)
+ expect(list_price.reload.deleted_at).not_to be_nil
+ end
+ end
+ end
+ end
+end
diff --git a/spree/core/app/models/spree/permission_sets/product_display.rb b/spree/core/app/models/spree/permission_sets/product_display.rb
index 0ef8851c97..43e4805f56 100644
--- a/spree/core/app/models/spree/permission_sets/product_display.rb
+++ b/spree/core/app/models/spree/permission_sets/product_display.rb
@@ -19,6 +19,8 @@ module Spree
can [:read, :admin], Spree::Taxonomy
can [:read, :admin], Spree::Classification
can [:read, :admin], Spree::Price
+ can [:read, :admin], Spree::PriceList
+ can [:read, :admin], Spree::PriceRule
end
end
end
diff --git a/spree/core/app/models/spree/permission_sets/product_management.rb b/spree/core/app/models/spree/permission_sets/product_management.rb
index f811820dac..5081d6ccf4 100644
--- a/spree/core/app/models/spree/permission_sets/product_management.rb
+++ b/spree/core/app/models/spree/permission_sets/product_management.rb
@@ -18,6 +18,8 @@ module Spree
can :manage, Spree::Taxonomy
can :manage, Spree::Classification
can :manage, Spree::Price
+ can :manage, Spree::PriceList
+ can :manage, Spree::PriceRule
can :manage, Spree::Asset
end
end
diff --git a/spree/core/app/models/spree/price.rb b/spree/core/app/models/spree/price.rb
index 192d7334c6..be28be472c 100644
--- a/spree/core/app/models/spree/price.rb
+++ b/spree/core/app/models/spree/price.rb
@@ -55,7 +55,8 @@ module Spree
money_methods :amount, :price, :compare_at_amount
alias display_compare_at_price display_compare_at_amount
- self.whitelisted_ransackable_attributes = ['amount', 'compare_at_amount']
+ self.whitelisted_ransackable_attributes = %w[amount compare_at_amount currency price_list_id variant_id]
+ self.whitelisted_ransackable_associations = %w[variant price_list]
attribute :eligible_for_taxon_matching, :boolean, default: false
before_validation -> { self.eligible_for_taxon_matching = new_record? ? discounted? : discounted? != was_discounted? }
diff --git a/spree/core/app/models/spree/price_list.rb b/spree/core/app/models/spree/price_list.rb
index 55f665cb9d..4b37c3ab11 100644
--- a/spree/core/app/models/spree/price_list.rb
+++ b/spree/core/app/models/spree/price_list.rb
@@ -11,10 +11,11 @@ module Spree
belongs_to :store, class_name: 'Spree::Store'
- has_many :price_rules, class_name: 'Spree::PriceRule', dependent: :destroy
+ has_many :price_rules, class_name: 'Spree::PriceRule', autosave: true, dependent: :destroy
+ alias rules price_rules
has_many :prices, class_name: 'Spree::Price', dependent: :destroy_async
- has_many :variants, -> { where(spree_prices: { deleted_at: nil }).distinct }, through: :prices, source: :variant
- has_many :products, -> { where(spree_prices: { deleted_at: nil }).distinct }, through: :variants, source: :product
+ has_many :variants, -> { distinct }, through: :prices, source: :variant
+ has_many :products, -> { distinct }, through: :variants, source: :product
alias price_list_products products
# Override default nested attributes to use bulk_update_prices for performance
@@ -28,20 +29,59 @@ module Spree
end
after_update :process_bulk_prices_update
+ after_save :apply_pending_rules
+ after_save :apply_pending_product_ids
+ after_save :apply_pending_prices
+
+ # @return [Array<String>] prefixed product ids in this list,
+ # encoded inline to avoid hydrating N Product records.
+ def product_prefixed_ids
+ prefix = Spree::Product._prefix_id_prefix
+ product_ids.sort.map { |pk| "#{prefix}_#{Spree::PrefixedId::SQIDS.encode([pk])}" }
+ end
- # Processes the bulk prices update
+ # Reconciles list membership. Removes prices for products no longer
+ # in `ids` and adds placeholder prices for the new ones.
+ #
+ # @param ids [Array<String>] raw product PKs (prefixed strings are
+ # resolved upstream by `Spree::Base#assign_attributes`).
# @return [void]
- def process_bulk_prices_update
- return if @prices_attributes.blank?
+ def product_ids=(ids)
+ @pending_product_ids = Array(ids).compact.uniq
+ end
- bulk_update_prices(@prices_attributes)
- @prices_attributes = nil
+ # Flat-payload writer for `prices`. Bulk-upserts the listed rows in
+ # `after_save` so newly-added products have their placeholder rows
+ # materialized first. Nullability contract:
+ # - `nil` → no-op
+ # - `[]` → clear every override on this list
+ # - `[…]` → upsert listed rows, leave the rest alone
+ #
+ # @param rows [Array<Hash>, Array<Spree::Price>, nil]
+ # @return [void]
+ def prices=(rows)
+ first = Array(rows).first
+ return super(rows) if first.is_a?(Spree::Price)
+ return if rows.nil?
+
+ @pending_prices = Array(rows).map do |row|
+ row.respond_to?(:to_unsafe_h) ? row.to_unsafe_h.with_indifferent_access : row.with_indifferent_access
+ end
+ @pending_prices_clear = rows.empty?
+ end
+
+ # Flat-payload writer for `rules`. See
+ # {Spree::TypedAssociations#assign_typed_association}.
+ def rules=(rows)
+ assign_typed_association(:price_rules, rows)
end
validates :name, :store, presence: true
validates :match_policy, presence: true, inclusion: { in: MATCH_POLICIES }
validate :starts_at_before_ends_at
+ self.whitelisted_ransackable_attributes = %w[status match_policy starts_at ends_at]
+
scope :by_position, -> { order(position: :asc) }
scope :for_store, ->(store) { where(store: store) }
scope :current, lambda { |timezone = nil|
@@ -119,9 +159,10 @@ module Spree
active_or_scheduled? && within_date_range?(Time.current)
end
- # Adds products to the price list
- # Creates placeholder prices (with nil amount) for all variants and currencies
- # @param product_ids [Array<String>] of product ids
+ # Adds products to the list, materializing a placeholder price
+ # (amount nil) for every variant × store currency.
+ #
+ # @param product_ids [Array<String>] raw product PKs
# @return [void]
def add_products(product_ids)
return if product_ids.blank?
@@ -130,7 +171,6 @@ module Spree
variant_ids = Spree::Variant.eligible.where(product_id: product_ids).distinct.pluck(:id)
return if variant_ids.empty?
- # Get existing variant_id/currency combinations to avoid duplicates
existing = prices.where(variant_id: variant_ids)
.pluck(:variant_id, :currency)
.to_set
@@ -160,9 +200,12 @@ module Spree
touch
end
- # Removes products from the price list
- # Hard deletes prices (not soft delete) to allow re-adding products later
- # @param product_ids [Array<String>] of product ids
+ # Removes products from the list. Hard-deletes their prices so the
+ # unique index doesn't block re-adding the same products later
+ # (acts_as_paranoid would leave soft-deleted rows blocking the
+ # `(variant_id, currency, price_list_id)` slot).
+ #
+ # @param product_ids [Array<String>] raw product PKs
# @return [void]
def remove_products(product_ids)
return if product_ids.blank?
@@ -195,7 +238,12 @@ module Spree
next if attrs[:id].blank?
price_id = attrs[:id].to_i
- current = current_values[price_id] || {}
+ # Reject rows that aren't in *this* list's prices — `upsert_all`
+ # otherwise keys solely by primary id and would silently cross
+ # list boundaries.
+ next unless current_values.key?(price_id)
+
+ current = current_values[price_id]
# Parse amounts using LocalizedNumber for proper decimal handling
amount = attrs[:amount].present? ? Spree::LocalizedNumber.parse(attrs[:amount]) : nil
@@ -232,6 +280,70 @@ module Spree
private
+ # Processes the bulk prices update
+ # @return [void]
+ def process_bulk_prices_update
+ return if @prices_attributes.blank?
+
+ bulk_update_prices(@prices_attributes)
+ @prices_attributes = nil
+ end
+
+ def apply_pending_rules
+ flush_pending_typed_association(:price_rules)
+ end
+
+ def apply_pending_product_ids
+ return unless @pending_product_ids
+
+ desired = @pending_product_ids
+ @pending_product_ids = nil
+
+ current = product_ids
+ to_remove = current - desired
+ to_add = desired - current
+
+ remove_products(to_remove) if to_remove.any?
+ add_products(to_add) if to_add.any?
+ end
+
+ def apply_pending_prices
+ pending = @pending_prices
+ cleared = @pending_prices_clear
+ return if pending.nil?
+
+ @pending_prices = nil
+ @pending_prices_clear = nil
+
+ if cleared
+ variant_ids = prices.distinct.pluck(:variant_id)
+ prices.update_all(amount: nil, compare_at_amount: nil, updated_at: Time.current)
+ touch_variants(variant_ids)
+ return
+ end
+
+ rows = pending.filter_map do |row|
+ # `variant_id` may arrive as a prefixed string (legacy callers,
+ # console) or already decoded (the controller's `permitted_params`
+ # runs through `normalize_params`). Handle both.
+ raw = row[:variant_id]
+ variant_id = Spree::PrefixedId.prefixed_id?(raw) ? Spree::PrefixedId.decode_prefixed_id(raw) : raw
+ next if variant_id.blank? || row[:currency].blank?
+
+ {
+ variant_id: variant_id,
+ currency: row[:currency],
+ price_list_id: id,
+ amount: row[:amount],
+ compare_at_amount: row[:compare_at_amount]
+ }
+ end
+ return if rows.empty?
+
+ Spree::Prices::BulkUpsert.call(rows: rows)
+ touch_variants(rows.map { |r| r[:variant_id] }.uniq)
+ end
+
# Touches the variants in a background job
# @param variant_ids [Array<String>] array of variant ids
# @return [void]
diff --git a/spree/core/app/models/spree/price_rule.rb b/spree/core/app/models/spree/price_rule.rb
index f3cab5a544..e528774c68 100644
--- a/spree/core/app/models/spree/price_rule.rb
+++ b/spree/core/app/models/spree/price_rule.rb
@@ -4,7 +4,7 @@ module Spree
belongs_to :price_list, class_name: 'Spree::PriceList', touch: true
- validates :type, :price_list,presence: true
+ validates :type, :price_list, presence: true
# Returns true if the price rule is applicable to the context
# @param context [Spree::Pricing::Context]
@@ -24,5 +24,12 @@ module Spree
def self.description
''
end
+
+ # Pull the rule registry off the global pricing config so
+ # PreferenceSchema's `.subclasses_with_preference_schema` can power
+ # the admin's "Add rule" picker.
+ def self.registered_subclasses
+ Array(Spree.pricing&.rules)
+ end
end
end
diff --git a/spree/core/app/models/spree/price_rules/user_rule.rb b/spree/core/app/models/spree/price_rules/user_rule.rb
index 5b8350cfdd..00f5f15b7a 100644
--- a/spree/core/app/models/spree/price_rules/user_rule.rb
+++ b/spree/core/app/models/spree/price_rules/user_rule.rb
@@ -12,7 +12,14 @@ module Spree
end
def self.description
- 'Apply pricing to specific users'
+ 'Apply pricing to specific customers'
+ end
+
+ # Public-facing label — keeps the wire `api_type` as `user_rule`
+ # (preference column is `user_ids`) so existing data stays valid,
+ # but every UI surface reads "Customer rule".
+ def self.human_name
+ 'Customer rule'
end
end
end
diff --git a/spree/core/app/models/spree/store.rb b/spree/core/app/models/spree/store.rb
index 2552685173..cbf3f60ea5 100644
--- a/spree/core/app/models/spree/store.rb
+++ b/spree/core/app/models/spree/store.rb
@@ -79,6 +79,7 @@ module Spree
has_many :products, through: :store_products, class_name: 'Spree::Product'
has_many :variants, through: :products, class_name: 'Spree::Variant', source: :variants_including_master
has_many :stock_items, through: :variants, class_name: 'Spree::StockItem'
+ has_many :prices, through: :variants, class_name: 'Spree::Price'
has_many :inventory_units, through: :variants, class_name: 'Spree::InventoryUnit'
has_many :option_value_variants, through: :variants, class_name: 'Spree::OptionValueVariant'
has_many :customer_returns, class_name: 'Spree::CustomerReturn', inverse_of: :store
diff --git a/spree/core/app/services/spree/prices/bulk_upsert.rb b/spree/core/app/services/spree/prices/bulk_upsert.rb
new file mode 100644
index 0000000000..48501065f1
--- /dev/null
+++ b/spree/core/app/services/spree/prices/bulk_upsert.rb
@@ -0,0 +1,117 @@
+module Spree
+ module Prices
+ # Bulk-writes Spree::Price rows on the unique key
+ # `(variant_id, currency, price_list_id)` and sweeps stale
+ # placeholder rows in one transaction.
+ #
+ # The unique index on `spree_prices` is partial
+ # (`WHERE amount IS NOT NULL`), so `upsert_all` can't see
+ # placeholder rows (amount IS NULL) as conflict targets — filling
+ # in a placeholder via upsert inserts a sibling row instead of
+ # updating. The post-write sweep removes those.
+ class BulkUpsert
+ prepend Spree::ServiceModule::Base
+
+ UNIQUE_BY = %i[variant_id currency price_list_id].freeze
+
+ # @param rows [Array<Hash>] each row must carry
+ # `variant_id`, `currency`, and `amount`; `price_list_id` and
+ # `compare_at_amount` are optional. A blank `amount` is treated
+ # as "clear this price."
+ # @return [Spree::ServiceModule::Result] success carries
+ # `{ price_count: N }` — the number of rows passed to
+ # `upsert_all`.
+ def call(rows:)
+ rows = Array(rows).map { |r| r.with_indifferent_access }
+ keyed = rows.select { |r| r[:variant_id].present? && r[:currency].present? }
+ # PG rejects an upsert with two rows hitting the same unique-key
+ # triple in one statement ("ON CONFLICT DO UPDATE command cannot
+ # affect row a second time"). Last-write-wins: keep the last
+ # occurrence of each triple.
+ deduped = keyed.reverse.uniq { |r| [r[:variant_id], r[:currency], r[:price_list_id]] }.reverse
+ upsert_rows, clear_rows = deduped.partition { |r| r[:amount].present? }
+
+ payload = build_payload(upsert_rows)
+ affected_keys = deduped.map { |r| [r[:variant_id], r[:currency], r[:price_list_id]] }
+
+ return success(price_count: 0) if affected_keys.empty?
+
+ Spree::Price.transaction do
+ # `update_only` lists only domain columns. Rails adds
+ # `updated_at` automatically (when `record_timestamps` is on,
+ # which it is for `Spree::Price`); listing it explicitly here
+ # produces `SET updated_at = …, updated_at = …` on PG and the
+ # statement fails with "multiple assignments to same column".
+ if payload.any?
+ Spree::Price.upsert_all(
+ payload,
+ update_only: %i[amount compare_at_amount],
+ **upsert_opts(UNIQUE_BY)
+ )
+ end
+ sweep(affected_keys, clear_rows)
+ end
+
+ success(price_count: payload.length)
+ end
+
+ private
+
+ def build_payload(rows)
+ now = Time.current
+ rows.map do |row|
+ {
+ variant_id: row[:variant_id],
+ currency: row[:currency],
+ price_list_id: row[:price_list_id],
+ amount: parse_amount(row[:amount]),
+ compare_at_amount: parse_amount(row[:compare_at_amount]),
+ created_at: now,
+ updated_at: now
+ }
+ end
+ end
+
+ # Parses locale-aware decimal input ("1.234,56" in DE, "1,234.56"
+ # in en-US). Numeric values pass through; blank values become nil.
+ def parse_amount(value)
+ return nil if value.blank?
+ return value if value.is_a?(Numeric)
+
+ Spree::LocalizedNumber.parse(value)
+ end
+
+ def sweep(affected_keys, clear_rows)
+ cleared_keys = clear_rows.map { |r| [r[:variant_id], r[:currency], r[:price_list_id]] }.to_set
+ affected_set = affected_keys.to_set
+
+ candidates = Spree::Price
+ .where(
+ variant_id: affected_keys.map(&:first).uniq,
+ currency: affected_keys.map { |k| k[1] }.uniq,
+ price_list_id: affected_keys.map(&:last).uniq
+ )
+ .pluck(:id, :variant_id, :currency, :price_list_id, :amount)
+
+ doomed_ids = candidates.filter_map do |id, variant_id, currency, price_list_id, amount|
+ key = [variant_id, currency, price_list_id]
+ next unless affected_set.include?(key)
+ next id if amount.nil?
+ next id if cleared_keys.include?(key)
+
+ nil
+ end
+
+ Spree::Price.where(id: doomed_ids).delete_all if doomed_ids.any?
+ end
+
+ # MySQL infers conflict targets from its own unique indexes and
+ # rejects an explicit `unique_by`.
+ def upsert_opts(unique_by)
+ return {} if ActiveRecord::Base.connection.adapter_name == 'Mysql2'
+
+ { unique_by: unique_by }
+ end
+ end
+ end
+end
diff --git a/spree/core/lib/spree/core/engine.rb b/spree/core/lib/spree/core/engine.rb
index f8a68d97f4..c4adfce923 100644
--- a/spree/core/lib/spree/core/engine.rb
+++ b/spree/core/lib/spree/core/engine.rb
@@ -162,12 +162,18 @@ module Spree
Spree::Promotion::Rules::OptionValue,
]
+ # Default registry. MarketRule is included so existing installs
+ # don't lose access to saved rule rows in the admin. ZoneRule is
+ # intentionally excluded — Zones are being removed in 6.0 (see
+ # docs/plans/6.0-tax-provider.md) and we don't want to invest
+ # in admin UI for a model on its way out. The class itself
+ # stays so legacy data continues to load; it just doesn't show
+ # up in the "Add rule" picker.
Rails.application.config.spree.pricing.rules.concat [
- Spree::PriceRules::ZoneRule,
- Spree::PriceRules::MarketRule,
Spree::PriceRules::UserRule,
Spree::PriceRules::CustomerGroupRule,
- Spree::PriceRules::VolumeRule
+ Spree::PriceRules::VolumeRule,
+ Spree::PriceRules::MarketRule
]
Rails.application.config.spree.promotions.actions = [
diff --git a/spree/core/spec/services/spree/prices/bulk_upsert_spec.rb b/spree/core/spec/services/spree/prices/bulk_upsert_spec.rb
new file mode 100644
index 0000000000..73bf1b2125
--- /dev/null
+++ b/spree/core/spec/services/spree/prices/bulk_upsert_spec.rb
@@ -0,0 +1,91 @@
+require 'spec_helper'
+
+RSpec.describe Spree::Prices::BulkUpsert do
+ let(:store) { @default_store }
+ let(:price_list) { create(:price_list, store: store) }
+ let(:product) { create(:product, stores: [store]) }
+ let!(:variant) { create(:variant, product: product) }
+ let!(:override) do
+ create(:price, variant: variant, price_list: price_list, currency: 'USD', amount: BigDecimal('5.00'))
+ end
+
+ describe '#call' do
+ it 'returns zero count on empty input without touching the DB' do
+ expect(Spree::Price).not_to receive(:upsert_all)
+ result = described_class.call(rows: [])
+
+ expect(result).to be_success
+ expect(result.value).to eq(price_count: 0)
+ end
+
+ it 'updates a price-list override in a single upsert_all call' do
+ expect(Spree::Price).to receive(:upsert_all).once.and_call_original
+
+ result = described_class.call(
+ rows: [{
+ variant_id: variant.id,
+ currency: 'USD',
+ price_list_id: price_list.id,
+ amount: '19.99',
+ compare_at_amount: '24.99'
+ }]
+ )
+
+ expect(result).to be_success
+ expect(result.value).to eq(price_count: 1)
+ expect(override.reload).to have_attributes(
+ amount: BigDecimal('19.99'),
+ compare_at_amount: BigDecimal('24.99')
+ )
+ end
+
+ it 'creates a new row when no match exists' do
+ other_variant = create(:variant, product: product)
+
+ result = described_class.call(
+ rows: [{
+ variant_id: other_variant.id,
+ currency: 'EUR',
+ price_list_id: price_list.id,
+ amount: '4.20'
+ }]
+ )
+
+ expect(result).to be_success
+ expect(result.value).to eq(price_count: 1)
+ row = Spree::Price.find_by(
+ variant_id: other_variant.id, currency: 'EUR', price_list_id: price_list.id
+ )
+ expect(row).not_to be_nil
+ expect(row.amount).to eq(BigDecimal('4.20'))
+ end
+
+ it 'drops rows missing variant_id or currency' do
+ result = described_class.call(rows: [{ amount: '9.99' }])
+
+ expect(result).to be_success
+ expect(result.value).to eq(price_count: 0)
+ end
+
+ it 'leaves exactly one real-amount row when filling in a placeholder' do
+ placeholder_variant = create(:variant, product: product)
+ create(:price, variant: placeholder_variant, price_list: price_list, currency: 'USD', amount: nil)
+
+ result = described_class.call(
+ rows: [{
+ variant_id: placeholder_variant.id,
+ currency: 'USD',
+ price_list_id: price_list.id,
+ amount: '12.34'
+ }]
+ )
+
+ expect(result).to be_success
+ surviving = Spree::Price.where(
+ variant_id: placeholder_variant.id, currency: 'USD', price_list_id: price_list.id
+ )
+ expect(surviving.count).to eq(1)
+ expect(surviving.first.amount).to eq(BigDecimal('12.34'))
+ end
+ end
+end