Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
45 lines (33 sloc) 1.54 KB


ActiveCart is a Shopping Cart framework, it's not a fullyfledged cart, so you will need to do some stuff to get it to work.

The cart system has a storage engine, which means you aren't bound to a particular database. So far, there is a an ActiveModel storage engine, called acts_as_cart, but the gem isn't just for Rails, by writing other engines, you could target any datastore.


gem install active_cart


require 'rubygems'
require 'active_cart'

@cart = ActiveCart::Cart.setup( do |t|
  t <<
  t <<

In this example the ShippingOrderTotal and GstOrderTotal have been created by the developer and follow the OrderTotal interface.

For information about the API and interfase, checkout the documentation:

Sample using the contrived Memory demo classes in irb

>> require 'rubygems'
=> true
>> require 'active_cart'
=> true
>> include ActiveCart
=> Object
>> c =
=> #<ActiveCart::Cart:0xb7a697a0 @order_total_calculators=[], @storage_engine=[]>
>> c.add_to_cart(, "Test Item", 10))
=> nil
>> c.add_to_cart(, "Test Item", 10))
=> nil
>> c[0]
=> #<ActiveCart::Items::MemoryItem:0xb7a63170 @price=10, @name="Test Item", @quantity=2, @id=1>
=> 20

Copyright © 2010 Myles Eftos, released under the MIT license

Jump to Line
Something went wrong with that request. Please try again.