Coder Social home page Coder Social logo

active_cart's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.