spree-last-address 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/Gemfile +3 -0
- data/LICENSE +23 -0
- data/README.md +31 -0
- data/Rakefile +1 -0
- data/app/controllers/spree/checkout_controller_decorator.rb +15 -0
- data/lib/spree_last_address/version.rb +5 -0
- data/lib/spree_last_address.rb +27 -0
- data/lib/tasks/install.rake +24 -0
- data/spree_last_address.gemspec +19 -0
- metadata +67 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6cd710be6ac325810be49c2bed3cd6b3a25a5820
|
4
|
+
data.tar.gz: e56c61ca01ada3ee8ba85e1eaa0ddf275300de21
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d891f0373749514ff53fa144205710dc123559a7caad93218e34d109f66e61ea49c3d1aa88e33cbbae32a2e0974ee9963696b36aa2f85caa18c7546114cd949b
|
7
|
+
data.tar.gz: e27157ca2835b82f41e68582120647790515a242cb8a4e668ec45f8a6ac276b060d61bad89c567ff89d3a87686a22fff49691d3292ea16af39d4b9aca5db6832
|
data/Gemfile
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,31 @@
|
|
1
|
+
Last Address extension for Spree
|
2
|
+
================================
|
3
|
+
|
4
|
+
During checkout, causes the address to be prefilled with the address from their most recent order or
|
5
|
+
the user’s saved address (if available).
|
6
|
+
|
7
|
+
This relieves the customer of having to type in his address again on a second order. (The
|
8
|
+
unnecessary typing make them more likely to bounce instead of completing the order.)
|
9
|
+
|
10
|
+
If your app allows a user to set and edit their "preferred" or "default" address (as reflected by
|
11
|
+
`user.bill_address`/`user.ship_address`), and the user has set a preferred address for their
|
12
|
+
account, that address will take priority and be used instead of the address from their most recent
|
13
|
+
order. (Similar to [spree-default-addresses](https://github.com/swistak/spree-default-addresses).)
|
14
|
+
|
15
|
+
As of Spree 1.2, the `belongs_to :bill_address` and `belongs_to :ship_address` associations are
|
16
|
+
provided for the `Spree::User` model by the spree_auth_devise gem . If those associations are not
|
17
|
+
available or if the user doesn't have a saved address (which will be the case unless you've provided
|
18
|
+
a way in your app to set an address), then it will just use the address from user's most recent
|
19
|
+
order.
|
20
|
+
|
21
|
+
Installation
|
22
|
+
============
|
23
|
+
|
24
|
+
Just put this in your `Gemfile`:
|
25
|
+
|
26
|
+
gem 'spree_last_address', '~> 1.0.0'
|
27
|
+
|
28
|
+
License
|
29
|
+
=======
|
30
|
+
|
31
|
+
Copyright (c) 2010 Torsten Rüger, released under the New BSD License
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Spree
|
2
|
+
CheckoutController.class_eval do
|
3
|
+
|
4
|
+
private
|
5
|
+
|
6
|
+
def before_address
|
7
|
+
return if @order.bill_address or @order.ship_address
|
8
|
+
last_used_bill_address, last_used_ship_address = SpreeLastAddress.find_last_used_addresses(@order.email)
|
9
|
+
preferred_bill_address, preferred_ship_address = current_user.bill_address, current_user.ship_address if current_user.respond_to?(:bill_address) && current_user.respond_to?(:ship_address)
|
10
|
+
@order.bill_address ||= preferred_bill_address || last_used_bill_address || Address.default
|
11
|
+
@order.ship_address ||= preferred_ship_address || last_used_ship_address || Address.default
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spree_last_address/version'
|
2
|
+
|
3
|
+
module SpreeLastAddress
|
4
|
+
class Engine < Rails::Engine
|
5
|
+
|
6
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
7
|
+
|
8
|
+
def self.activate
|
9
|
+
Dir.glob(File.join(File.dirname(__FILE__), '../app/**/*_decorator*.rb')) do |c|
|
10
|
+
Rails.env.production? ? require(c) : load(c)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
config.to_prepare &method(:activate).to_proc
|
15
|
+
end
|
16
|
+
|
17
|
+
class << self
|
18
|
+
def find_last_used_addresses(email)
|
19
|
+
past = Spree::Order.order("id desc").where(:email => email).where("state != 'cart'").limit(8)
|
20
|
+
if order = past.detect(&:bill_address)
|
21
|
+
bill_address = order.bill_address.clone if order.bill_address
|
22
|
+
ship_address = order.ship_address.clone if order.ship_address
|
23
|
+
end
|
24
|
+
return bill_address, ship_address
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
namespace :spree_last_address 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_last_address:install:migrations'].invoke
|
5
|
+
Rake::Task['spree_last_address: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
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'spree_last_address/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.platform = Gem::Platform::RUBY
|
7
|
+
s.name = 'spree-last-address'
|
8
|
+
s.version = SpreeLastAddress.version
|
9
|
+
s.summary = "Prefill address with last-used address"
|
10
|
+
s.description = "During checkout, causes the address to be prefilled with the address from their most recent order or the user's saved address."
|
11
|
+
|
12
|
+
s.author = 'Torsten Rüger'
|
13
|
+
s.email = 'torsten@villataika.fi'
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.require_path = 'lib'
|
17
|
+
|
18
|
+
s.add_dependency 'spree_core', '~> 1.0'
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spree-last-address
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Torsten Rüger
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: spree_core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
description: During checkout, causes the address to be prefilled with the address
|
28
|
+
from their most recent order or the user's saved address.
|
29
|
+
email: torsten@villataika.fi
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- .gitignore
|
35
|
+
- Gemfile
|
36
|
+
- LICENSE
|
37
|
+
- README.md
|
38
|
+
- Rakefile
|
39
|
+
- app/controllers/spree/checkout_controller_decorator.rb
|
40
|
+
- lib/spree_last_address.rb
|
41
|
+
- lib/spree_last_address/version.rb
|
42
|
+
- lib/tasks/install.rake
|
43
|
+
- spree_last_address.gemspec
|
44
|
+
homepage:
|
45
|
+
licenses: []
|
46
|
+
metadata: {}
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 2.1.10
|
64
|
+
signing_key:
|
65
|
+
specification_version: 4
|
66
|
+
summary: Prefill address with last-used address
|
67
|
+
test_files: []
|