Spree 2.0.0
Major/new features
General
Removing support for Ruby 1.8.7
Support for Ruby 1.8.7 is going away in this major release. If you are still using 1.8.7, it is time to upgrade. Ruby 1.8.7 is End of Life’d at the end of June
Upgrading to Ruby 1.9.3 or higher is highly encouraged. Spree 2.0 and above supports Ruby 2.
Splitting up core
A lot of people have requested the ability to use either the backend or the frontend separately from the other. We did a lot of work toward this goal as part of <%= issue 2225 %> and now Spree is split up into the following components:
- API
- Backend
- Core
- Dash
- Frontend
- Sample
The Backend component provides the admin interface for Spree and the Frontend component provides the frontend user-facaing checkout interface. These components were extracted out of Core to allow for users of Spree to override the frontend or backend functionality of Spree as they choose. Core now contains just the very basic needs for Spree.
Along with this work, the Promo engine has now been merged with Spree core. We saw that there was a lot of hackery going on to get promos to work with Core, and a lot of stores want promos anyway, and so merging them made sense.
Additionally, as part of this work, the spreecore assets have been renamed.
In store/all.css
and store/all.js
, you will need to rename the references
from `spreecoreto
spreefrontend. Similarly to this, in
admin/all.cssand
admin/all.js, you will need to rename the references from
spreecoreto
spree_backend`.
Split shipments
Complex Spree stores require sophisticated shipping and warehouse logic that Spree hasn’t had a general solution for until now. Split shipments in Spree allows for multiple shipments per order and for those shipments to be shipped from multiple locations.
There are 4 main components that make up split shipments: Stock Locations, Stock Items, Stock Movements and Stock Transfers.
Stock locations
Stock locations are the locations where your inventory is shipped from. Each stock location can have many stock items. When creating a new stock location, stock items for that location are automatically created for each variant in your store.
Having multiple stock locations allows for more robust shipping options. For example, if an item in an order is out of stock at the location of the other items in a order, a new shipment may be created if that item is found to be in stock at another location.
You are also able to create and manage orders that have items from multiple locations by using the improved admin interface.
Stock items
Stock Items represent the inventory at a stock location for a specific variant. Stock item count on hand can be increased or decreased by creating stock movements. Because these are created automatically for each location you create, there is no need to manually manage these.
Stock movements
Stock movements allow you to manage the inventory of a stock item for a stock location. Stock movements are created in the admin interface by first navigating to the product you want to manage. Then, follow the Stock Management link in the sidebar.
For more information on split shipments and how they pertain to inventory management, read the Inventory Guide.
For more information on the classes introduced by split shipments and how to work with them programmatically, see the Shipments Guide.
Stock transfers
Stock transfers allow you to move inventory in bulk from one stock location to another stock location.
Stock transfers generally consist of a source location, a destination location, one or more variants and an optional reference number. Stock transfers can also be used as a way to track new stock, in which case only a stock location destination and variant are required.
I18n
Spree 2.0 now comes with namespaced translations so that translations in your application will no longer conflict with those within Spree. It’s recommended that if you have extension that uses Spree to move its translations into the Spree namespace to avoid the same problem.
Translations within Spree views should now use the Spree.t
helper, rather than the t
helper so that they are namespaced correctly.
API
New API endpoints
API clients can now manage the following resources through the API:
- Option Types
- Option Values
- Inventory Units
- Shipments
- Stock Items
- Stock Locations
- Stock Movements
The documentation for these endpoints hasn’t been written yet, but will be shortly.
Instance level permissions
The API now can enforce instance-level permissions on objects. This means that some users would be able to access a single item within a resource, rather than an “all or none” approach to the API.
<%= commit “548dc0c58e4400501bc67cddea942fda1c7dbad3” %>
Custom API templates
If you wish to use a custom template for an API response you can do this by
passing in a template
parameter to API requests.
Read the documentation for more information.
Core
Adjustment state changes
Adjustments can now be open, closed or finalized, allowing for a more flexible adjustments system. An ‘open’ adjustment can be modified, whereas a ‘closed’ adjustment cannot. Finalized adjustments are never altered.
<%= commit “43a3cca49180b1572e41bc3638d3ca0f0e9116d9” %>
OrderPopulator
Order population responsibility has been moved out to its own class. This has been done so that the API, Core and any other extensions that wish to use the order population logic have an easy way to do so.
See <%= issue 2341 %> and <%= commit “432d129c86e03597347cd223507d9386e9613d62” %> for more information.
CouponApplicator
Coupon application responsibility has been moved out to its own class too. This has been done so that the API, Core and any other extensions that wish to apply coupons have an easy way to do so.
<%= commit “8ac9ac1c56fe1e471dd5b0124edbe383a8c70c48” %>
ProductDuplicator
Product duplication code has been moved out to its own class as well.
<%= issue 2641 %>
New helpers to modify checkout flow steps
To add or remove steps to the checkout flow, you can now use the insert_checkout_step
and remove_checkout_step
helpers respectively. This patch has been backported
to 1-3-stable as well, and will be available in Spree releases >= 1.3.3.
The insert_checkout_step
takes a before
or after
option to determine where to
insert the step:
insert_checkout_step :new_step, before: :address
# or
insert_checkout_step :new_step, after: :address```
The `remove_checkout_step` will remove just one checkout step at a time:
```ruby
remove_checkout_step :address
remove_checkout_step :delivery```
### Dash
## Minor changes
### API
#### CheckoutsController
The Spree API now has support for "checking out" an order. This API
functionality allows an existing order to be updated and advanced until
it is in the complete state.
For instance, if you have an order in the "confirm" state that you would
like to advance to the "complete" state, make the following request:
```bash
PUT /api/checkouts/ORDER_NUMBER```
For more information on using the new CheckoutsController, please see
the [Checkouts API Documentation](/api/checkouts).
#### Versioned templates
API responses can now be versioned by the [versioncake](https://github.com/bwillis/versioncake) gem. While this is not used in Spree at the moment, it is future-proofing the API.
### Core
#### Auto-rotation of images
Images will now be auto-rotated to their correct orientation based on EXIF data from the original image. All EXIF data is then stripped from the image, resulting in a smaller final image size.
<%= issue 2338 %>
#### Sample data
The sample data now exists within straight Ruby code. The previous YAML-backed
configuration was confusing and led to invalid data being inserted for sample data.
<%= commit "cc2f55a27a154c0bf9d67e1dbef3c4761c68f8b8" %>
#### Unique payment identifier
Some payment gateways require payments to have a unique identifier. To solve this problem in Spree, each payment now has an `identifier` attribute which is generated when the payment is created.
<%= issue 1998 %>
<%= commit "b543fd105c2d511cdc98f27223cd0f5b1f663e72" %>
#### Removal of `CheckoutController#state_callback`
The `state_callback` method in `CheckoutController` has been removed. Instead of this method, please use transition callbacks on the `Order.state_machine` instance instead.
#### Tracking URL for shipments
Shipping methods now have the ability to have tracking URLs. These can be used to track the shipments on external shipping providers' websites.
<%= issue 2644 %>
#### Mailers now can take IDs or model objects
To help with potential background processing of mailers, all mailer actions can now take the ID of their respective object, or the object itself.
<%= issue 2808 %>
#### SSLRequirement deprecated in favour of ForceSSL
Spree will now use the `config.force_ssl` setting of Rails to determine whether or not to use SSL.
<%= issue 2410 %>
#### MailMethod model no longer exists
The `MailMethod` model no longer exists. Instead, it is a class and all configuration is now done through that class or through `Spree::Config` settings.
<%= issue 2643 %>
## Trivial changes
Some of these changes may have made it into 1-3-stable or 1-2-stable as well. You may wish to check that branch for commits with the same message to make sure of this.
* `ShippingMethod` labels can now be overriden by overriding the `adjustment_label` method. <%= issue(2222) %>
* Promotion rules that respond to `#products` will have their products considered in promotion adjustments. <%= issue 2363 %>
* Taxons and products are now joined with a `Classification` model. <%= issue 2532 %> <%= commit "0c594923a457d2f6050c936498d31df312d6153a" %>
* Fix call to `select_month` and `select_year` <%= issue 2259 %>
* Fix issue where `params[:keyword]`, not `params[:keywords]` was acknowledged on taxons/show.html.erb. <%= issue 2258 %> <%= issue 2270 %>
* Allow overriding of a shipping address's label <%= issue 2222 %>
* Guard against false positive Jirafe conversions <%= issue 2273 %> <%= issue 2211 %> <%= issue 2157 %>
* Add first_name and last_name aliases for Addresses <%= commit "ad119f9e21af9ba6f6ada96944fc758a6144c61c" %>
* Escape JavaScript within ecommerce tracking code <%= issue 2289 %>
* Slight refactoring of how preferences are fetched from preference store <%= commit "bddc49a5cf261ca9fcee45e4234bdb076eaa3feb" %>
* Fix issue where "New State" button on country page would not link to correct country. <%= issue 2281 %>
* Order#checkout_steps will now always include complete <%= commit "5110e12127840fb9b2e22f8b4f4c4fbee594de23" %>
* Fix issue where `flash[:commerce_tracking]` was hanging around too long. <%= issue 2287 %>
* Remove colons from translations in mail templates <%= issue 2278 %>
* A payment method can now control its `auto_capture?` method. <%= issue 2304 %>
* Added a preference to display a product without a price. <%= issue 2302 %>
* Improve 'out of stock' error message. <%= issue 1821 %>
* Track IP addresses for orders, for payment gateway reasons. <%= issue 2216 %> <%= issue 2257 %>
* Use protocol-specific URL for font. <%= issue 2316 %>
* First order promotion will now work with guest users. <%= issue 2306 %>
* Always show resend button on admin order page. <%= issue 2318 %>
* Allow a shipment to be made 'ready' once order has been made 'resumed' <%= issue 2317 %>
* PerItem calculator no longer fails if a rule doesn't respond to the `products` method. <%= issue 2322 %>
* `attachment_url` can now be configured from the admin backend. <%= issue 2344 %>
* Scale and precision have been corrected in split_prices_from_variants migration. <%= issue 2358 %>
* Localize error message for email validator. <%= issue 2364 %> <%= issue 2729 %> <%= issue 2730 %>
* Remove duplicate thumbnails on products/show. <%= issue 2361 %>
* Use line item price, not variant price, in return authorization price calculation JS. <%= issue 2342 %>
* Allow for a product's description to be put to the page raw <%= issue 2323 %> <%= issue 2874 %> <%= commit "30fdf083" %>. See also <%= commit "b616d84a78e426bdeb3e8e6251aaa9ce8757996d" %> and <%= issue 2518 %>.
* Promotions can now apply to orders which were created before the promotion. <%= issue 2388 %> <%= issue 2395 %>
* Allow Address#phone validation to be overridden. <%= issue 2394 %>
* Sort properties by alphabetical order on prototype form. <%= issue 2389 %>
* Introduce datepicker_field_value for displaying datepicker field values. <%= issue 2405 %>
* The 'New Product' button now appears on the edit product page. <%= issue 2407 %>
* option values in `Variant#options_text` are now sorted in a predictable order. <%= issue 2432 %>
* link_to_cart can now be used outside of Spree contexts. <%= issue 2441 %>
* Promotion adjustments will now be removed on orders which are not complete when the promotion is deleted. <%= issue 1046 %> <%= issue 2453 %>
* Adjustments are now displayed on the orders/show template. <%= issue 2449 %>
* Variant images are displayed in place of product images in admin/images <%= issue 2228 %>
* Product properties are now sortable. <%= issue 2464 %>
* Returned items can now be re-shipped. <%= issue 2475 %>
* LogEntry records are now saved for failed payments <%= issue 1767 %>
* Show full address in order confirmation <%= issue 2136 %> <%= issue 2511 %>
* Retrieve a list of variants from an order by calling `Order#variants`. <%= issue 2195 %>
* Fix group_by_products_id sometimes not being available as a scope. <%= issue 1247 %>
* Allow `meta_description` on `Spree::Product` to be as long as `text` will allow, rather than `string`. <%= issue 2611 %>
* Fix currency display issues when using Euro. <%= issue 2634 %>
* Fix issue where orders would become "locked" when initial payment had failed. <%= issue 2616 %> <%= issue 2570 %> <%= issue 2678 %> <%= issue 2585 %> <%= issue 2652 %>
* Check for unprocessed payments before transitioning to complete state <%= issue 2694 %>
* Added check to prevent skipping of checkout steps. <%= issue 2280 %>
* Improve the look of the coupon code on the checkout. <%= issue 2720 %>
* Admin tabs are now only displayed if user is authorized to see them. <%= issue 2626 %>
* Reduce minimum characters required for variant autocomplete <%= issue 2774 %>
* Added helper methods to shipment to calculate shipment item and total costs <%= issue 2843 %>
* Allow product scopes to be added to from an extension <%= issue 2608 %>
* Fix routing error caused by routing-filter and previous ghetto implementation of taxon autocomplete. <%= issue 2248 %>
* ActionMailer settings will no longer be re-configured if they're already set. <%= issue 2855 %>
* Fix issue where tax calculator computed taxes incorrectly for non-VAT taxes. <%= issue 2870 %>
* The coupon code field is now hidden when there are no possible coupon codes. <%= issue 2835 %>
* The `position` attribute for variants is now computed once the variant is saved. <%= issue 2744 %>
* Account for situation where `current_order` might return `nil` in an `OrdersController#update` call. <%= issue 2750 %>
* Fix case where ActiveMerchant would incorrectly process currencies without 2 decimal places. <%= issue 2930 %>
* Add US military states to default states. <%= issue 2769 %>
* Allow for specially overridden attributes for line items in the API. <%= issue 2916 %>
* Transition order as far to complete as it will go after editing customer details. <%= issue 2950 %> <%= issue 2433 %>
* Fix issue where going back a step in a cart could cause a `undefined method run_callbacks` error to be raised. <%= issue 2959 %> <%= issue 2921 %>
* Use DISTINCT ON to make product `in_taxon` scope really distinct in PostgreSQL <%= issue 2851 %>
* Run order update hooks when order is finalized too <%= issue 2986 %>