You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 19, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: internals/preferences.md
+9-43Lines changed: 9 additions & 43 deletions
Original file line number
Diff line number
Diff line change
@@ -5,9 +5,13 @@ section: internals
5
5
6
6
# Preferences
7
7
8
+
{% hint style="warning" %}
9
+
We do not advise to use Preferences anymore, we're working on a path forward limitting Preferences in Spree codebase
10
+
{% endhint %}
11
+
8
12
## Overview
9
13
10
-
Spree Preferences support general application configuration and preferences per model instance. Spree comes with preferences for your store like `logo` and `currency`. Additional preferences can be added by your application or included extensions.
14
+
Spree Preferences support general application configuration and preferences per model instance. Spree comes with preferences for your application like `track_inventory_levels`. Additional preferences can be added by your application or included extensions.
11
15
12
16
To implement preferences for a model, simply add a new column called `preferences`. This is an example migration for the `spree_products` table:
13
17
@@ -37,7 +41,7 @@ Both use cases are handled by Spree Preferences. They are easy to define, provid
37
41
38
42
## General Settings
39
43
40
-
Spree comes with many application-wide preferences. They are defined in `core/app/models/spree/app_configuration.rb` and made available to your code through `Spree::Config`, e.g., `Spree::Config.logo`.
44
+
Spree comes with many application-wide preferences. They are defined in `core/app/models/spree/app_configuration.rb` and made available to your code through `Spree::Config`, e.g., `Spree::Config.track_inventory_levels`.
41
45
42
46
A limited set of the general settings are available in the admin interface of your store \(`/admin/general_settings`\).
43
47
@@ -205,8 +209,6 @@ The `Spree::Config` constant returns an instance of `Spree::AppConfiguration` wh
205
209
You can access these preferences directly in code. To see this in action, just fire up `rails console` and try the following:
206
210
207
211
```ruby
208
-
>>Spree::Config.admin_interface_logo
209
-
=> "logo/spree_50.png"
210
212
>>Spree::Config.admin_products_per_page
211
213
=> 10
212
214
```
@@ -243,18 +245,17 @@ During the Spree installation process, an initializer file is created within you
243
245
```ruby
244
246
Spree.config do |config|
245
247
# Example:
246
-
# Uncomment to override the default logo location.
247
-
# config.logo = 'logo/my_store.png'
248
+
# Uncomment to stop tracking inventory levels in the application
249
+
# config.track_inventory_levels = false
248
250
end
249
251
```
250
252
251
253
The `Spree.config` block acts as a shortcut to setting `Spree::Config` multiple times. If you have multiple default preferences you would like to override within your code you may override them here. Using the initializer for setting the defaults is a nice shortcut, and helps keep your preferences organized in a standard location.
252
254
253
-
For example if you would like to change the logo location and if you want to tax using the shipping address you can accomplish this by doing the following:
255
+
For example, if you would like to tax using the shipping address you can accomplish this by doing the following:
254
256
255
257
```ruby
256
258
Spree.config do |config|
257
-
config.logo ='logo/my_store.png'
258
259
config.tax_using_ship_address =true
259
260
end
260
261
```
@@ -313,10 +314,6 @@ This section lists all of the configuration options for the current version of S
313
314
314
315
Will determine if the state field should appear on the checkout page. Defaults to `true`.
315
316
316
-
`admin_interface_logo`
317
-
318
-
The path to the logo to display on the admin interface. Can be different from `Spree::Config[:logo]`. Defaults to `logo/spree_50.png`.
319
-
320
317
`admin_products_per_page`
321
318
322
319
How many products to display on the products listing in the admin interface. Defaults to 30.
@@ -329,43 +326,12 @@ Continues the checkout process even if the payment gateway error failed. Default
329
326
330
327
Determines if an alternative phone number should be present for the shipping address on the checkout page. Defaults to `false`.
331
328
332
-
`always_put_site_name_in_title`
333
-
334
-
Determines if the site name \(`current_store.site_name`\) should be placed into the title. Defaults to `true`.
335
-
336
-
`attachment_default_url`
337
-
338
-
Tells `Paperclip` the form of the URL to use for attachments which are missing.
339
-
340
-
`attachment_path`
341
-
342
-
Tells `Paperclip` the path at which to store images.
343
-
344
-
`attachment_styles`
345
-
346
329
A JSON hash of different styles that are supported by attachments. Defaults to:
347
330
348
-
```javascript
349
-
{
350
-
"mini":"48x48>",
351
-
"small":"100x100>",
352
-
"product":"240x240>",
353
-
"large":"600x600>"
354
-
}
355
-
```
356
-
357
-
`attachment_default_style`
358
-
359
-
A key from the list of styles from `Spree::Config[:attachment_styles]` that is the default style for images. Defaults to the the `product` style.
360
-
361
331
`auto_capture`
362
332
363
333
Depending on whether or not Spree is configured to "auto capture" the credit card, either a purchase or an authorize operation will be performed on the card \(via the current credit card gateway\). Defaults to `false`.
364
334
365
-
`checkout_zone`
366
-
367
-
Limits the checkout to countries from a specific zone, by name. Defaults to `nil`.
368
-
369
335
`company`
370
336
371
337
Determines whether or not a field for "Company" displays on the checkout pages for shipping and billing addresses. Defaults to `false`.
0 commit comments