spree_advanced_cart 0.40.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +12 -0
- data/LICENSE +23 -0
- data/README.md +18 -0
- data/Rakefile +80 -0
- data/Versionfile +2 -0
- data/app/controllers/orders_controller_decorator.rb +29 -0
- data/app/views/orders/_advanced_cart.html.erb +45 -0
- data/app/views/orders/_estimate_shipping_cost_table.html.erb +12 -0
- data/app/views/orders/edit.html.erb +41 -0
- data/app/views/orders/estimate_shipping_cost.js.erb +5 -0
- data/app/views/orders/update.js.erb +2 -0
- data/config/locales/en.yml +7 -0
- data/config/routes.rb +3 -0
- data/features/advanced_cart.feature +21 -0
- data/features/step_definitions/advanced_cart_steps.rb +17 -0
- data/features/support/env.rb +22 -0
- data/features/support/paths.rb +40 -0
- data/lib/advanced_cart_configuration.rb +5 -0
- data/lib/spree/advanced_cart/config.rb +23 -0
- data/lib/spree_advanced_cart.rb +17 -0
- data/lib/spree_advanced_cart_hooks.rb +6 -0
- data/lib/tasks/install.rake +25 -0
- data/lib/tasks/spree_advanced_cart.rake +1 -0
- data/public/javascripts/advanced_cart.js +21 -0
- data/public/stylesheets/advanced_cart.css +28 -0
- data/spec/spec_helper.rb +31 -0
- data/spree_advanced_cart.gemspec +24 -0
- metadata +117 -0
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Redistribution and use in source and binary forms, with or without modification,
|
2
|
+
are permitted provided that the following conditions are met:
|
3
|
+
|
4
|
+
* Redistributions of source code must retain the above copyright notice,
|
5
|
+
this list of conditions and the following disclaimer.
|
6
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
7
|
+
this list of conditions and the following disclaimer in the documentation
|
8
|
+
and/or other materials provided with the distribution.
|
9
|
+
* Neither the name of the Rails Dog LLC nor the names of its
|
10
|
+
contributors may be used to endorse or promote products derived from this
|
11
|
+
software without specific prior written permission.
|
12
|
+
|
13
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
14
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
15
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
16
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
17
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
18
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
19
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
20
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
21
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
22
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
23
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Spree Advanced Cart
|
2
|
+
=================
|
3
|
+
|
4
|
+
This extension provide replacement to Spree cart with several additional improvements like:
|
5
|
+
|
6
|
+
* coupon applying
|
7
|
+
* shipping cost precalculation
|
8
|
+
|
9
|
+
|
10
|
+
Installation
|
11
|
+
============
|
12
|
+
|
13
|
+
Add `gem "spree_advanced_cart", :git => "git://github.com/romul/spree_advanced_cart.git"
|
14
|
+
Run `bundle install`
|
15
|
+
Run `rake spree_advanced_cart:install:assets`
|
16
|
+
|
17
|
+
|
18
|
+
Copyright (c) 2011 Roman Smirnov
|
data/Rakefile
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rake/packagetask'
|
5
|
+
require 'rake/gempackagetask'
|
6
|
+
|
7
|
+
gemfile = File.expand_path('../spec/test_app/Gemfile', __FILE__)
|
8
|
+
if File.exists?(gemfile) && (%w(spec cucumber).include?(ARGV.first.to_s) || ARGV.size == 0)
|
9
|
+
require 'bundler'
|
10
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
11
|
+
Bundler.setup
|
12
|
+
|
13
|
+
require 'rspec'
|
14
|
+
require 'rspec/core/rake_task'
|
15
|
+
RSpec::Core::RakeTask.new
|
16
|
+
|
17
|
+
require 'cucumber/rake/task'
|
18
|
+
Cucumber::Rake::Task.new do |t|
|
19
|
+
t.cucumber_opts = %w{--format progress}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "Default Task"
|
24
|
+
task :default => [:spec, :cucumber ]
|
25
|
+
|
26
|
+
spec = eval(File.read('spree_advanced_cart.gemspec'))
|
27
|
+
|
28
|
+
Rake::GemPackageTask.new(spec) do |p|
|
29
|
+
p.gem_spec = spec
|
30
|
+
end
|
31
|
+
|
32
|
+
desc "Release to gemcutter"
|
33
|
+
task :release => :package do
|
34
|
+
require 'rake/gemcutter'
|
35
|
+
Rake::Gemcutter::Tasks.new(spec).define
|
36
|
+
Rake::Task['gem:push'].invoke
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "Default Task"
|
40
|
+
task :default => [ :spec ]
|
41
|
+
|
42
|
+
desc "Regenerates a rails 3 app for testing"
|
43
|
+
task :test_app do
|
44
|
+
require '../spree/lib/generators/spree/test_app_generator'
|
45
|
+
class AdvancedCartTestAppGenerator < Spree::Generators::TestAppGenerator
|
46
|
+
|
47
|
+
def install_gems
|
48
|
+
inside "test_app" do
|
49
|
+
run 'rake spree_core:install'
|
50
|
+
run 'rake spree_auth:install'
|
51
|
+
run 'rake spree_promo:install'
|
52
|
+
run 'rake spree_advanced_cart:install'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def migrate_db
|
57
|
+
run_migrations
|
58
|
+
end
|
59
|
+
|
60
|
+
protected
|
61
|
+
def full_path_for_local_gems
|
62
|
+
<<-gems
|
63
|
+
gem 'spree_core', :path => \'#{File.join(File.dirname(__FILE__), "../spree/", "core")}\'
|
64
|
+
gem 'spree_auth', :path => \'#{File.join(File.dirname(__FILE__), "../spree/", "auth")}\'
|
65
|
+
gem 'spree_promo', :path => \'#{File.join(File.dirname(__FILE__), "../spree/", "promo")}\'
|
66
|
+
gem 'spree_advanced_cart', :path => \'#{File.dirname(__FILE__)}\'
|
67
|
+
gems
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
AdvancedCartTestAppGenerator.start
|
72
|
+
end
|
73
|
+
|
74
|
+
namespace :test_app do
|
75
|
+
desc 'Rebuild test and cucumber databases'
|
76
|
+
task :rebuild_dbs do
|
77
|
+
system("cd spec/test_app && rake db:drop db:migrate RAILS_ENV=test && rake db:drop db:migrate RAILS_ENV=cucumber")
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
data/Versionfile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
OrdersController.class_eval do
|
2
|
+
|
3
|
+
def update
|
4
|
+
@order = current_order
|
5
|
+
if @order.update_attributes(params[:order])
|
6
|
+
@order.line_items = @order.line_items.select {|li| li.quantity > 0 }
|
7
|
+
if request.xhr?
|
8
|
+
@order.update!
|
9
|
+
else
|
10
|
+
redirect_to cart_path
|
11
|
+
end
|
12
|
+
else
|
13
|
+
render :edit
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def estimate_shipping_cost
|
18
|
+
if params[:zipcode] =~ /^\d{5}$/ || Spree::AdvancedCart::Config[:skip_zipcode_validation]
|
19
|
+
@order = current_order
|
20
|
+
@order.ship_address = Address.new(:zipcode => params[:zipcode], :country_id => Spree::Config[:default_country_id])
|
21
|
+
@shipping_methods = ShippingMethod.all_available(@order)
|
22
|
+
@esc_values = @shipping_methods.map {|sm| [sm.name, sm.calculator.compute(@order)]}
|
23
|
+
else
|
24
|
+
flash[:error] = I18n.t(:estimation_works_only_with_us_zipcodes)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<%= form_for(@order, :url => update_cart_path, :html=>{:id=>'updatecart'}, :remote => true) do |order_form| %>
|
2
|
+
<%= hook :inside_cart_form do %>
|
3
|
+
|
4
|
+
<%= hook :cart_items do %>
|
5
|
+
<%= render :partial => 'form', :locals => {:order_form => order_form} %>
|
6
|
+
<% end %>
|
7
|
+
|
8
|
+
<% if Spree::AdvancedCart::Config[:enable_coupon_applying] %>
|
9
|
+
<table id="order-charges">
|
10
|
+
<tbody>
|
11
|
+
<% @order.adjustments.each do |adjustment| %>
|
12
|
+
<tr>
|
13
|
+
<td><strong><%= adjustment.label %></strong></td>
|
14
|
+
<td class="total"><span><%= number_to_currency adjustment.amount %></span></td>
|
15
|
+
</tr>
|
16
|
+
<% end %>
|
17
|
+
</tbody>
|
18
|
+
</table>
|
19
|
+
|
20
|
+
<div id="applying_coupon">
|
21
|
+
<h3><%= t(:apply_coupon) %></h3>
|
22
|
+
<label><%= t(:coupon_code) %></label>
|
23
|
+
<%= order_form.text_field :coupon_code, :size => 19 %>
|
24
|
+
<span class="ajax_loader"><%= image_tag 'ajax_loader.gif', :alt => t('loading') %></span>
|
25
|
+
<%= order_form.submit t("apply") %>
|
26
|
+
</div>
|
27
|
+
<% end %>
|
28
|
+
|
29
|
+
<div id="subtotal">
|
30
|
+
<%= hook :advanced_cart_subtotal do %>
|
31
|
+
<h3><%= "#{t("subtotal")}: #{order_price(@order)}" %></h3>
|
32
|
+
<% if Spree::AdvancedCart::Config[:enable_coupon_applying] %>
|
33
|
+
<h3><%= "#{t("total")}: #{number_to_currency @order.total}" %></h3>
|
34
|
+
<% end %>
|
35
|
+
<% end %>
|
36
|
+
<%= hook :advanced_cart_subtotal_links do %>
|
37
|
+
<div class="links">
|
38
|
+
<%= link_to image_tag('/images/update.png') + t("update"), '#', :class => 'button checkout primary', :onclick => "$('form#updatecart').submit(); return false;" %>
|
39
|
+
<%= link_to image_tag('/images/checkout.png') + t("checkout"), checkout_path, :class => 'button checkout primary' %>
|
40
|
+
</div>
|
41
|
+
<% end %>
|
42
|
+
</div>
|
43
|
+
|
44
|
+
<% end %>
|
45
|
+
<% end %>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<table id="shipping_costs">
|
2
|
+
<tr>
|
3
|
+
<th><%= t(:shipping_method) %></th>
|
4
|
+
<th class="price"><%= t(:price) %></th>
|
5
|
+
</tr>
|
6
|
+
<% @esc_values.each do |name, price| %>
|
7
|
+
<tr>
|
8
|
+
<td><%= name %></td>
|
9
|
+
<td><%= number_to_currency price %></td>
|
10
|
+
</tr>
|
11
|
+
<% end %>
|
12
|
+
</table>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<% @body_id = 'cart' %>
|
2
|
+
|
3
|
+
<h1><%= t("shopping_cart")%></h1>
|
4
|
+
|
5
|
+
<% if @order.line_items.empty? %>
|
6
|
+
|
7
|
+
<%= hook :empty_cart do %>
|
8
|
+
<p><%= t("your_cart_is_empty.") %></p>
|
9
|
+
<p><%= link_to t("continue_shopping"), products_path, :class => 'button continue' %></p>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
<% else %>
|
13
|
+
<div id="advanced_cart">
|
14
|
+
<%= render :partial => 'orders/advanced_cart' %>
|
15
|
+
</div>
|
16
|
+
<div style="clear:both;">
|
17
|
+
<% if Spree::AdvancedCart::Config[:enable_shipping_cost_calculation] %>
|
18
|
+
<%= hook :estimate_shipping_costs do %>
|
19
|
+
<div id="estimate_shipping_costs">
|
20
|
+
<h3><%= t(:calc_estimated_shipping_cost) %></h3>
|
21
|
+
<%= form_tag estimate_shipping_cost_path, :remote => true, :method => :get do %>
|
22
|
+
<%= label_tag t(:enter_zipcode) %>: <%= text_field_tag :zipcode %>
|
23
|
+
<span class="ajax_loader"><%= image_tag 'ajax_loader.gif', :alt => t('loading') %></span>
|
24
|
+
<%= submit_tag t("actions.calc") %>
|
25
|
+
<% end %>
|
26
|
+
<div id="estimate_shipping_cost_table"></div>
|
27
|
+
</div>
|
28
|
+
<% end %>
|
29
|
+
<% end %>
|
30
|
+
|
31
|
+
<%= hook :continue_shopping_or_empty_cart do %>
|
32
|
+
<%= form_tag empty_cart_path, :method => :put do %>
|
33
|
+
<p id="clear_cart_link">
|
34
|
+
<%= link_to t("continue_shopping"), products_path, :class => 'button continue' %>
|
35
|
+
<%= t(:or) %>
|
36
|
+
<input type="submit" value="<%= t('empty_cart') %>" class="button" />
|
37
|
+
</p>
|
38
|
+
<% end %>
|
39
|
+
<% end %>
|
40
|
+
</div>
|
41
|
+
<% end %>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Feature: AdvancedCart
|
2
|
+
|
3
|
+
@selenium
|
4
|
+
Scenario: Add coupon in the cart
|
5
|
+
Given a promotion with code "SPREE" and "FlatRate" amount "5"
|
6
|
+
When I add a product with name: "RoR Mug", price: "40" to cart
|
7
|
+
And I fill in "order_coupon_code" with "SPREE"
|
8
|
+
And I press "Apply"
|
9
|
+
Then I should see "Coupon (SPREE)"
|
10
|
+
And I should see "-$5"
|
11
|
+
And I should see "Total: $35"
|
12
|
+
|
13
|
+
@selenium
|
14
|
+
Scenario: Precalculate shipping cost in the cart
|
15
|
+
Given a shipping_method with name "UPS Ground" and "FlatRate" amount "5"
|
16
|
+
When I add a product with name: "RoR Mug", price: "40" to cart
|
17
|
+
And I fill in "zipcode" with "90210"
|
18
|
+
And I press "Calc"
|
19
|
+
Then I should see "UPS Ground"
|
20
|
+
And I should see "$5"
|
21
|
+
And I should see "Total: $40"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Given /^a promotion with code "([^"]*)" and "([^"]*)" amount "([^"]*)"$/ do |code, calc_name, amount|
|
2
|
+
promotion = Promotion.new(:name => code, :code => code)
|
3
|
+
promotion.calculator = "Calculator::#{calc_name}".constantize.new
|
4
|
+
promotion.save
|
5
|
+
promotion.calculator.preferred_amount = amount.to_f
|
6
|
+
promotion.save
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
Given /^a shipping_method with name "([^"]*)" and "([^"]*)" amount "([^"]*)"$/ do |name, calc_name, amount|
|
11
|
+
zone = Zone.find_by_name('North America')
|
12
|
+
shipping_method = ShippingMethod.new(:name => name, :zone => zone)
|
13
|
+
shipping_method.calculator = "Calculator::#{calc_name}".constantize.new
|
14
|
+
shipping_method.save
|
15
|
+
shipping_method.calculator.preferred_amount = amount.to_f
|
16
|
+
shipping_method.save
|
17
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
FEATURES_PATH = File.expand_path('../..', __FILE__)
|
2
|
+
|
3
|
+
# load shared env with features
|
4
|
+
require File.expand_path('../../../../spree/features/support/env', __FILE__)
|
5
|
+
|
6
|
+
# load the rest of files for support and step definitions
|
7
|
+
directories = [ File.expand_path('../../../../spree/features/support', __FILE__),
|
8
|
+
File.expand_path('../../../../spree/features/step_definitions', __FILE__),
|
9
|
+
File.expand_path('../../../spec/factories', __FILE__) ]
|
10
|
+
|
11
|
+
files = directories.map do |dir|
|
12
|
+
Dir["#{dir}/**/*.rb"]
|
13
|
+
end.flatten.uniq
|
14
|
+
|
15
|
+
files.each do |path|
|
16
|
+
if path !~ /env.rb$/
|
17
|
+
fp = File.expand_path(path)
|
18
|
+
#puts fp
|
19
|
+
load(fp)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module NavigationHelpers
|
2
|
+
# Maps a name to a path. Used by the
|
3
|
+
#
|
4
|
+
# When /^I go to (.+)$/ do |page_name|
|
5
|
+
#
|
6
|
+
# step definition in web_steps.rb
|
7
|
+
#
|
8
|
+
def path_to(page_name)
|
9
|
+
case page_name
|
10
|
+
|
11
|
+
when "admin promotions page"
|
12
|
+
admin_promotions_path
|
13
|
+
when /the home\s?page/
|
14
|
+
'/'
|
15
|
+
when /the sign in page/
|
16
|
+
new_user_session_path
|
17
|
+
when /the sign up page/
|
18
|
+
new_user_registration_path
|
19
|
+
|
20
|
+
# Add more mappings here.
|
21
|
+
# Here is an example that pulls values out of the Regexp:
|
22
|
+
#
|
23
|
+
# when /^(.*)'s profile page$/i
|
24
|
+
# user_profile_path(User.find_by_login($1))
|
25
|
+
|
26
|
+
else
|
27
|
+
begin
|
28
|
+
page_name =~ /the (.*) page/
|
29
|
+
path_components = $1.split(/\s+/)
|
30
|
+
self.send(path_components.push('path').join('_').to_sym)
|
31
|
+
rescue Object => e
|
32
|
+
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
|
33
|
+
"Now, go and add a mapping in #{__FILE__}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
World(NavigationHelpers)
|
40
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Spree
|
2
|
+
module AdvancedCart
|
3
|
+
# Singleton class to access the advanced cart configuration object (AdvancedCartConfiguration.first by default) and it's preferences.
|
4
|
+
#
|
5
|
+
# Usage:
|
6
|
+
# Spree::AdvancedCart::Config[:foo] # Returns the foo preference
|
7
|
+
# Spree::AdvancedCart::Config[] # Returns a Hash with all the google base preferences
|
8
|
+
# Spree::AdvancedCart::Config.instance # Returns the configuration object (AdvancedCartConfiguration.first)
|
9
|
+
# Spree::AdvancedCart::Config.set(preferences_hash) # Set the advanced cart preferences as especified in +preference_hash+
|
10
|
+
class Config
|
11
|
+
include Singleton
|
12
|
+
include PreferenceAccess
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def instance
|
16
|
+
return nil unless ActiveRecord::Base.connection.tables.include?('configurations')
|
17
|
+
AdvancedCartConfiguration.find_or_create_by_name("Advanced Cart configuration")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spree_core'
|
2
|
+
require 'spree_advanced_cart_hooks'
|
3
|
+
|
4
|
+
module SpreeAdvancedCart
|
5
|
+
class Engine < Rails::Engine
|
6
|
+
|
7
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
8
|
+
|
9
|
+
def self.activate
|
10
|
+
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
|
11
|
+
Rails.env.production? ? require(c) : load(c)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
config.to_prepare &method(:activate).to_proc
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
namespace :spree_advanced_cart do
|
2
|
+
desc "Copies all migrations and assets (NOTE: This will be obsolete with Rails 3.1)"
|
3
|
+
task :install do
|
4
|
+
Rake::Task['spree_advanced_cart:install:migrations'].invoke
|
5
|
+
Rake::Task['spree_advanced_cart:install:assets'].invoke
|
6
|
+
end
|
7
|
+
|
8
|
+
namespace :install do
|
9
|
+
desc "Copies all migrations (NOTE: This will be obsolete with Rails 3.1)"
|
10
|
+
task :migrations do
|
11
|
+
source = File.join(File.dirname(__FILE__), '..', '..', 'db')
|
12
|
+
destination = File.join(Rails.root, 'db')
|
13
|
+
Spree::FileUtilz.mirror_files(source, destination)
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "Copies all assets (NOTE: This will be obsolete with Rails 3.1)"
|
17
|
+
task :assets do
|
18
|
+
source = File.join(File.dirname(__FILE__), '..', '..', 'public')
|
19
|
+
destination = File.join(Rails.root, 'public')
|
20
|
+
puts "INFO: Mirroring assets from #{source} to #{destination}"
|
21
|
+
Spree::FileUtilz.mirror_files(source, destination)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
# add custom rake tasks here
|
@@ -0,0 +1,21 @@
|
|
1
|
+
(function($){
|
2
|
+
$(document).ready(function(){
|
3
|
+
|
4
|
+
$('#estimate_shipping_costs form').bind('ajax:before', function() {
|
5
|
+
$(this).children("input[type=submit]").fadeOut();
|
6
|
+
$(this).children(".ajax_loader").show();
|
7
|
+
});
|
8
|
+
|
9
|
+
$('#estimate_shipping_costs form').bind('ajax:success', function() {
|
10
|
+
$(this).children(".ajax_loader").fadeOut();
|
11
|
+
$(this).children("input[type=submit]").show();
|
12
|
+
});
|
13
|
+
|
14
|
+
$('form#updatecart').live('ajax:before', function() {
|
15
|
+
$("#order_submit").fadeOut();
|
16
|
+
$("#applying_coupon").children(".ajax_loader").show();
|
17
|
+
});
|
18
|
+
|
19
|
+
});
|
20
|
+
})(jQuery);
|
21
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#updatecart #order-charges td {
|
2
|
+
text-align: right;
|
3
|
+
}
|
4
|
+
|
5
|
+
#updatecart #order-charges td.total {
|
6
|
+
text-align: left;
|
7
|
+
width: 115px;
|
8
|
+
}
|
9
|
+
|
10
|
+
table#shipping_costs {
|
11
|
+
width: 40%;
|
12
|
+
}
|
13
|
+
|
14
|
+
table#shipping_costs th.price {
|
15
|
+
width: 70px;
|
16
|
+
}
|
17
|
+
|
18
|
+
div#estimate_shipping_costs {
|
19
|
+
margin: 40px 0;
|
20
|
+
}
|
21
|
+
|
22
|
+
div#applying_coupon {
|
23
|
+
float: left;
|
24
|
+
clear: left;
|
25
|
+
}
|
26
|
+
|
27
|
+
.ajax_loader { display: none; }
|
28
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
|
2
|
+
# from the project root directory.
|
3
|
+
ENV["RAILS_ENV"] ||= 'test'
|
4
|
+
require File.expand_path("../test_app/config/environment", __FILE__)
|
5
|
+
require 'rspec/rails'
|
6
|
+
|
7
|
+
# Requires supporting files with custom matchers and macros, etc,
|
8
|
+
# in ./support/ and its subdirectories.
|
9
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
# == Mock Framework
|
13
|
+
#
|
14
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
15
|
+
#
|
16
|
+
# config.mock_with :mocha
|
17
|
+
# config.mock_with :flexmock
|
18
|
+
# config.mock_with :rr
|
19
|
+
config.mock_with :rspec
|
20
|
+
|
21
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
22
|
+
|
23
|
+
#config.include Devise::TestHelpers, :type => :controller
|
24
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
25
|
+
# examples within a transaction, comment the following line or assign false
|
26
|
+
# instead of true.
|
27
|
+
config.use_transactional_fixtures = true
|
28
|
+
end
|
29
|
+
|
30
|
+
@configuration ||= AppConfiguration.find_or_create_by_name("Default configuration")
|
31
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.platform = Gem::Platform::RUBY
|
3
|
+
s.name = 'spree_advanced_cart'
|
4
|
+
s.version = '0.40.0'
|
5
|
+
s.summary = 'Cart with several useful additions for Spree'
|
6
|
+
#s.description = 'Add (optional) gem description here'
|
7
|
+
s.required_ruby_version = '>= 1.8.7'
|
8
|
+
|
9
|
+
s.author = 'Roman Smirnov'
|
10
|
+
s.email = 'roman@railsdog.com'
|
11
|
+
s.homepage = 'http://github.com/romul/spree_advanced_cart'
|
12
|
+
# s.rubyforge_project = 'actionmailer'
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.require_path = 'lib'
|
17
|
+
s.requirements << 'none'
|
18
|
+
|
19
|
+
s.has_rdoc = true
|
20
|
+
|
21
|
+
s.add_dependency('spree_core', '>= 0.40.0')
|
22
|
+
s.add_dependency('spree_promo', '>= 0.40.0')
|
23
|
+
end
|
24
|
+
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spree_advanced_cart
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 40
|
8
|
+
- 0
|
9
|
+
version: 0.40.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Roman Smirnov
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-04-05 00:00:00 +04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: spree_core
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 40
|
30
|
+
- 0
|
31
|
+
version: 0.40.0
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: spree_promo
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
- 40
|
44
|
+
- 0
|
45
|
+
version: 0.40.0
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
48
|
+
description:
|
49
|
+
email: roman@railsdog.com
|
50
|
+
executables: []
|
51
|
+
|
52
|
+
extensions: []
|
53
|
+
|
54
|
+
extra_rdoc_files: []
|
55
|
+
|
56
|
+
files:
|
57
|
+
- .gitignore
|
58
|
+
- LICENSE
|
59
|
+
- README.md
|
60
|
+
- Rakefile
|
61
|
+
- Versionfile
|
62
|
+
- app/controllers/orders_controller_decorator.rb
|
63
|
+
- app/views/orders/_advanced_cart.html.erb
|
64
|
+
- app/views/orders/_estimate_shipping_cost_table.html.erb
|
65
|
+
- app/views/orders/edit.html.erb
|
66
|
+
- app/views/orders/estimate_shipping_cost.js.erb
|
67
|
+
- app/views/orders/update.js.erb
|
68
|
+
- config/locales/en.yml
|
69
|
+
- config/routes.rb
|
70
|
+
- features/advanced_cart.feature
|
71
|
+
- features/step_definitions/advanced_cart_steps.rb
|
72
|
+
- features/support/env.rb
|
73
|
+
- features/support/paths.rb
|
74
|
+
- lib/advanced_cart_configuration.rb
|
75
|
+
- lib/spree/advanced_cart/config.rb
|
76
|
+
- lib/spree_advanced_cart.rb
|
77
|
+
- lib/spree_advanced_cart_hooks.rb
|
78
|
+
- lib/tasks/install.rake
|
79
|
+
- lib/tasks/spree_advanced_cart.rake
|
80
|
+
- public/javascripts/advanced_cart.js
|
81
|
+
- public/stylesheets/advanced_cart.css
|
82
|
+
- spec/spec_helper.rb
|
83
|
+
- spree_advanced_cart.gemspec
|
84
|
+
has_rdoc: true
|
85
|
+
homepage: http://github.com/romul/spree_advanced_cart
|
86
|
+
licenses: []
|
87
|
+
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
segments:
|
98
|
+
- 1
|
99
|
+
- 8
|
100
|
+
- 7
|
101
|
+
version: 1.8.7
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
segments:
|
107
|
+
- 0
|
108
|
+
version: "0"
|
109
|
+
requirements:
|
110
|
+
- none
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 1.3.6
|
113
|
+
signing_key:
|
114
|
+
specification_version: 3
|
115
|
+
summary: Cart with several useful additions for Spree
|
116
|
+
test_files: []
|
117
|
+
|