@spree/docs 0.1.177 → 0.1.178

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/dist/developer/cli/quickstart.md +1 -1
  2. package/dist/developer/contributing/creating-an-extension.md +2 -2
  3. package/dist/developer/core-concepts/addresses.md +3 -3
  4. package/dist/developer/core-concepts/architecture.md +4 -4
  5. package/dist/developer/core-concepts/calculators.md +2 -2
  6. package/dist/developer/core-concepts/carts.md +207 -0
  7. package/dist/developer/core-concepts/channels.md +3 -3
  8. package/dist/developer/core-concepts/customers.md +1 -1
  9. package/dist/developer/core-concepts/events.md +1 -1
  10. package/dist/developer/core-concepts/fulfillments.md +278 -0
  11. package/dist/developer/core-concepts/imports-exports.md +6 -18
  12. package/dist/developer/core-concepts/inventory.md +3 -3
  13. package/dist/developer/core-concepts/media.md +1 -1
  14. package/dist/developer/core-concepts/metafields.md +1 -1
  15. package/dist/developer/core-concepts/orders.md +92 -339
  16. package/dist/developer/core-concepts/payments.md +1 -1
  17. package/dist/developer/core-concepts/promotions.md +68 -195
  18. package/dist/developer/core-concepts/returns-exchanges-claims.md +173 -0
  19. package/dist/developer/core-concepts/store-credits-gift-cards.md +16 -18
  20. package/dist/developer/core-concepts/stores.md +1 -1
  21. package/dist/developer/core-concepts/taxes-discounts-fees.md +199 -0
  22. package/dist/developer/core-concepts/taxes.md +3 -3
  23. package/dist/developer/create-spree-app/quickstart.md +1 -1
  24. package/dist/developer/customization/api.md +36 -11
  25. package/dist/developer/customization/configuration.md +207 -37
  26. package/dist/developer/customization/decorators.md +8 -8
  27. package/dist/developer/customization/permissions.md +34 -229
  28. package/dist/developer/customization/quickstart.md +159 -108
  29. package/dist/developer/customization/validations.md +1 -1
  30. package/dist/developer/dashboard/overview.md +1 -1
  31. package/dist/developer/how-to/build-a-b2b-store.md +21 -0
  32. package/dist/developer/how-to/build-a-marketplace.md +25 -0
  33. package/dist/developer/how-to/custom-api-authentication.md +1 -1
  34. package/dist/developer/how-to/custom-delivery-rate-provider.md +242 -0
  35. package/dist/developer/how-to/custom-document-numbers.md +154 -0
  36. package/dist/developer/how-to/custom-order-routing.md +1 -1
  37. package/dist/developer/how-to/custom-payment-method.md +1 -1
  38. package/dist/developer/how-to/custom-promotion.md +76 -115
  39. package/dist/developer/how-to/custom-report.md +2 -2
  40. package/dist/developer/how-to/custom-stock-splitter.md +5 -5
  41. package/dist/developer/how-to/sell-digital-products.md +20 -0
  42. package/dist/developer/multi-tenant/quickstart.md +1 -1
  43. package/dist/developer/providers/dam.md +14 -0
  44. package/dist/developer/providers/erp.md +31 -0
  45. package/dist/developer/providers/fulfillment.md +25 -0
  46. package/dist/developer/{deployment/telemetry.md → providers/observability.md} +1 -1
  47. package/dist/developer/providers/overview.md +44 -0
  48. package/dist/developer/providers/pim.md +25 -0
  49. package/dist/developer/providers/sso.md +20 -0
  50. package/dist/developer/sdk/admin/extending.md +1 -1
  51. package/dist/developer/sdk/admin/quickstart.md +1 -1
  52. package/dist/developer/sdk/admin/resources.md +1 -1
  53. package/dist/developer/sdk/extending.md +1 -1
  54. package/dist/developer/tutorial/admin-api.md +13 -0
  55. package/dist/developer/tutorial/dashboard-plugin.md +14 -0
  56. package/dist/developer/tutorial/events.md +7 -161
  57. package/dist/developer/tutorial/introduction.md +15 -35
  58. package/dist/developer/tutorial/model.md +7 -98
  59. package/dist/developer/tutorial/store-api.md +13 -0
  60. package/dist/developer/tutorial/storefront.md +12 -0
  61. package/dist/developer/tutorial/testing.md +7 -711
  62. package/dist/developer/upgrades/5.6-to-6.0.md +2 -2
  63. package/package.json +1 -1
  64. package/dist/developer/admin/admin.md +0 -214
  65. package/dist/developer/admin/authentication.md +0 -59
  66. package/dist/developer/admin/components.md +0 -711
  67. package/dist/developer/admin/custom-css.md +0 -256
  68. package/dist/developer/admin/custom-javascript.md +0 -116
  69. package/dist/developer/admin/extending-ui.md +0 -1839
  70. package/dist/developer/admin/form-builder.md +0 -444
  71. package/dist/developer/admin/helper-methods.md +0 -531
  72. package/dist/developer/admin/navigation.md +0 -805
  73. package/dist/developer/admin/tables.md +0 -490
  74. package/dist/developer/advanced/adding_spree_to_rails_app.md +0 -92
  75. package/dist/developer/core-concepts/adjustments.md +0 -113
  76. package/dist/developer/core-concepts/reports.md +0 -208
  77. package/dist/developer/core-concepts/shipments.md +0 -307
  78. package/dist/developer/core-concepts/users.md +0 -303
  79. package/dist/developer/customization/authentication.md +0 -100
  80. package/dist/developer/customization/checkout.md +0 -202
  81. package/dist/developer/customization/emails.md +0 -18
  82. package/dist/developer/customization/routes.md +0 -24
  83. package/dist/developer/multi-vendor/installation.md +0 -61
  84. package/dist/developer/multi-vendor/quickstart.md +0 -17
  85. package/dist/developer/tutorial/admin.md +0 -206
  86. package/dist/developer/tutorial/api.md +0 -606
  87. package/dist/developer/tutorial/extending-models.md +0 -393
  88. package/dist/developer/tutorial/sdk.md +0 -170
  89. package/dist/developer/upgrades/2.0-to-2.1.md +0 -46
  90. package/dist/developer/upgrades/2.1-to-2.2.md +0 -59
  91. package/dist/developer/upgrades/2.2-to-2.3.md +0 -44
  92. package/dist/developer/upgrades/2.3-to-2.4.md +0 -42
  93. package/dist/developer/upgrades/3.0-to-3.1.md +0 -47
  94. package/dist/developer/upgrades/3.1-to-3.2.md +0 -34
  95. package/dist/developer/upgrades/3.2-to-3.3.md +0 -70
  96. package/dist/developer/upgrades/3.3-to-3.4.md +0 -36
  97. package/dist/developer/upgrades/3.4-to-3.5.md +0 -44
  98. package/dist/developer/upgrades/3.5-to-3.6.md +0 -40
  99. package/dist/developer/upgrades/3.6-to-3.7.md +0 -62
  100. package/dist/developer/upgrades/3.7-to-4.0.md +0 -152
  101. package/dist/developer/upgrades/4.0-to-4.1.md +0 -92
  102. package/dist/developer/upgrades/4.1-to-4.2.md +0 -109
  103. package/dist/developer/upgrades/4.10-to-5.0.md +0 -131
  104. package/dist/developer/upgrades/4.2-to-4.3.md +0 -100
  105. package/dist/developer/upgrades/4.3-to-4.4.md +0 -125
  106. package/dist/developer/upgrades/4.4-to-4.5.md +0 -94
  107. package/dist/developer/upgrades/4.5-to-4.6.md +0 -119
  108. package/dist/developer/upgrades/4.6-to-4.7.md +0 -39
  109. package/dist/developer/upgrades/4.8-to-4.9.md +0 -24
  110. package/dist/developer/upgrades/4.9-to-4.10.md +0 -24
  111. package/dist/developer/upgrades/4.x-to-4.8.md +0 -52
  112. package/dist/developer/upgrades/5.0-to-5.1.md +0 -28
  113. package/dist/developer/upgrades/5.1-to-5.2.md +0 -131
  114. package/dist/developer/upgrades/5.2-to-5.3.md +0 -338
  115. package/dist/developer/upgrades/5.3-to-5.4.md +0 -277
  116. package/dist/developer/upgrades/5.4-to-5.5.md +0 -301
  117. package/dist/developer/upgrades/5.5-to-5.6.md +0 -207
@@ -1,490 +0,0 @@
1
- ---
2
- title: Admin Tables
3
- sidebarTitle: Tables
4
- description: Use the Spree Admin Tables DSL to define columns, sorting, filtering, and bulk actions for resource listings, and extend existing admin tables.
5
- ---
6
-
7
- Spree Admin provides a flexible table system for displaying resource listings with customizable columns, sorting, filtering, and bulk actions. The Tables DSL allows you to define table configurations for your resources and extend existing ones.
8
-
9
- > **INFO:** The Tables system uses a declarative API accessible via `Spree.admin.tables`. This allows you to programmatically add, modify, and remove table columns and bulk actions directly in your initializers.
10
-
11
- ## Basic Usage
12
-
13
- ### Creating a New Table
14
-
15
- Register a new table for your resource in `config/initializers/spree.rb`:
16
-
17
- ```ruby config/initializers/spree.rb
18
- Rails.application.config.after_initialize do
19
- # Register a new table
20
- Spree.admin.tables.register(:brands, model_class: Spree::Brand, search_param: :name_cont)
21
-
22
- # Add columns
23
- Spree.admin.tables.brands.add :name,
24
- label: :name,
25
- type: :link,
26
- sortable: true,
27
- default: true,
28
- position: 10
29
-
30
- Spree.admin.tables.brands.add :products_count,
31
- label: :products,
32
- type: :number,
33
- sortable: false,
34
- default: true,
35
- position: 20,
36
- method: ->(brand) { brand.products.count }
37
-
38
- Spree.admin.tables.brands.add :created_at,
39
- label: :created_at,
40
- type: :datetime,
41
- sortable: true,
42
- default: false,
43
- position: 30
44
- end
45
- ```
46
-
47
- ### Using the Table in Views
48
-
49
- Render the table in your index view using the `render_table` helper:
50
-
51
- ```erb app/views/spree/admin/brands/index.html.erb
52
- <%= render_table @collection, :brands %>
53
- ```
54
-
55
- With additional options:
56
-
57
- ```erb
58
- <%= render_table @collection, :brands,
59
- bulk_operations: true,
60
- export_type: Spree::Exports::Brands %>
61
- ```
62
-
63
- ## Table Registration Options
64
-
65
- When registering a table, you can specify these options:
66
-
67
- - **`model_class`** (`Class`) — The model class for the table (e.g., `Spree::Brand`).
68
-
69
- - **`search_param`** (`Symbol`) — The Ransack search parameter for the search box.
70
-
71
- - **`search_placeholder`** (`String`) — Custom placeholder text for the search box.
72
-
73
- - **`row_actions`** (`Boolean`) — Enable row action buttons (edit/delete dropdown).
74
-
75
- - **`row_actions_edit`** (`Boolean`) — Show edit action in row actions dropdown.
76
-
77
- - **`row_actions_delete`** (`Boolean`) — Show delete action in row actions dropdown.
78
-
79
- - **`new_resource`** (`Boolean`) — Show "New Resource" button when collection is empty.
80
-
81
- - **`date_range_param`** (`Symbol`) — Enable date range filter for the specified column (e.g., `:created_at`).
82
-
83
- - **`link_to_action`** (`Symbol`) — Action for link columns (`:edit` or `:show`).
84
-
85
- ## Column Options
86
-
87
- All columns support the following options:
88
-
89
- - **`label`** (`Symbol or String`) — The column header label. Can be a symbol (translation key using `Spree.t`) or a string.
90
-
91
- - **`type`** (`String`) — The column type. Determines how the value is rendered.
92
-
93
- Available types:
94
- - `string` - Plain text
95
- - `number` - Numeric value
96
- - `date` - Date formatted with `spree_date` helper
97
- - `datetime` - Relative time with `spree_time_ago` helper
98
- - `money` - Currency formatted with `Spree::Money`
99
- - `status` - Badge with status-based styling
100
- - `link` - Clickable link to resource
101
- - `boolean` - Active/inactive badge
102
- - `image` - Thumbnail image
103
- - `association` - Associated record name(s)
104
- - `custom` - Custom partial rendering
105
-
106
- - **`sortable`** (`Boolean`) — Whether the column can be sorted.
107
-
108
- - **`filterable`** (`Boolean`) — Whether the column appears in the query builder filter options.
109
-
110
- - **`displayable`** (`Boolean`) — Whether the column can be shown/hidden by users. Set to `false` for filter-only columns.
111
-
112
- - **`default`** (`Boolean`) — Whether the column is visible by default.
113
-
114
- - **`position`** (`Integer`) — Column order. Lower numbers appear first.
115
-
116
- - **`method`** (`Symbol or Lambda`) — Custom method to extract the column value. Can be a method name or lambda.
117
-
118
- - **`align`** (`String`) — Text alignment: `left`, `center`, or `right`.
119
-
120
- - **`width`** (`String`) — Column width class (e.g., `"20"` for `w-20`).
121
-
122
- - **`if`** (`Lambda`) — Conditional visibility. Column only appears if lambda returns true.
123
-
124
- ### Filter-specific Options
125
-
126
- - **`filter_type`** (`String`) — Override the filter input type. Available: `string`, `number`, `date`, `datetime`, `money`, `status`, `boolean`, `autocomplete`, `select`.
127
-
128
- - **`ransack_attribute`** (`String`) — Custom Ransack attribute name for filtering/sorting (defaults to column key).
129
-
130
- - **`operators`** (`Array`) — Available filter operators. Defaults based on column type.
131
-
132
- - **`value_options`** (`Array or Lambda`) — Options for select/status filters. Array of hashes with `value` and `label` keys.
133
-
134
- - **`search_url`** (`String | Lambda`) — URL for autocomplete filter type. Use a Lambda for dynamic paths: `search_url: ->(view_context) { view_context.spree.admin_taxons_select_options_path(format: :json) }`.
135
-
136
- ### Custom Sort Options
137
-
138
- - **`sort_scope_asc`** (`Symbol`) — Custom scope name for ascending sort (bypasses Ransack).
139
-
140
- - **`sort_scope_desc`** (`Symbol`) — Custom scope name for descending sort (bypasses Ransack).
141
-
142
- ### Custom Partial Options
143
-
144
- - **`partial`** (`String`) — Partial path for `custom` type columns.
145
-
146
- - **`partial_locals`** (`Hash or Lambda`) — Additional locals to pass to the partial. Lambda receives the record.
147
-
148
- ## Column Types Examples
149
-
150
- ### String Column
151
-
152
- ```ruby
153
- Spree.admin.tables.brands.add :name,
154
- label: :name,
155
- type: :string,
156
- sortable: true,
157
- default: true
158
- ```
159
-
160
- ### Link Column
161
-
162
- Links to the resource edit or show page:
163
-
164
- ```ruby
165
- Spree.admin.tables.brands.add :name,
166
- label: :name,
167
- type: :link,
168
- sortable: true,
169
- default: true
170
- ```
171
-
172
- ### Money Column
173
-
174
- Displays formatted currency:
175
-
176
- ```ruby
177
- Spree.admin.tables.products.add :price,
178
- label: :price,
179
- type: :money,
180
- sortable: true,
181
- default: true,
182
- align: :right,
183
- method: ->(product) { product.display_price }
184
- ```
185
-
186
- ### Status Column
187
-
188
- Displays a colored badge based on the status value:
189
-
190
- ```ruby
191
- Spree.admin.tables.orders.add :state,
192
- label: :state,
193
- type: :status,
194
- filter_type: :select,
195
- sortable: true,
196
- default: true,
197
- value_options: -> {
198
- Spree::Order.state_machine(:state).states.map { |s|
199
- { value: s.name.to_s, label: s.name.to_s.humanize }
200
- }
201
- }
202
- ```
203
-
204
- Status values are automatically styled:
205
- - **Green** (`badge-active`): `active`, `complete`, `completed`, `paid`, `shipped`, `available`
206
- - **Yellow** (`badge-warning`): `draft`, `pending`, `processing`, `ready`
207
- - **Gray** (`badge-inactive`): `archived`, `canceled`, `cancelled`, `failed`, `void`, `inactive`
208
-
209
- ### Boolean Column
210
-
211
- ```ruby
212
- Spree.admin.tables.products.add :available,
213
- label: :available,
214
- type: :boolean,
215
- sortable: true,
216
- default: true
217
- ```
218
-
219
- ### DateTime Column
220
-
221
- Displays relative time (e.g., "2 hours ago"):
222
-
223
- ```ruby
224
- Spree.admin.tables.orders.add :completed_at,
225
- label: :completed_at,
226
- type: :datetime,
227
- sortable: true,
228
- default: true
229
- ```
230
-
231
- ### Association Column
232
-
233
- For displaying related records:
234
-
235
- ```ruby
236
- Spree.admin.tables.products.add :taxons,
237
- label: :taxons,
238
- type: :association,
239
- filter_type: :autocomplete,
240
- sortable: false,
241
- filterable: true,
242
- default: false,
243
- ransack_attribute: 'taxons_id',
244
- operators: [:in],
245
- search_url: ->(view_context) { view_context.spree.admin_taxons_select_options_path(format: :json) },
246
- method: ->(product) { product.taxons.map(&:pretty_name).join(', ') }
247
- ```
248
-
249
- ### Custom Partial Column
250
-
251
- For complex rendering:
252
-
253
- ```ruby
254
- Spree.admin.tables.products.add :name,
255
- label: :name,
256
- type: :custom,
257
- sortable: true,
258
- default: true,
259
- partial: 'spree/admin/tables/columns/product_name'
260
-
261
- # With dynamic locals
262
- Spree.admin.tables.orders.add :customer,
263
- label: :customer,
264
- type: :custom,
265
- default: true,
266
- partial: 'spree/admin/orders/customer_summary',
267
- partial_locals: ->(record) { { order: record } }
268
- ```
269
-
270
- The partial receives `record`, `column`, and `value` locals plus any custom locals.
271
-
272
- ### Filter-only Column
273
-
274
- Columns that can be filtered but not displayed:
275
-
276
- ```ruby
277
- Spree.admin.tables.orders.add :sku,
278
- label: :sku,
279
- type: :string,
280
- sortable: false,
281
- filterable: true,
282
- displayable: false,
283
- ransack_attribute: 'line_items_variant_sku'
284
- ```
285
-
286
- ## Modifying Existing Tables
287
-
288
- ### Adding Columns to Existing Tables
289
-
290
- ```ruby config/initializers/spree.rb
291
- Rails.application.config.after_initialize do
292
- # Add a custom column to products
293
- Spree.admin.tables.products.add :vendor,
294
- label: 'Vendor',
295
- type: :string,
296
- sortable: false,
297
- default: true,
298
- position: 25,
299
- method: ->(product) { product.vendor&.name },
300
- if: -> { defined?(Spree::Vendor) }
301
- end
302
- ```
303
-
304
- ### Updating Existing Columns
305
-
306
- ```ruby
307
- Rails.application.config.after_initialize do
308
- # Change the position of an existing column
309
- Spree.admin.tables.products.update :price, position: 15
310
-
311
- # Make a column default
312
- Spree.admin.tables.products.update :sku, default: true
313
-
314
- # Change column label
315
- Spree.admin.tables.orders.update :number, label: 'Order #'
316
- end
317
- ```
318
-
319
- ### Removing Columns
320
-
321
- ```ruby
322
- Rails.application.config.after_initialize do
323
- # Remove a column entirely
324
- Spree.admin.tables.products.remove :sku
325
- end
326
- ```
327
-
328
- ### Inserting Columns at Specific Positions
329
-
330
- ```ruby
331
- Rails.application.config.after_initialize do
332
- # Insert before an existing column
333
- Spree.admin.tables.products.insert_before :price, :cost_price,
334
- label: 'Cost Price',
335
- type: :money,
336
- default: false
337
-
338
- # Insert after an existing column
339
- Spree.admin.tables.products.insert_after :name, :brand,
340
- label: 'Brand',
341
- type: :string,
342
- default: true,
343
- method: ->(product) { product.brand&.name }
344
- end
345
- ```
346
-
347
- ## Bulk Actions
348
-
349
- Add bulk actions that appear when users select multiple rows:
350
-
351
- ```ruby
352
- Rails.application.config.after_initialize do
353
- Spree.admin.tables.products.add_bulk_action :set_active,
354
- label: 'admin.bulk_ops.products.title.set_active',
355
- icon: 'circle-check',
356
- action_path: ->(view_context) { view_context.spree.bulk_status_update_admin_products_path(status: 'active') },
357
- body: 'admin.bulk_ops.products.body.set_active',
358
- position: 10,
359
- if: -> { can?(:activate, Spree::Product) }
360
- end
361
- ```
362
-
363
- The modal is automatically rendered via `/admin/bulk_operations/new?kind=:action_key&table_key=:table_key`.
364
-
365
- ### Bulk Action Options
366
-
367
- - **`label`** (`String`) — Translation key or text for the action button.
368
-
369
- - **`icon`** (`String`) — Icon name from [Tabler Icons](https://tabler.io/icons).
370
-
371
- - **`action_path`** (`String | Lambda`) — URL for the bulk action endpoint. Use a Lambda for dynamic paths: `action_path: ->(view_context) { view_context.custom_path }`.
372
-
373
- - **`method`** (`Symbol`) — HTTP method for the action (`:get`, `:post`, `:put`, `:patch`, `:delete`).
374
-
375
- - **`position`** (`Integer`) — Order in the bulk actions menu.
376
-
377
- - **`if`** (`Lambda`) — Conditional visibility based on user permissions.
378
-
379
- - **`confirm`** (`String`) — Confirmation message before executing the action.
380
-
381
- - **`button_text`** (`String`) — Custom text for the modal submit button. Supports translation keys. Defaults to "Confirm".
382
-
383
- - **`button_class`** (`String`) — CSS class for the modal submit button (e.g., `btn-danger` for destructive actions).
384
-
385
- ### Managing Bulk Actions
386
-
387
- ```ruby
388
- # Update a bulk action
389
- Spree.admin.tables.products.update_bulk_action :set_active, position: 5
390
-
391
- # Remove a bulk action
392
- Spree.admin.tables.products.remove_bulk_action :set_archived
393
- ```
394
-
395
- ## Custom Sorting
396
-
397
- For columns that need custom database queries:
398
-
399
- ```ruby
400
- # In your model
401
- class Spree::Product < Spree.base_class
402
- scope :ascend_by_price, -> { joins(:master).order('spree_variants.price ASC') }
403
- scope :descend_by_price, -> { joins(:master).order('spree_variants.price DESC') }
404
- end
405
-
406
- # In your initializer
407
- Spree.admin.tables.products.add :price,
408
- label: :price,
409
- type: :money,
410
- sortable: true,
411
- default: true,
412
- sort_scope_asc: :ascend_by_price,
413
- sort_scope_desc: :descend_by_price,
414
- method: ->(product) { product.price }
415
- ```
416
-
417
- ## Available Tables
418
-
419
- Spree registers tables for all built-in resources:
420
-
421
- | Table Key | Model Class |
422
- |-----------|-------------|
423
- | `:products` | `Spree::Product` |
424
- | `:orders` | `Spree::Order` |
425
- | `:checkouts` | `Spree::Order` (draft) |
426
- | `:users` | `Spree.user_class` |
427
- | `:promotions` | `Spree::Promotion` |
428
- | `:customer_returns` | `Spree::CustomerReturn` |
429
- | `:option_types` | `Spree::OptionType` |
430
- | `:newsletter_subscribers` | `Spree::NewsletterSubscriber` |
431
- | `:policies` | `Spree::Policy` |
432
- | `:stock_transfers` | `Spree::StockTransfer` |
433
- | `:metafield_definitions` | `Spree::MetafieldDefinition` |
434
- | `:gift_cards` | `Spree::GiftCard` |
435
- | `:stock_items` | `Spree::StockItem` |
436
- | `:webhook_endpoints` | `Spree::WebhookEndpoint` |
437
- | `:webhook_deliveries` | `Spree::WebhookDelivery` |
438
- | `:price_list_products` | `Spree::Product` (nested) |
439
-
440
- ## API Reference
441
-
442
- ### Table Methods
443
-
444
- ```ruby
445
- table = Spree.admin.tables.products
446
-
447
- # Column management
448
- table.add(key, **options) # Add a new column
449
- table.remove(key) # Remove a column
450
- table.update(key, **options) # Update column options
451
- table.find(key) # Find a column by key
452
- table.exists?(key) # Check if column exists
453
- table.insert_before(target, key, **options)
454
- table.insert_after(target, key, **options)
455
-
456
- # Query columns
457
- table.available_columns # All displayable columns
458
- table.default_columns # Columns shown by default
459
- table.visible_columns(selected, ctx) # Columns for current view
460
- table.sortable_columns # Columns that can be sorted
461
- table.filterable_columns # Columns for query builder
462
-
463
- # Bulk actions
464
- table.add_bulk_action(key, **options)
465
- table.remove_bulk_action(key)
466
- table.update_bulk_action(key, **options)
467
- table.find_bulk_action(key)
468
- table.visible_bulk_actions(context)
469
- table.bulk_operations_enabled?
470
- ```
471
-
472
- ### Registry Methods
473
-
474
- ```ruby
475
- # Check if a table is registered
476
- Spree.admin.tables.registered?(:brands)
477
-
478
- # Get a table
479
- Spree.admin.tables.get(:products)
480
-
481
- # Shorthand access
482
- Spree.admin.tables.products
483
- ```
484
-
485
- ## Related Documentation
486
-
487
- - [Admin Navigation](navigation.md) - Add custom menu items to the admin
488
- - [Extending Admin UI](extending-ui.md) - Inject partials into admin pages
489
- - [Search & Filtering](../core-concepts/search-filtering.md) - Add searchable/filterable fields
490
- - [Customization Quickstart](../customization/quickstart.md) - Overview of all customization options
@@ -1,92 +0,0 @@
1
- ---
2
- title: Adding to an existing Rails app
3
- description: This guide will show you how to add Spree to an existing Ruby on Rails application.
4
- ---
5
-
6
- > **WARNING:** This guide is aimed at advanced users who want to add Spree to an existing Rails application. If you are new to Spree, please follow the [Quickstart guide](/getting-started/quickstart).
7
-
8
- ## Overview
9
-
10
- If you already have a Ruby on Rails application, you can add Spree to it by following these steps.
11
-
12
- > **INFO:** Spree works with **PostgreSQL**, **MySQL**, and **SQLite** — whatever database your Rails app already uses. No database migration is needed.
13
-
14
- ## 1. Add Spree gems
15
-
16
- Add these lines to your project `Gemfile`:
17
-
18
- ```ruby
19
- spree_opts = { 'github': 'spree/spree', 'branch': 'main' }
20
- gem 'spree', spree_opts # core, API, and CLI
21
- gem 'spree_admin', spree_opts # Admin panel (optional)
22
- gem 'spree_emails', spree_opts # transactional emails (optional)
23
- ```
24
-
25
- And run the following command to install the gems:
26
-
27
- ```bash
28
- bundle install
29
- ```
30
-
31
- ## 2. Run the install generators
32
-
33
- Spree uses a modular installation approach. First install the core, then add optional components.
34
-
35
- ### Install core Spree
36
-
37
- This installs core models, API, CLI, and authentication:
38
-
39
- ```bash
40
- bin/rails g spree:install --user_class=Spree::User --authentication=devise
41
- ```
42
-
43
- **Core installation options:**
44
-
45
- | Option | Description |
46
- |--------|-------------|
47
- | `user_class` | The class for your users, eg. `Spree::User` or `User` |
48
- | `admin_user_class` | The class for admin users (defaults to `user_class`) |
49
- | `authentication` | Authentication gem: `devise` or `custom` |
50
- | `migrate` | Whether to run migrations (default: true) |
51
- | `seed` | Whether to run the seed file (default: true) |
52
- | `sample` | Whether to add sample data (default: false) |
53
- | `admin_email` | Email of the first admin user |
54
- | `admin_password` | Password of the first admin user |
55
-
56
- ### Install Admin Panel (optional)
57
-
58
- ```bash
59
- bin/rails g spree:admin:install
60
- bin/rails g spree:admin:devise # if using Devise authentication
61
- ```
62
-
63
- ### Add sample data (optional)
64
-
65
- To add sample data to your store, run:
66
-
67
- ```bash
68
- bin/rake spree:load_sample_data
69
- ```
70
-
71
- This will add some products, categories and multiple markets to your store.
72
-
73
- ## Accessing Admin Panel
74
-
75
- Navigate to [http://localhost:3000/admin](http://localhost:3000/admin) and log in with the default credentials:
76
-
77
- | | |
78
- |---|---|
79
- | **Email** | `spree@example.com` |
80
- | **Password** | `spree123` |
81
-
82
- Upon successful authentication, you should see the admin screen:
83
-
84
- <img src="/images/spree_admin_dashboard.png" />
85
-
86
- ---
87
-
88
- Congrats! You've set up your Spree Commerce and it's looking amazing!
89
-
90
- Give Spree a [GitHub Star](https://github.com/spree/spree), why don't ya? Thank you for supporting Spree open-source!
91
-
92
- Need support or want to give some feedback? Join our [Discord](https://discord.spreecommerce.org/)
@@ -1,113 +0,0 @@
1
- ---
2
- title: Adjustments
3
- description: How Spree adjustments apply taxes, promotions, and other price modifications to orders, line items, and shipments, and how totals are recalculated.
4
- ---
5
-
6
- ## Overview
7
-
8
- An Adjustment modifies the price of an [Order](orders.md), a [Line Item](orders.md#line-items), or a [Shipment](shipments.md). Adjustments can be positive (charges) or negative (credits).
9
-
10
- ```mermaid
11
- erDiagram
12
- Adjustment {
13
- decimal amount
14
- string label
15
- boolean eligible
16
- boolean mandatory
17
- string state
18
- boolean included
19
- string source_type
20
- string adjustable_type
21
- }
22
-
23
- Order ||--o{ Adjustment : "has many"
24
- Order ||--o{ LineItem : "has many"
25
- Order ||--o{ Shipment : "has many"
26
- LineItem ||--o{ Adjustment : "has many"
27
- Shipment ||--o{ Adjustment : "has many"
28
- TaxRate ||--o{ Adjustment : "creates"
29
- PromotionAction ||--o{ Adjustment : "creates"
30
- ```
31
-
32
- **Key relationships:**
33
- - **Adjustment** modifies prices on orders, line items, or shipments
34
- - **Source** is where the adjustment comes from ([Tax Rate](taxes.md) or [Promotion Action](promotions.md))
35
- - **Adjustable** is what's being adjusted (Order, LineItem, or Shipment)
36
- - Positive amounts are charges, negative amounts are credits
37
-
38
- ## Adjustment Types
39
-
40
- ### Included vs Additional
41
-
42
- - **Included** adjustments are part of the item's displayed price (e.g., VAT in European stores)
43
- - **Additional** adjustments are added on top of the item's price (e.g., US sales tax)
44
-
45
- ### Sources
46
-
47
- Adjustments are created by two sources:
48
-
49
- | Source | Example | Typical Amount |
50
- |--------|---------|----------------|
51
- | [Tax Rate](taxes.md) | Sales tax, VAT | Positive (charge) |
52
- | [Promotion Action](promotions.md) | Coupon discount, free shipping | Negative (credit) |
53
-
54
- ## Adjustment Attributes
55
-
56
- | Attribute | Description | Example |
57
- |-----------|-------------|---------|
58
- | `amount` | The monetary value of the adjustment | `-10.00` |
59
- | `label` | Human-readable description | `10% off order` |
60
- | `eligible` | Whether the adjustment currently applies | `true` |
61
- | `mandatory` | If `true`, always applied regardless of eligibility rules | `false` |
62
- | `state` | `open` (auto-updated) or `closed` (locked) | `open` |
63
- | `included` | Whether the amount is included in the item's displayed price | `false` |
64
-
65
- ## Adjustment Lifecycle
66
-
67
- - **Open** adjustments are recalculated whenever the order is updated (e.g., items added/removed, address changed)
68
- - **Closed** adjustments are locked and will not be automatically recalculated
69
- - When a promotion becomes ineligible (e.g., item removed from cart), its adjustments are automatically removed
70
-
71
- ## Store API
72
-
73
- Adjustments appear in order responses when you [`?expand=items,fulfillments`](../../api-reference/store-api/relations.md) on the order. The response exposes the [`amount`, `adjustment_total`, and the tax totals](../../api-reference/store-api/monetary-amounts.md) as money fields:
74
-
75
-
76
- ```typescript Store SDK
77
- const order = await client.orders.get('or_abc123', { expand: ['items', 'fulfillments'] }, {
78
- spreeToken: '<token>',
79
- })
80
-
81
- // Line item adjustments (promotions, taxes)
82
- order.items?.forEach(item => {
83
- item.adjustment_total // total adjustments on this item
84
- item.additional_tax_total
85
- item.included_tax_total
86
- })
87
-
88
- // Order-level totals
89
- order.adjustment_total // total of all adjustments
90
- order.discount_total // total promotional discounts
91
- order.display_discount_total // formatted promotional discounts
92
- order.additional_tax_total
93
- order.included_tax_total
94
- ```
95
-
96
- ```typescript Admin SDK
97
- const order = await adminClient.orders.get('or_abc123')
98
- ```
99
-
100
- ```bash cURL
101
- curl 'https://api.mystore.com/api/v3/store/orders/or_abc123?expand=items,fulfillments' \
102
- -H 'X-Spree-API-Key: pk_xxx' \
103
- -H 'X-Spree-Token: <token>'
104
- ```
105
-
106
-
107
- ## Related Documentation
108
-
109
- - [Promotions](promotions.md) — Promotion-based adjustments
110
- - [Taxes](taxes.md) — Tax adjustments
111
- - [Shipments](shipments.md) — Shipping adjustments
112
- - [Orders](orders.md) — How adjustments affect order totals
113
- - [Calculators](calculators.md) — How tax rate and promotion action amounts are computed