/op_cart

Opinionated cart engine for Ruby on Rails

Primary LanguageRubyMIT LicenseMIT

Op(inionated) Cart

Opinionated cart engine for Ruby on Rails

OpCart makes things simple through inflexibility and lack of features.

OpCart assumes you are using:

  • Stripe for payments
  • Rails ~> 4.2.0
  • Postgres ~> 9.3
  • Devise ~> 3.3 for authentication
  • ActiveJob with a job queue configured
  • SSL already

OpCart assumes you don’t:

  • have hundreds of products and want search indexing
  • need promotion/coupon support
  • need to track inventory
  • charge for shipping
  • have complex products to sell (e.g. variants like different sizes and colors)
  • like Spree or other open-source carts

Installation

Add op_cart to your Gemfile:

gem 'op_cart', '~> 1.0.0'

Copy the migrations and run them:

rake op_cart:install:migrations db:migrate

Add a checkout route to your config/routes.rb:

Rails.application.routes.draw do
  mount OpCart::Engine => "/store"
  #...
end

When updating OpCart, you will need to run rake op_cart:install:migrations again.

Data Models and Classes

  • Product
    • name
    • description
    • image_url
    • price (in cents)
    • allow_purchases (to hide product and disable sales)
    • charge_taxes
    • user_id (creator)
  • Order
    • status
    • total
    • tax_charge
    • shipping_address_id
    • user_id
  • Line Item
    • unit_price
    • quantity
    • price
    • sellable_snapshot (object freeze)
    • sellable_type
    • sellable_id
    • order_id
  • Payment
  • PaymentGateway
  • Cart (cookie?)
  • Address
  • Shipment
  • Tax Calculator