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

#admin_form_preference_names, #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.



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

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

#address_requires_stateBoolean



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

preference :address_requires_state, :boolean, default: true

#admin_interface_logoString



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

preference :admin_interface_logo, :string, default: 'logo/solidus.svg'

#admin_products_per_pageInteger



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

preference :admin_products_per_page, :integer, default: 10

#admin_variants_per_pageInteger



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

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.



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

preference :admin_vat_country_iso, :string, default: nil

#allow_checkout_on_gateway_errorBoolean



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

preference :allow_checkout_on_gateway_error, :boolean, default: false

#allow_guest_checkoutBoolean



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

preference :allow_guest_checkout, :boolean, default: true

#allow_return_item_amount_editingBoolean



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

preference :allow_return_item_amount_editing, :boolean, default: false

#alternative_billing_phoneBoolean



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

preference :alternative_billing_phone, :boolean, default: false

#alternative_shipping_phoneBoolean



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

preference :alternative_shipping_phone, :boolean, default: false

#always_put_site_name_in_titleBoolean



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

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 Automatically capture the credit card (as opposed to just authorize and capture later) (default: false).



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

preference :auto_capture, :boolean, default: false

#auto_capture_exchangesBoolean



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

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.



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

preference :automatic_default_address, :boolean, default: true

#available_currenciesArray



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

attr_writer :available_currencies

#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)



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

preference :binary_inventory_cache, :boolean, default: false

#can_restrict_stock_managementBoolean



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

preference :can_restrict_stock_management, :boolean, default: false

#carton_shipped_email_classActionMailer::Base

Allows providing your own Mailer for shipped cartons.



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

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

#checkout_zoneString



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

preference :checkout_zone, :string, default: nil

#companyBoolean



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

preference :company, :boolean, default: false

#completable_order_created_cutoffInteger



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

preference :completable_order_created_cutoff_days, :integer, default: nil

#credit_to_new_allocationBoolean



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

preference :credit_to_new_allocation, :boolean, default: false

#currencyString

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



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

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

#current_store_selector_classClass

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



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

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

#customer_returns_per_pageInteger



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

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).



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

preference :default_country_id, :integer

#default_country_isoString

Default customer country ISO code



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

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”.



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

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)



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

preference :generate_api_key_for_all_roles, :boolean, default: false

#image_attachment_moduleModule

Allows switching attachment library for Image

‘Spree::Image::PaperclipAttachment` is the default and provides the classic Paperclip implementation.

Enumerable of images adhering to the present_image_class interface



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

class_name_attribute :image_attachment_module, default: 'Spree::Image::PaperclipAttachment'

#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.



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

preference :inventory_cache_threshold, :integer

#layoutString



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

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

#logoString



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

preference :logo, :string, default: 'logo/solidus.svg'

#mails_fromString



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

preference :mails_from, :string, default: '[email protected]'

#max_level_in_taxons_menuInteger



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

preference :max_level_in_taxons_menu, :integer, default: 1

#order_bill_address_usedBoolean

bill addresses on payment sources. (default: true)



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

preference :order_bill_address_used, :boolean, default: true

#order_capturing_time_windowInteger



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

preference :order_capturing_time_window, :integer, default: 14

#order_mailer_classActionMailer::Base

Allows providing your own Mailer for order mailer.



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

class_name_attribute :order_mailer_class, default: 'Spree::OrderMailer'

#order_merger_classClass

Allows providing your own class for merging two orders.



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

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

#order_mutex_max_ageInteger



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

preference :order_mutex_max_age, :integer, default: 120

#order_number_generatorClass

Allows providing your own class instance for generating order numbers.



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

attr_writer :order_number_generator

#orders_per_pageInteger



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

preference :orders_per_page, :integer, default: 15

#payment_cancellerClass

Allows providing your own class for canceling payments.



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

attr_writer :payment_canceller

Allows providing your own class for image galleries on Products

Enumerable of images adhering to the present_image_class interface



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

class_name_attribute :product_gallery_class, default: 'Spree::Gallery::ProductGallery'

#products_per_pageInteger



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

preference :products_per_page, :integer, default: 12

#promotion_code_batch_mailer_classActionMailer::Base

Allows providing your own Mailer for promotion code batch mailer.



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

class_name_attribute :promotion_code_batch_mailer_class, default: 'Spree::PromotionCodeBatchMailer'

#promotions_per_pageInteger



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

preference :promotions_per_page, :integer, default: 15

#properties_per_pageInteger



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

preference :properties_per_page, :integer, default: 15

#reimbursement_mailer_classActionMailer::Base

Allows providing your own Mailer for reimbursement mailer.



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

class_name_attribute :reimbursement_mailer_class, default: 'Spree::ReimbursementMailer'

#require_master_priceBoolean



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

preference :require_master_price, :boolean, default: true

#require_payment_to_shipBoolean



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

preference :require_payment_to_ship, :boolean, default: true

#return_eligibility_number_of_daysInteger



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

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’])



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

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

#send_core_emailsBoolean



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

preference :send_core_emails, :boolean, default: true

#shipping_instructionsBoolean



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

preference :shipping_instructions, :boolean, default: false

#shipping_rate_tax_calculator_classClass

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



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

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

#show_only_complete_orders_by_defaultBoolean



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

preference :show_only_complete_orders_by_default, :boolean, default: true

#show_products_without_priceBoolean



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

preference :show_products_without_price, :boolean, default: false

#show_raw_product_descriptionBoolean



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

preference :show_raw_product_description, :boolean, default: false

#show_variant_full_priceBoolean



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

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.



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

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

#tax_calculator_classClass

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



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

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

#tax_using_ship_addressBoolean



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

preference :tax_using_ship_address, :boolean, default: true

#taxon_attachment_moduleModule

Allows switching attachment library for Taxon

‘Spree::Taxon::PaperclipAttachment` is the default and provides the classic Paperclip implementation.

Enumerable of taxons adhering to the present_taxon_class interface



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

class_name_attribute :taxon_attachment_module, default: 'Spree::Taxon::PaperclipAttachment'

#taxon_url_parametizer_classClass

Allows providing your own class for creating urls on taxons

returns a String



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

class_name_attribute :taxon_url_parametizer_class, default: 'ActiveSupport::Inflector'

#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.



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

preference :track_inventory_levels, :boolean, default: true

Allows providing your own class for image galleries on Variants

Enumerable of images adhering to the present_image_class interface



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

class_name_attribute :variant_gallery_class, default: 'Spree::Gallery::VariantGallery'

#variant_price_selector_classClass

Allows implementing custom pricing for variants



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

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.



558
559
560
561
562
# File 'lib/spree/app_configuration.rb', line 558

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



289
290
291
# File 'lib/spree/app_configuration.rb', line 289

def default_pricing_options
  pricing_options_class.new
end

#environmentObject



476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
# File 'lib/spree/app_configuration.rb', line 476

def environment
  @environment ||= Spree::Core::Environment.new(self).tap do |env|
    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
    ]

    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.payment_methods = %w[
      Spree::PaymentMethod::BogusCreditCard
      Spree::PaymentMethod::SimpleBogusCreditCard
      Spree::PaymentMethod::StoreCredit
      Spree::PaymentMethod::Check
    ]

    env.promotions.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
      Spree::Promotion::Rules::Store
    ]

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

    env.promotions.shipping_actions = %w[
      Spree::Promotion::Actions::FreeShipping
    ]

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

#eventsObject



472
473
474
# File 'lib/spree/app_configuration.rb', line 472

def events
  @events_configuration ||= Spree::Event::Configuration.new
end

#pricing_options_classClass

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



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

delegate :pricing_options_class, to: :variant_price_selector_class

#rolesObject



465
466
467
468
469
470
# File 'lib/spree/app_configuration.rb', line 465

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



457
458
459
# File 'lib/spree/app_configuration.rb', line 457

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

#stockObject



461
462
463
# File 'lib/spree/app_configuration.rb', line 461

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