spree_store_pickup 1.1.3 → 1.1.4
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 +4 -4
- data/README.md +50 -28
- data/app/assets/config/spree_store_pickup_manifest.js +5 -0
- data/app/javascript/spree_store_pickup/application.js +16 -0
- data/app/javascript/spree_store_pickup/controllers/spree_store_pickup_controller.js +7 -0
- data/app/models/spree/payment_method_decorator.rb +2 -2
- data/app/views/spree/admin/shipping_methods/_store_pickup_form.html.erb +1 -5
- data/app/views/spree_store_pickup/_head.html.erb +1 -0
- data/config/importmap.rb +6 -0
- data/config/initializers/spree.rb +2 -3
- data/lib/spree_store_pickup/engine.rb +13 -0
- data/lib/spree_store_pickup/version.rb +1 -1
- metadata +14 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d02ed985c2068cff724a0e6f46d67839695b2b61d34200955475959e5a27719f
|
|
4
|
+
data.tar.gz: 6710d56720b1beab6a6876549ee05f89d24ad9969cfa5c3e7ab1e25cf378d31f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 85d9824885ed2706e53b8dd0916a51070609b808597de131a1d649a2d02ab708ad99cecefd47d9dad8e28d8ce060db0626e808e6da22dfa2ec7c43aa6f32ed41
|
|
7
|
+
data.tar.gz: 44c0ff744bcdc62683045652a3d020422ec80b2db76bfbb6e6f970d4c06a1ecb14e2bc77d82a772c225c225b1e2ea6bbb46cb729dfa40f220e0ad5fcec4715ef
|
data/README.md
CHANGED
|
@@ -1,68 +1,90 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Spree Store Pickup
|
|
2
2
|
|
|
3
|
-
This is a Store Pickup extension for [Spree Commerce](https://spreecommerce.org), an open source e-commerce platform built with Ruby on Rails. Adds in-store pickup as selectable shipping and payment
|
|
3
|
+
This is a Store Pickup extension for [Spree Commerce](https://spreecommerce.org), an open source e-commerce platform built with Ruby on Rails. Adds in-store pickup as selectable shipping and payment method during checkout.
|
|
4
4
|
|
|
5
5
|
[](https://badge.fury.io/rb/spree_store_pickup)
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
|
-
1. Add this extension to your Gemfile:
|
|
9
|
+
1. Add this extension to your Gemfile with this line:
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
12
|
bundle add spree_store_pickup
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
2.
|
|
15
|
+
2. Run the install generator
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
bundle exec
|
|
18
|
+
bundle exec rails g spree_store_pickup:install
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
3.
|
|
21
|
+
3. Restart your server
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
If your server was running, restart it so that it can find the assets properly.
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
1. Create (or enable) a Shipping Method that represents in‑store pickup. The generator creates a shipping method with a `store_pickup` type. Ensure the shipping method you want to use returns `true` for `store_pickup?`.
|
|
28
|
+
2. Create a Payment Method for store pickup (e.g. name: "Pay In Store") whose `method_type` is `store_pickup`.
|
|
29
|
+
3. By default this gem only provides helpers:
|
|
30
|
+
* `payment_method.store_pickup?`
|
|
31
|
+
* `payment_method.store_pickup_available?(order)` (true when the order's selected shipping method is store pickup)
|
|
32
|
+
4. If you want the Store Pickup payment method to be shown ONLY when the shipping method is store pickup, add a decorator in your host app:
|
|
33
|
+
|
|
34
|
+
````ruby
|
|
35
|
+
module Spree
|
|
36
|
+
module PaymentMethodDecorator
|
|
37
|
+
# Customize availability combining store pickup (and optionally COD) logic.
|
|
38
|
+
def available_for_order?(order)
|
|
39
|
+
return false unless super
|
|
40
|
+
|
|
41
|
+
# If shipping method is store pickup, only allow the store pickup payment method.
|
|
42
|
+
if store_pickup_available?(order)
|
|
43
|
+
return store_pickup?
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Example integration with a COD payment gem (optional):
|
|
47
|
+
if respond_to?(:cod_payment_available?) && cod_payment_available?(order)
|
|
48
|
+
return cod_payment?
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Hide specialized methods when their conditions are not met.
|
|
52
|
+
if store_pickup? || (respond_to?(:cod_payment?) && cod_payment?)
|
|
53
|
+
return false
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
true
|
|
57
|
+
end
|
|
58
|
+
end
|
|
26
59
|
|
|
27
|
-
|
|
60
|
+
PaymentMethod.prepend PaymentMethodDecorator
|
|
61
|
+
end
|
|
62
|
+
````
|
|
28
63
|
|
|
29
64
|
## Developing
|
|
30
65
|
|
|
31
|
-
1. Create a dummy app
|
|
66
|
+
1. Create a dummy app
|
|
32
67
|
|
|
33
68
|
```bash
|
|
34
69
|
bundle update
|
|
35
70
|
bundle exec rake test_app
|
|
36
71
|
```
|
|
37
72
|
|
|
38
|
-
2. Add code
|
|
73
|
+
2. Add your new code
|
|
39
74
|
|
|
40
|
-
3. Run tests
|
|
75
|
+
3. Run tests
|
|
41
76
|
|
|
42
77
|
```bash
|
|
43
78
|
bundle exec rspec
|
|
44
79
|
```
|
|
45
80
|
|
|
46
|
-
When testing your
|
|
81
|
+
When testing your applications integration with this extension you may use it's factories.
|
|
82
|
+
Simply add this require statement to your spec_helper:
|
|
47
83
|
|
|
48
84
|
```ruby
|
|
49
85
|
require 'spree_store_pickup/factories'
|
|
50
86
|
```
|
|
51
87
|
|
|
52
|
-
## Testing
|
|
53
|
-
|
|
54
|
-
Generate the test app:
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
bundle exec rake test_app
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Then run:
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
bundle exec rspec
|
|
64
|
-
```
|
|
65
|
-
|
|
66
88
|
## Releasing a new version
|
|
67
89
|
|
|
68
90
|
```bash
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import '@hotwired/turbo-rails'
|
|
2
|
+
import { Application } from '@hotwired/stimulus'
|
|
3
|
+
|
|
4
|
+
let application
|
|
5
|
+
|
|
6
|
+
if (typeof window.Stimulus === "undefined") {
|
|
7
|
+
application = Application.start()
|
|
8
|
+
application.debug = false
|
|
9
|
+
window.Stimulus = application
|
|
10
|
+
} else {
|
|
11
|
+
application = window.Stimulus
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
import SpreeStorePickupController from 'spree_store_pickup/controllers/spree_store_pickup_controller'
|
|
15
|
+
|
|
16
|
+
application.register('spree_store_pickup', SpreeStorePickupController)
|
|
@@ -5,10 +5,6 @@
|
|
|
5
5
|
</h5>
|
|
6
6
|
</div>
|
|
7
7
|
<div class="card-body">
|
|
8
|
-
|
|
9
|
-
<%= f.check_box :store_pickup, class: 'custom-control-input' %>
|
|
10
|
-
<%= f.label :store_pickup, class: 'custom-control-label font-weight-semibold' %>
|
|
11
|
-
<%= f.error_message_on :store_pickup %>
|
|
12
|
-
</div>
|
|
8
|
+
<%= f.spree_check_box :store_pickup %>
|
|
13
9
|
</div>
|
|
14
10
|
</div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= javascript_import_module_tag 'application-spree-store-pickup' %>
|
data/config/importmap.rb
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
pin 'application-spree-store-pickup', to: 'spree_store_pickup/application.js', preload: false
|
|
2
|
+
|
|
3
|
+
pin_all_from SpreeStorePickup::Engine.root.join('app/javascript/spree_store_pickup/controllers'),
|
|
4
|
+
under: 'spree_store_pickup/controllers',
|
|
5
|
+
to: 'spree_store_pickup/controllers',
|
|
6
|
+
preload: 'application-spree-store-pickup'
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
Rails.application.config.after_initialize do
|
|
2
|
-
|
|
2
|
+
Spree.payment_methods << Spree::PaymentMethod::StorePickup
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
Rails.application.config.spree_admin.shipping_method_form_partials << 'spree/admin/shipping_methods/store_pickup_form'
|
|
4
|
+
Spree.admin.partials.shipping_method_form << 'spree/admin/shipping_methods/store_pickup_form'
|
|
6
5
|
|
|
7
6
|
Spree::PermittedAttributes.shipping_method_attributes << :store_pickup
|
|
8
7
|
end
|
|
@@ -13,6 +13,19 @@ module SpreeStorePickup
|
|
|
13
13
|
SpreeStorePickup::Config = SpreeStorePickup::Configuration.new
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
initializer 'spree_store_pickup.assets' do |app|
|
|
17
|
+
app.config.assets.paths << root.join('app/javascript')
|
|
18
|
+
app.config.assets.paths << root.join('vendor/javascript')
|
|
19
|
+
app.config.assets.paths << root.join('vendor/stylesheets')
|
|
20
|
+
app.config.assets.precompile += %w[spree_store_pickup_manifest]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
initializer 'spree_store_pickup.importmap', before: 'importmap' do |app|
|
|
24
|
+
app.config.importmap.paths << root.join('config/importmap.rb')
|
|
25
|
+
# https://github.com/rails/importmap-rails?tab=readme-ov-file#sweeping-the-cache-in-development-and-test
|
|
26
|
+
app.config.importmap.cache_sweepers << root.join('app/javascript')
|
|
27
|
+
end
|
|
28
|
+
|
|
16
29
|
def self.activate
|
|
17
30
|
Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
|
|
18
31
|
Rails.configuration.cache_classes ? require(c) : load(c)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spree_store_pickup
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- OlympusOne
|
|
@@ -15,42 +15,42 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 5.
|
|
18
|
+
version: 5.2.0
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 5.
|
|
25
|
+
version: 5.2.0
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: spree_storefront
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
30
|
- - ">="
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 5.
|
|
32
|
+
version: 5.2.0
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - ">="
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: 5.
|
|
39
|
+
version: 5.2.0
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: spree_admin
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
|
43
43
|
requirements:
|
|
44
44
|
- - ">="
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: 5.
|
|
46
|
+
version: 5.2.0
|
|
47
47
|
type: :runtime
|
|
48
48
|
prerelease: false
|
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
51
|
- - ">="
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: 5.
|
|
53
|
+
version: 5.2.0
|
|
54
54
|
- !ruby/object:Gem::Dependency
|
|
55
55
|
name: spree_extension
|
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -89,6 +89,9 @@ files:
|
|
|
89
89
|
- LICENSE.md
|
|
90
90
|
- README.md
|
|
91
91
|
- Rakefile
|
|
92
|
+
- app/assets/config/spree_store_pickup_manifest.js
|
|
93
|
+
- app/javascript/spree_store_pickup/application.js
|
|
94
|
+
- app/javascript/spree_store_pickup/controllers/spree_store_pickup_controller.js
|
|
92
95
|
- app/models/spree/payment_method/store_pickup.rb
|
|
93
96
|
- app/models/spree/payment_method_decorator.rb
|
|
94
97
|
- app/views/spree/admin/payment_methods/_store_pickup.html.erb
|
|
@@ -97,6 +100,8 @@ files:
|
|
|
97
100
|
- app/views/spree/admin/shipping_methods/_store_pickup_form.html.erb
|
|
98
101
|
- app/views/spree/admin/spree/checkout/payment/_store_pickup.html.erb
|
|
99
102
|
- app/views/spree/checkout/payment/_store_pickup.html.erb
|
|
103
|
+
- app/views/spree_store_pickup/_head.html.erb
|
|
104
|
+
- config/importmap.rb
|
|
100
105
|
- config/initializers/spree.rb
|
|
101
106
|
- config/locales/el.yml
|
|
102
107
|
- config/locales/en.yml
|
|
@@ -113,10 +118,10 @@ licenses:
|
|
|
113
118
|
- AGPL-3.0-or-later
|
|
114
119
|
metadata:
|
|
115
120
|
bug_tracker_uri: https://github.com/olympusone/spree_store_pickup/issues
|
|
116
|
-
changelog_uri: https://github.com/olympusone/spree_store_pickup/releases/tag/v1.1.
|
|
121
|
+
changelog_uri: https://github.com/olympusone/spree_store_pickup/releases/tag/v1.1.4
|
|
117
122
|
documentation_uri: https://github.com/olympusone/spree_store_pickup
|
|
118
123
|
homepage_uri: https://github.com/olympusone/spree_store_pickup
|
|
119
|
-
source_code_uri: https://github.com/olympusone/spree_store_pickup/tree/v1.1.
|
|
124
|
+
source_code_uri: https://github.com/olympusone/spree_store_pickup/tree/v1.1.4
|
|
120
125
|
rdoc_options: []
|
|
121
126
|
require_paths:
|
|
122
127
|
- lib
|