track_inventory_levels. Additional preferences can be added by your application or included extensions.
preferences. This is an example migration for the
Spree::Productis a subclass of
Spree::Base. If found, the
preferencesattribute gets serialized into a
Hashand merged with the default values.
Usermodel inherits from
Spree::Basethen add the
preferencescolumn. You'll then be able to define preferences for
Users without adding extra columns to the database table.
If you're using
spree_auth_devise, note that the provided
Spree::Userdoesn't inherit from
core/app/models/spree/app_configuration.rband made available to your code through
spree/app_configurationnamespace or create your own subclass of
Spree::Configconstant. This object provides general access to the configuration settings anywhere in the application.
Spree::Configconstant returns an instance of
Spree::AppConfigurationwhich is where the default values for all of the general Spree preferences are defined.
rails consoleand try the following:
spree_preferencesor in our
preferencescolumn. It will use a memory cached version to maintain performance.
Spree::AppConfigurationcan be changed using the
setmethod of the
Spree::Configmodule. 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.configblock acts as a shortcut to setting
Spree::Configmultiple 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.rbwill overwrite any changes that were made through the admin user interface when you restart.
admin/general_settingsURL 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.
MyAppname used here is an example and should be replaced with your actual application's name, found in
MyApp::Config, we must first instantiate the configuration object.
app/viewsdirectory. Defaults to
spree/layouts/spree_application. To make Spree use your application's layout rather than Spree's default, use this:
InventoryUnitobjects to be created when a product is bought. Defaults to