Spree Commerce

Try It Now

Improved Layout Customization

Posted on July 27, 2009 by Sean Schofield

The edge version of Spree has new features aimed at reducing the need to override the default Spree layout template. The title, stylesheets, and logo now can all be customized without creating your own copy of the layout. These handy new features were contributed by Eliot Sykes along with the following writeup.

New Title Methods

There are some new methods for manipulating the page title: the title and set_title helper methods in Spree::BaseController.

Use set_title to set a page title either from a controller method, or a view template. You can also override the default_title and title methods in Spree::BaseController for further control.

The title method is used in application.html.erb of the new release, however if you are upgrading and want to take advantage, use this in between your <title> tags of your layout template:


<p>&lt;%= title %&gt;</p>

And to set the title in a view template:


<p>&lt;% set_title &#8216;My custom title&#8217; %&gt;</p>

Customize Default Stylesheets

Spree::Config[:stylesheets] is a new config option for customizing the stylesheets used by the default application layout.

The value of Spree::Config[:stylesheets] is a comma-separated string
of stylesheet names without the file extensions. See the customization
tutorial
for more information.

If you are upgrading, to take advantage of this use the new stylesheet_tags helper method.

Customized Logo

Spree::Config[:logo] is a new config option for customizing the logo image path. If you are upgrading, take advantage of this by using the new logo helper method.

Webbynode Announces One-Click Spree Install

Posted on July 20, 2009 by Sean Schofield

picture-19
Last week Webbynode announced that they have added Spree as a "one click install" option to their "ReadyStack." The ReadyStack is probably one of the more interesting features provided by this up and coming Rails hosting service. The Webbynode home page contains a great video explaining more about how the service works.

The Spree wiki has also been updated with a brief guide on Spree Installation With Webbynode. The installation process is actually relatively simple, the wiki is really more to give you an idea of what the process looks like.

Unfortuantely due to the overwhelming demand for Webbynode, they are temporarily sold out of new server instances. It looks like you will need to wait about a week before being able to try this service out. In the meantime, you can checkout a live instance of Spree running on the very modestly priced "256" plan. I don’t have a lot of experience running Spree is such a low memory environment but it does seem to run well under modest load conditions.

"New on Edge: Charges and Credits"

Posted on July 20, 2009 by Sean Schofield

Spree now provides a new flexible system of charges and credits associated with orders. The orders table no longer has seperate columns for tax_total, ship_total, etc. This information is now captured more generically as a Charge. This allows a Spree application to add more then one tax or shipping charge per order as well as to support new types of charges that might be required. For instance, some products for sale (like cell phones) require a seperate activation fee.

Charges are added to the order in the Checkout model. Developers wishing to override the default behavior of Spree can now just override the update_charges method to provide their own additional logic. This snippet below shows how the Spree core adds tax related charges to an order.


def update_charges
&#8230;
<ol>
	<li>update tax (if applicable)<br />
    tax_amount = order.calculate_tax<br />
    if tax_amount &gt; 0<br />
      tax_charge = order.tax_charges.first<br />
      tax_charge ||= order.tax_charges.build(:description =&gt; I18n.t(:tax))<br />
      tax_charge.amount = tax_amount<br />
      tax_charge.save<br />
    end</li>
</ol>
order.reload
order.update_totals
order.save
end

In addition to charges, credits are now supported. Credits are the mirror image of charges and they serve to reduce the cost of the order. The primary mechanism for adding a credit to an order is through the use of coupons. Its possible, however, that developers may wish to build their own custom logic for creating credits.

WARNING: There are significant changes to the database to support the new charge system. The migrations should update your legacy data and create the necessary tax and shipping charges for existing orders but you should backup your database before running.

Spree 0.8.5 Released

Posted on July 08, 2009 by Sean Schofield

We’ve just done another patch release to Spree. This release actually contains no changes other then those that were supposed to have made it into the 0.8.4 release. Due to some “enthusiastic” git branch deletion I accidentally removed some of the changes needed for the release. So the 0.8.4 release did not really do anything other then increment the version number. This release contains the minor rake task upgrades that were supposed to be part of that release.