track_inventory_levels
. Additional preferences can be added by your application or included extensions.preferences
. This is an example migration for the spree_products
table:Spree::Product
is a subclass of Spree::Base
. If found, the preferences
attribute gets serialized into a Hash
and merged with the default values.User
model inherits from Spree::Base
then add the preferences
column. You'll then be able to define preferences for User
s without adding extra columns to the database table.If you're usingspree_auth_devise
, note that the providedSpree::User
doesn't inherit fromSpree::Base
.
core/app/models/spree/app_configuration.rb
and made available to your code through Spree::Config
, e.g., Spree::Config.track_inventory_levels
./admin/general_settings
).spree/app_configuration
namespace or create your own subclass of Preferences::Configuration
.hot_salsa
dark_chocolate
color
favorite_number
language
boolean
string
password
integer
text
array
hash
preferences
helper:Spree::Config
constant. This object provides general access to the configuration settings anywhere in the application.Spree::Config
constant returns an instance of Spree::AppConfiguration
which is where the default values for all of the general Spree preferences are defined.rails console
and try the following:Spree::AppConfiguration
class.spree_preferences
or in our preferences
column. It will use a memory cached version to maintain performance.Spree::AppConfiguration
can be changed using the set
method of the Spree::Config
module. For example to set the number of products shown on the products listing in the admin interface we could do the following:Spree::AppConfiguration
. In this case the preference system will persist the new value in the spree_preferences
table.config/initializers/spree.rb
: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.config/initializers/spree.rb
will overwrite any changes that were made through the admin user interface when you restart.admin/general_settings
URL in your Spree application can be used to configure the values for the site name and the site URL. This is basically equivalent to calling Spree::Config.set(currency: "CDN", currency_thousands_separator: " ")
directly in your Ruby code.Spree::Preferences::Configuration
.lib/
directory.MyApp
name used here is an example and should be replaced with your actual application's name, found in config/application.rb
.MyApp::Config
, we must first instantiate the configuration object.address_requires_state
true
.admin_products_per_page
allow_checkout_on_gateway_error
false
.alternative_shipping_phone
false
.auto_capture
false
.company
false
.currency
default_country_id
layout
app/views
directory. Defaults to spree/layouts/spree_application
. To make Spree use your application's layout rather than Spree's default, use this:max_level_in_taxons_menu
1
.admin_orders_per_page
30
.prices_inc_tax
false
.shipment_inc_vat
false
.shipping_instructions
false
.show_descendents
true
.show_only_complete_orders_by_default
true
.show_variant_full_price
false
.show_store_selector
false
.tax_using_ship_address
true
.track_inventory_levels
InventoryUnit
objects to be created when a product is bought. Defaults to true
.