Class: Spree::AppConfiguration

Inherits:
Preferences::Configuration show all
Defined in:
lib/spree/app_configuration.rb

Instance Attribute Summary collapse

Attributes inherited from Preferences::Configuration

#preference_store

Instance Method Summary collapse

Methods inherited from Preferences::Configuration

class_name_attribute, #configure, preference, #reset, #set, #use_legacy_db_preferences!, #use_static_preferences!

Methods included from Preferences::Preferable

#default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference

Instance Attribute Details

#add_payment_sources_to_wallet_classClass

Allows providing your own class for adding payment sources to a user's “wallet” after an order moves to the complete state.

Returns:

  • (Class)

    a class with the same public interfaces as Spree::Wallet::AddPaymentSourcesToWallet.



339
# File 'lib/spree/app_configuration.rb', line 339

class_name_attribute :add_payment_sources_to_wallet_class, default: 'Spree::Wallet::AddPaymentSourcesToWallet'

#address_requires_stateBoolean

Returns should state/state_name be required

Returns:

  • (Boolean)

    should state/state_name be required



29
# File 'lib/spree/app_configuration.rb', line 29

preference :address_requires_state, :boolean, default: true

#admin_interface_logoString

Returns URL of logo used in admin (default: 'logo/solidus_logo.png')

Returns:

  • (String)

    URL of logo used in admin (default: 'logo/solidus_logo.png')



33
# File 'lib/spree/app_configuration.rb', line 33

preference :admin_interface_logo, :string, default: 'logo/solidus_logo.png'

#admin_products_per_pageInteger

Returns Number of products to display in admin (default: 10)

Returns:

  • (Integer)

    Number of products to display in admin (default: 10)



37
# File 'lib/spree/app_configuration.rb', line 37

preference :admin_products_per_page, :integer, default: 10

#admin_variants_per_pageInteger

Returns Number of variants to display in admin (default: 20)

Returns:

  • (Integer)

    Number of variants to display in admin (default: 20)



41
# File 'lib/spree/app_configuration.rb', line 41

preference :admin_variants_per_page, :integer, default: 20

#admin_vat_country_isoString?

Set this if you want to enter prices in the backend including value added tax.

Returns:

  • (String, nil)

    Two-letter ISO code of that Country for which prices are entered in the backend (default: nil)



131
# File 'lib/spree/app_configuration.rb', line 131

preference :admin_vat_country_iso, :string, default: nil

#allow_checkout_on_gateway_errorBoolean

Returns Allow checkout to complete after a failed payment (default: false)

Returns:

  • (Boolean)

    Allow checkout to complete after a failed payment (default: false)



45
# File 'lib/spree/app_configuration.rb', line 45

preference :allow_checkout_on_gateway_error, :boolean, default: false

#allow_guest_checkoutBoolean

Returns When false, customers must create an account to complete an order (default: true)

Returns:

  • (Boolean)

    When false, customers must create an account to complete an order (default: true)



49
# File 'lib/spree/app_configuration.rb', line 49

preference :allow_guest_checkout, :boolean, default: true

#allow_return_item_amount_editingBoolean

Returns Determines whether an admin is allowed to change a return item's pre-calculated amount (default: false)

Returns:

  • (Boolean)

    Determines whether an admin is allowed to change a return item's pre-calculated amount (default: false)



53
# File 'lib/spree/app_configuration.rb', line 53

preference :allow_return_item_amount_editing, :boolean, default: false

#alternative_billing_phoneBoolean

Returns Request an extra phone number for bill address (default: false)

Returns:

  • (Boolean)

    Request an extra phone number for bill address (default: false)



57
# File 'lib/spree/app_configuration.rb', line 57

preference :alternative_billing_phone, :boolean, default: false

#alternative_shipping_phoneBoolean

Returns Request an extra phone number for shipping address (default: false)

Returns:

  • (Boolean)

    Request an extra phone number for shipping address (default: false)



61
# File 'lib/spree/app_configuration.rb', line 61

preference :alternative_shipping_phone, :boolean, default: false

#always_put_site_name_in_titleBoolean

Returns When true, site name is always appended to titles on the frontend (default: true)

Returns:

  • (Boolean)

    When true, site name is always appended to titles on the frontend (default: true)



65
# File 'lib/spree/app_configuration.rb', line 65

preference :always_put_site_name_in_title, :boolean, default: true

#auto_captureBoolean

Note:

Setting this to true is not recommended. Performing an authorize and later capture has far superior error handing. VISA and MasterCard also require that shipments are sent within a certain time of the card being charged.

Returns Perform a sale/purchase transaction at checkout instead of a authorize and capture.

Returns:

  • (Boolean)

    Perform a sale/purchase transaction at checkout instead of a authorize and capture.



73
# File 'lib/spree/app_configuration.rb', line 73

preference :auto_capture, :boolean, default: false

#auto_capture_exchangesBoolean

Returns automatically capture the credit card (as opposed to just authorize and capture later) (default: false)

Returns:

  • (Boolean)

    automatically capture the credit card (as opposed to just authorize and capture later) (default: false)



77
# File 'lib/spree/app_configuration.rb', line 77

preference :auto_capture_exchanges, :boolean, default: false

#automatic_default_addressBoolean

The default value of true preserves existing backwards compatible feature of treating the most recently used address in checkout as the user's default address. Setting to false means that the user should manage their own default via some custom UI that uses AddressBookController.

Returns:

  • (Boolean)

    Whether use of an address in checkout marks it as user's default



254
# File 'lib/spree/app_configuration.rb', line 254

preference :automatic_default_address, :boolean, default: true

#binary_inventory_cacheBoolean

Deprecated.
  • use inventory_cache_threshold instead

Only invalidate product caches when they change from in stock to out of stock. By default, caches are invalidated on any change of inventory quantity. Setting this to true should make operations on inventory faster. (default: false)

Returns:

  • (Boolean)


87
# File 'lib/spree/app_configuration.rb', line 87

preference :binary_inventory_cache, :boolean, default: false

#can_restrict_stock_managementBoolean

Returns Indicates if stock management can be restricted by location

Returns:

  • (Boolean)

    Indicates if stock management can be restricted by location



258
# File 'lib/spree/app_configuration.rb', line 258

preference :can_restrict_stock_management, :boolean, default: false

#carton_shipped_email_classActionMailer::Base

Allows providing your own Mailer for shipped cartons.

Returns:

  • (ActionMailer::Base)

    an object that responds to “shipped_email” (e.g. an ActionMailer with a “shipped_email” method) with the same signature as Spree::CartonMailer.shipped_email.



305
# File 'lib/spree/app_configuration.rb', line 305

class_name_attribute :carton_shipped_email_class, default: 'Spree::CartonMailer'

#checkout_zoneString

Returns Name of a Zone, which limits available countries to those included in that zone. (default: nil)

Returns:

  • (String)

    Name of a Zone, which limits available countries to those included in that zone. (default: nil)



106
# File 'lib/spree/app_configuration.rb', line 106

preference :checkout_zone, :string, default: nil

#companyBoolean

Returns Request company field for billing and shipping addresses. (default: false)

Returns:

  • (Boolean)

    Request company field for billing and shipping addresses. (default: false)



110
# File 'lib/spree/app_configuration.rb', line 110

preference :company, :boolean, default: false

#completable_order_created_cutoffInteger

Returns the number of days to look back for updated orders which get returned to the user as last completed

Returns:

  • (Integer)

    the number of days to look back for updated orders which get returned to the user as last completed



91
# File 'lib/spree/app_configuration.rb', line 91

preference :completable_order_created_cutoff_days, :integer, default: nil

#credit_to_new_allocationBoolean

Returns Creates a new allocation anytime StoreCredit#credit is called

Returns:



246
# File 'lib/spree/app_configuration.rb', line 246

preference :credit_to_new_allocation, :boolean, default: false

#currencyString

Currency to use by default when not defined on the site (default: “USD”)

Returns:

  • (String)

    ISO 4217 Three letter currency code



115
# File 'lib/spree/app_configuration.rb', line 115

preference :currency, :string, default: "USD"

#current_store_selector_classClass

Allows providing your own class for choosing which store to use.

Returns:

  • (Class)

    a class with the same public interfaces as Spree::CurrentStoreSelector



364
# File 'lib/spree/app_configuration.rb', line 364

class_name_attribute :current_store_selector_class, default: 'Spree::StoreSelector::ByServerName'

#customer_returns_per_pageInteger

Returns Customer returns to show per-page in the admin (default: 15)

Returns:

  • (Integer)

    Customer returns to show per-page in the admin (default: 15)



181
# File 'lib/spree/app_configuration.rb', line 181

preference :customer_returns_per_page, :integer, default: 15

#default_country_idInteger?

Deprecated.

Use the default country ISO preference instead

Returns id of Country to be selected by default in dropdowns (default: nil)

Returns:

  • (Integer, nil)

    id of Country to be selected by default in dropdowns (default: nil)



120
# File 'lib/spree/app_configuration.rb', line 120

preference :default_country_id, :integer

#default_country_isoString

Default customer country ISO code

Returns:

  • (String)

    Two-letter ISO code of a Country to assumed as the country of an unidentified customer (default: “US”)



125
# File 'lib/spree/app_configuration.rb', line 125

preference :default_country_iso, :string, default: 'US'

#default_payment_builder_classClass

Allows providing your own class for adding default payments to a user's order from their “wallet”.

Returns:

  • (Class)

    a class with the same public interfaces as Spree::Wallet::DefaultPaymentBuilder.



320
# File 'lib/spree/app_configuration.rb', line 320

class_name_attribute :default_payment_builder_class, default: 'Spree::Wallet::DefaultPaymentBuilder'

#generate_api_key_for_all_rolesBoolean

at role_user creation for all roles. (default: false)

Returns:

  • (Boolean)

    Allow generating api key automatically for user



136
# File 'lib/spree/app_configuration.rb', line 136

preference :generate_api_key_for_all_roles, :boolean, default: false

#inventory_cache_thresholdInteger

Only invalidate product caches when the count on hand for a stock item falls below or rises about the inventory_cache_threshold. When undefined, the product caches will be invalidated anytime the count on hand is changed.

Returns:

  • (Integer)


102
# File 'lib/spree/app_configuration.rb', line 102

preference :inventory_cache_threshold, :integer

#layoutString

Returns template to use for layout on the frontend (default: “spree/layouts/spree_application”)

Returns:

  • (String)

    template to use for layout on the frontend (default: “spree/layouts/spree_application”)



140
# File 'lib/spree/app_configuration.rb', line 140

preference :layout, :string, default: 'spree/layouts/spree_application'

#logoString

Returns URL of logo used on frontend (default: 'logo/solidus_logo.png')

Returns:

  • (String)

    URL of logo used on frontend (default: 'logo/solidus_logo.png')



144
# File 'lib/spree/app_configuration.rb', line 144

preference :logo, :string, default: 'logo/solidus_logo.png'

#mails_fromString

Returns Email address used as From: field in transactional emails.

Returns:

  • (String)

    Email address used as From: field in transactional emails.



240
# File 'lib/spree/app_configuration.rb', line 240

preference :mails_from, :string, default: 'spree@example.com'

#max_level_in_taxons_menuInteger

Returns maximum nesting level in taxons menu (default: 1)

Returns:

  • (Integer)

    maximum nesting level in taxons menu (default: 1)



157
# File 'lib/spree/app_configuration.rb', line 157

preference :max_level_in_taxons_menu, :integer, default: 1

#order_bill_address_usedBoolean

bill addresses on payment sources. (default: true)

Returns:

  • (Boolean)

    Use the order's bill address, as opposed to storing



149
# File 'lib/spree/app_configuration.rb', line 149

preference :order_bill_address_used, :boolean, default: true

#order_capturing_time_windowInteger

Returns the number of days to look back for fully-shipped/cancelled orders in order to charge for them

Returns:

  • (Integer)

    the number of days to look back for fully-shipped/cancelled orders in order to charge for them



153
# File 'lib/spree/app_configuration.rb', line 153

preference :order_capturing_time_window, :integer, default: 14

#order_merger_classClass

Allows providing your own class for merging two orders.

Returns:

  • (Class)

    a class with the same public interfaces as Spree::OrderMerger.



312
# File 'lib/spree/app_configuration.rb', line 312

class_name_attribute :order_merger_class, default: 'Spree::OrderMerger'

#order_mutex_max_ageInteger

Returns Max age of OrderMutex in seconds (default: 2 minutes)

Returns:

  • (Integer)

    Max age of OrderMutex in seconds (default: 2 minutes)



161
# File 'lib/spree/app_configuration.rb', line 161

preference :order_mutex_max_age, :integer, default: 120

#order_number_generatorClass

Allows providing your own class instance for generating order numbers.

Returns:

  • (Class)

    a class instance with the same public interfaces as Spree::Order::NumberGenerator



372
# File 'lib/spree/app_configuration.rb', line 372

attr_writer :order_number_generator

#orders_per_pageInteger

Returns Orders to show per-page in the admin (default: 15)

Returns:

  • (Integer)

    Orders to show per-page in the admin (default: 15)



165
# File 'lib/spree/app_configuration.rb', line 165

preference :orders_per_page, :integer, default: 15

#payment_cancellerClass

Allows providing your own class for canceling payments.

Returns:

  • (Class)

    a class instance that responds to `cancel!(payment)`



326
# File 'lib/spree/app_configuration.rb', line 326

attr_writer :payment_canceller

#products_per_pageInteger

Returns Products to show per-page in the frontend (default: 12)

Returns:

  • (Integer)

    Products to show per-page in the frontend (default: 12)



173
# File 'lib/spree/app_configuration.rb', line 173

preference :products_per_page, :integer, default: 12

#promotions_per_pageInteger

Returns Promotions to show per-page in the admin (default: 15)

Returns:

  • (Integer)

    Promotions to show per-page in the admin (default: 15)



177
# File 'lib/spree/app_configuration.rb', line 177

preference :promotions_per_page, :integer, default: 15

#properties_per_pageInteger

Returns Properties to show per-page in the admin (default: 15)

Returns:

  • (Integer)

    Properties to show per-page in the admin (default: 15)



169
# File 'lib/spree/app_configuration.rb', line 169

preference :properties_per_page, :integer, default: 15

#require_master_priceBoolean

Returns Require a price on the master variant of a product (default: true)

Returns:

  • (Boolean)

    Require a price on the master variant of a product (default: true)



185
# File 'lib/spree/app_configuration.rb', line 185

preference :require_master_price, :boolean, default: true

#require_payment_to_shipBoolean

Returns Allows shipments to be ready to ship regardless of the order being paid if false (default: true)

Returns:

  • (Boolean)

    Allows shipments to be ready to ship regardless of the order being paid if false (default: true)



189
# File 'lib/spree/app_configuration.rb', line 189

preference :require_payment_to_ship, :boolean, default: true

#return_eligibility_number_of_daysInteger

Returns default: 365

Returns:

  • (Integer)

    default: 365



193
# File 'lib/spree/app_configuration.rb', line 193

preference :return_eligibility_number_of_days, :integer, default: 365

#roles_for_auto_api_keyArray

at role_user creation is desired when user has one of these roles. (default: ['admin'])

Returns:

  • (Array)

    An array of roles where generating an api key for a user



199
# File 'lib/spree/app_configuration.rb', line 199

preference :roles_for_auto_api_key, :array, default: ['admin']

#send_core_emailsBoolean

Returns Whether to send transactional emails (default: true)

Returns:

  • (Boolean)

    Whether to send transactional emails (default: true)



236
# File 'lib/spree/app_configuration.rb', line 236

preference :send_core_emails, :boolean, default: true

#shipping_instructionsBoolean

Returns Request instructions/info for shipping (default: false)

Returns:

  • (Boolean)

    Request instructions/info for shipping (default: false)



203
# File 'lib/spree/app_configuration.rb', line 203

preference :shipping_instructions, :boolean, default: false

#shipping_rate_tax_calculator_classClass

Allows providing your own class for calculating taxes on a shipping rate.

Returns:

  • (Class)

    a class with the same public interfaces as Spree::TaxCalculator::ShippingRate



297
# File 'lib/spree/app_configuration.rb', line 297

class_name_attribute :shipping_rate_tax_calculator_class, default: 'Spree::TaxCalculator::ShippingRate'

#show_only_complete_orders_by_defaultBoolean

Returns Only show completed orders by default in the admin (default: true)

Returns:

  • (Boolean)

    Only show completed orders by default in the admin (default: true)



207
# File 'lib/spree/app_configuration.rb', line 207

preference :show_only_complete_orders_by_default, :boolean, default: true

#show_products_without_priceBoolean

Returns Whether products without a price are visible in the frontend (default: false)

Returns:

  • (Boolean)

    Whether products without a price are visible in the frontend (default: false)



215
# File 'lib/spree/app_configuration.rb', line 215

preference :show_products_without_price, :boolean, default: false

#show_raw_product_descriptionBoolean

Returns Don't escape HTML of product descriptions. (default: false)

Returns:

  • (Boolean)

    Don't escape HTML of product descriptions. (default: false)



219
# File 'lib/spree/app_configuration.rb', line 219

preference :show_raw_product_description, :boolean, default: false

#show_variant_full_priceBoolean

Returns Displays variant full price or difference with product price. (default: false)

Returns:

  • (Boolean)

    Displays variant full price or difference with product price. (default: false)



211
# File 'lib/spree/app_configuration.rb', line 211

preference :show_variant_full_price, :boolean, default: false

#tax_adjuster_classClass

Allows providing your own class for calculating taxes on an order.

This extension point is under development and may change in a future minor release.

Returns:

  • (Class)

    a class with the same public interfaces as Spree::Tax::OrderAdjuster



349
# File 'lib/spree/app_configuration.rb', line 349

class_name_attribute :tax_adjuster_class, default: 'Spree::Tax::OrderAdjuster'

#tax_calculator_classClass

Allows providing your own class for calculating taxes on an order.

Returns:

  • (Class)

    a class with the same public interfaces as Spree::TaxCalculator::Default



357
# File 'lib/spree/app_configuration.rb', line 357

class_name_attribute :tax_calculator_class, default: 'Spree::TaxCalculator::Default'

#tax_using_ship_addressBoolean

Returns Use the shipping address rather than the billing address to determine tax (default: true)

Returns:

  • (Boolean)

    Use the shipping address rather than the billing address to determine tax (default: true)



223
# File 'lib/spree/app_configuration.rb', line 223

preference :tax_using_ship_address, :boolean, default: true

#track_inventory_levelsObject

Determines whether to track on_hand values for variants / products. If you do not track inventory, or have effectively unlimited inventory for all products you can turn this on.

Returns:

  • Track on_hand values for variants / products. (default: true)



230
# File 'lib/spree/app_configuration.rb', line 230

preference :track_inventory_levels, :boolean, default: true

#variant_price_selector_classClass

Allows implementing custom pricing for variants

Returns:

  • (Class)

    an object that conforms to the API of the standard variant price selector class Spree::Variant::PriceSelector.

See Also:



268
# File 'lib/spree/app_configuration.rb', line 268

class_name_attribute :variant_price_selector_class, default: 'Spree::Variant::PriceSelector'

Instance Method Details

#admin_vat_locationSpree::Tax::TaxLocation

Default admin VAT location

An object that responds to :state_id and :country_id so it can double as a Spree::Address in Spree::Zone.for_address. Takes the `admin_vat_country_iso` as input.

Returns:

See Also:



475
476
477
478
479
# File 'lib/spree/app_configuration.rb', line 475

def admin_vat_location
  @default_tax_location ||= Spree::Tax::TaxLocation.new(
    country: Spree::Country.find_by(iso: admin_vat_country_iso)
  )
end

#default_pricing_optionsvariant_price_selector_class

Shortcut for the default pricing options

Returns:



278
279
280
# File 'lib/spree/app_configuration.rb', line 278

def default_pricing_options
  pricing_options_class.new
end

#environmentObject



392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
# File 'lib/spree/app_configuration.rb', line 392

def environment
  @environment ||= Spree::Core::Environment.new(self).tap do |env|
    env.calculators.shipping_methods = %w[
      Spree::Calculator::Shipping::FlatPercentItemTotal
      Spree::Calculator::Shipping::FlatRate
      Spree::Calculator::Shipping::FlexiRate
      Spree::Calculator::Shipping::PerItem
      Spree::Calculator::Shipping::PriceSack
    ]

    env.calculators.tax_rates = %w[
      Spree::Calculator::DefaultTax
    ]

    env.stock_splitters = %w[
      Spree::Stock::Splitter::ShippingCategory
      Spree::Stock::Splitter::Backordered
    ]

    env.payment_methods = %w[
      Spree::PaymentMethod::BogusCreditCard
      Spree::PaymentMethod::SimpleBogusCreditCard
      Spree::PaymentMethod::StoreCredit
      Spree::PaymentMethod::Check
    ]

    env.promotions = Spree::Promo::Environment.new.tap do |promos|
      promos.rules = %w[
        Spree::Promotion::Rules::ItemTotal
        Spree::Promotion::Rules::Product
        Spree::Promotion::Rules::User
        Spree::Promotion::Rules::FirstOrder
        Spree::Promotion::Rules::UserLoggedIn
        Spree::Promotion::Rules::OneUsePerUser
        Spree::Promotion::Rules::Taxon
        Spree::Promotion::Rules::NthOrder
        Spree::Promotion::Rules::OptionValue
        Spree::Promotion::Rules::FirstRepeatPurchaseSince
        Spree::Promotion::Rules::UserRole
      ]

      promos.actions = %w[
        Spree::Promotion::Actions::CreateAdjustment
        Spree::Promotion::Actions::CreateItemAdjustments
        Spree::Promotion::Actions::CreateQuantityAdjustments
        Spree::Promotion::Actions::FreeShipping
      ]

      promos.shipping_actions = %w[
        Spree::Promotion::Actions::FreeShipping
      ]
    end

    env.calculators.promotion_actions_create_adjustments = %w[
      Spree::Calculator::FlatPercentItemTotal
      Spree::Calculator::FlatRate
      Spree::Calculator::FlexiRate
      Spree::Calculator::TieredPercent
      Spree::Calculator::TieredFlatRate
    ]

    env.calculators.promotion_actions_create_item_adjustments = %w[
      Spree::Calculator::DistributedAmount
      Spree::Calculator::FlatRate
      Spree::Calculator::FlexiRate
      Spree::Calculator::PercentOnLineItem
      Spree::Calculator::TieredPercent
    ]

    env.calculators.promotion_actions_create_quantity_adjustments = %w[
      Spree::Calculator::PercentOnLineItem
      Spree::Calculator::FlatRate
    ]
  end
end

#pricing_options_classClass

Shortcut for getting the variant price selector's pricing options class

Returns:

  • (Class)

    The pricing options class to be used



273
# File 'lib/spree/app_configuration.rb', line 273

delegate :pricing_options_class, to: :variant_price_selector_class

#rolesObject



385
386
387
388
389
390
# File 'lib/spree/app_configuration.rb', line 385

def roles
  @roles ||= Spree::RoleConfiguration.new.tap do |roles|
    roles.assign_permissions :default, ['Spree::PermissionSets::DefaultCustomer']
    roles.assign_permissions :admin, ['Spree::PermissionSets::SuperUser']
  end
end

#static_model_preferencesObject



377
378
379
# File 'lib/spree/app_configuration.rb', line 377

def static_model_preferences
  @static_model_preferences ||= Spree::Preferences::StaticModelPreferences.new
end

#stockObject



381
382
383
# File 'lib/spree/app_configuration.rb', line 381

def stock
  @stock_configuration ||= Spree::Core::StockConfiguration.new
end