Skip to content

RG Courses Hometask Spring 2017 - rails engine "simle shpping cart"

License

Notifications You must be signed in to change notification settings

GalenkoEugene/cartify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

c825dad · Oct 19, 2017

History

15 Commits
Oct 18, 2017
Oct 3, 2017
Oct 10, 2017
Oct 8, 2017
Oct 12, 2017
Oct 11, 2017
Oct 11, 2017
Oct 5, 2017
Oct 11, 2017
Oct 3, 2017
Oct 11, 2017
Oct 10, 2017
Oct 11, 2017
Oct 11, 2017
Oct 10, 2017

Repository files navigation

Cartify

Shopping cart with a multi-step checkout, easily mounted into Rails application.

Usage

Run initializer:

rails generate initializer

Clone migrations:

rake cartify:install:migrations

Define associations in your "User" model:

has_many :orders, class_name: 'Cartify::Order', foreign_key: :user_id
has_one :billing, class_name: 'Cartify::Billing', foreign_key: :user_id
has_one :shipping, class_name: 'Cartify::Shipping', foreign_key: :user_id
has_many :addresses, class_name: 'Cartify::Address', foreign_key: :user_id

Installation

Add this line to your application's Gemfile:

gem 'cartify'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cartify

Available helpers

Shop icon helper

shop_icon_quantity

Will produce:

<span class="shop-icon">
  <span class="shop-quantity">1</span>
</span>

Add to cart link helper

add_to_cart(product, quantity, button_name)
# product -     name of your selling product (required!)
# quantity -    how many goods you with put into cart (default: 1)
# button_name - button name (default: "Add to cart")

Or customize as you with:

'helper link':            cartify.order_items_path()
'required params':        order_item: {quantity: quantity, product_id: product.id}
'use method':             method: :post
'asynchronously':         remote: true

# Example:
  link_to cartify.order_items_path(order_item: {quantity: 7, product_id: product.id}), 
    { method: :post, remote: true }

License

The gem is available as open source under the terms of the MIT License.

About

RG Courses Hometask Spring 2017 - rails engine "simle shpping cart"

Resources

License

Stars

Watchers

Forks

Packages

No packages published