Getting started
Core Concepts
Extending Spree
Upgrading
- Quickstart
- Upgrade Guides
Contributing
Quickstart
Learn how to customize every part of the Spree stack
Spree is a very flexible platform allowing you to customize every part of it, to suit your business needs.
There are several ways you can achieve this:
There’s a lot of Store settings you can change in the admin panel without touching the code.
Changing currency, shipping zones, languages - it’s very easy to do.
Go to Admin > Configuration > General Settings
Configuration allows you to tweak Spree’s behavior without having to modify the source code.
Spree comes with a handful configuration options you can change:
Configuration Key | Description | Default Value |
---|---|---|
allow_checkout_on_gateway_error | Continues the checkout process even if the payment gateway error failed. | false |
address_requires_phone | Determines whether a phone number is required for Addresses. | true |
alternative_shipping_phone | Determines if an alternative phone number should be present for the shipping address on the checkout page. | false |
allow_guest_checkout | Determines if guests can proceed to checkout without creating an account. | true |
always_include_confirm_step | Determines if the confirmation step is always included in the checkout process, regardless of the payment method. | false |
auto_capture | 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). | false |
auto_capture_on_dispatch | Captures payment for each shipment in Shipment#after_ship callback, and makes Shipment.ready when payment authorized. | false |
company | Determines whether or not a field for “Company” displays on the address form. | false |
credit_to_new_allocation | Determines if a new allocation is created anytime store credit is added. If not set, it will update the store credit’s amount in place. | false |
disable_sku_validation | Determines if the built-in SKU uniqueness validation is disabled. | false |
disable_store_presence_validation | Determines if Store presence validation for Products and Payment Methods is disabled. | false |
expedited_exchanges | Determines if an exchange shipment is kicked off upon return authorization save. Requires payment profiles to be supported on your gateway and a configured delayed job handler. | false |
expedited_exchanges_days_window | The number of days the customer has to return their item after the expedited exchange is shipped to avoid being charged. | 14 |
restock_inventory | Determines if inventory should be restocked when an order is canceled or returned | true |
return_eligibility_number_of_days | The number of days after purchase within which a return can be initiated. | 365 |
send_core_emails | Determines if core emails should be sent. This includes order confirmation and shipment tracking emails. | true |
show_products_without_price | Determines if products without a price are shown in the storefront and Storefront API | false |
tax_using_ship_address | Determines if tax information should be based on shipping address, rather than the billing address. | true |
track_inventory_levels | Determines if inventory levels should be tracked when products are purchased at checkout. This option causes new InventoryUnit objects to be created when a product is bought. | true |
To change these you need to edit your config/initializers/spree.rb
file.
For example, to disable the expedited_exchanges
feature, you would add the following line:
Spree.config do |config|
config.expedited_exchanges = false
end
Spree allows you to use your own authentication system.
To do this, you need to create a new authentication system and configure Spree to use it.
You can find more information in the Authentication section.
Spree allows you to change the images for products, variants and taxons.
Please see Images customization section for more information.
With Spree you can change the checkout flow to fit your business needs.
Please see Checkout flow customization section for more information.
Spree allows you to swap core classes and services with your own, eg. you want to handle adding to cart differently.
In your config/initializers/spree.rb
file, you can set the following:
Spree::Dependencies.cart_add_item_service = "MyCartAddItemService"
which would use MyCartAddItemService
to handle adding to cart.
You can find more information in the Dependencies section.
Decorators allow you to add behavior to Spree classes in your application. We’re using a neat feature of Ruby language called Module.prepend to add the behavior to the model.
For example, to add a method that returns the product name in uppercase, you would add the following to your decorator:
module Spree
module ProductDecorator
def custom_name
name.upcase
end
end
Product.prepend(ProductDecorator)
end
Decorators should be used as a last resort. They can make upgrading Spree more difficult.
Please see Decorators section for more information.
Was this page helpful?