Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A shopping cart framework

branch: master
README.rdoc

ActiveCart

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.

Installation

gem install active_cart

Usage

require 'rubygems'
require 'active_cart'

@cart = ActiveCart::Cart.setup(MyStorageEngine.new) do |t|
  t << ShippingOrderTotal.new
  t << GstOrderTotal.new
end

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: rdoc.info/projects/madpilot/active_cart

Sample using the contrived Memory demo classes in irb

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

Copyright © 2010 Myles Eftos www.madpilot.com.au/contact, released under the MIT license

Something went wrong with that request. Please try again.