spree_store_pickup 1.1.6 → 1.2.0
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b9ea96c2a440506b83d0c18b63756ead9a8c700ce0e28233726b49a9626dd135
|
|
4
|
+
data.tar.gz: 9d649669ddced34b0566b7454aa6a1b8078d8bfcc145fbcf41902c09cb19711c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4e53f483bbc3afce6fbf322caed4650eaa4a548921b19273d094b167b1f5119c1d704120f1b7e846e77b6b404d22af0b472caefe21e5b9e0374be4a771b7189c
|
|
7
|
+
data.tar.gz: 0ce18ee3d7c5c8b6b9e2dbc1514c3142af6331e2b4b5d33bb8cc6a9526d4ec1dd6069450e7a0092c58446b362eaa4f453f922ef8ad9eb45df27984a821eb6f65
|
data/README.md
CHANGED
|
@@ -8,75 +8,73 @@ This is a Store Pickup extension for [Spree Commerce](https://spreecommerce.org)
|
|
|
8
8
|
|
|
9
9
|
1. Add this extension to your Gemfile with this line:
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
```bash
|
|
12
|
+
bundle add spree_store_pickup
|
|
13
|
+
```
|
|
14
14
|
|
|
15
15
|
2. Run the install generator
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
```bash
|
|
18
|
+
bundle exec rails g spree_store_pickup:install
|
|
19
|
+
```
|
|
20
20
|
|
|
21
21
|
3. Restart your server
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
If your server was running, restart it so that it can find the assets properly.
|
|
24
24
|
|
|
25
25
|
## Usage
|
|
26
26
|
|
|
27
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
28
|
2. Create a Payment Method for store pickup (e.g. name: "Pay In Store") whose `method_type` is `store_pickup`.
|
|
29
|
-
3.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
4.
|
|
29
|
+
3. The gem decorates `Spree::PaymentMethod#available_for_order?` with these rules:
|
|
30
|
+
- The store pickup payment method is shown only when the selected shipping method is store pickup.
|
|
31
|
+
- When store pickup shipping is selected, all other available payment methods are shown too.
|
|
32
|
+
4. To show ONLY the store pickup payment method when store pickup shipping is selected, enable this in an initializer:
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
```ruby
|
|
35
|
+
SpreeStorePickup::Config[:exclusive_payment_method] = true
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
5. For custom rules, prepend your own decorator in the host app. Use a different module name than the gem's `Spree::PaymentMethodStorePickupDecorator` so it doesn't replace it. Call `super` to keep the gem's rules, or skip it to replace them:
|
|
39
|
+
|
|
40
|
+
```ruby
|
|
35
41
|
module Spree
|
|
36
|
-
module
|
|
37
|
-
# Customize availability combining store pickup (and optionally COD) logic.
|
|
42
|
+
module PaymentMethodCodDecorator
|
|
38
43
|
def available_for_order?(order)
|
|
39
44
|
return false unless super
|
|
40
45
|
|
|
41
|
-
#
|
|
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
|
|
46
|
+
# Example: hide a COD payment method when store pickup shipping is selected.
|
|
47
|
+
return false if store_pickup_available?(order) && respond_to?(:cod_payment?) && cod_payment?
|
|
55
48
|
|
|
56
49
|
true
|
|
57
50
|
end
|
|
58
51
|
end
|
|
59
52
|
|
|
60
|
-
PaymentMethod.prepend
|
|
53
|
+
PaymentMethod.prepend PaymentMethodCodDecorator
|
|
61
54
|
end
|
|
62
|
-
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Helpers available on every payment method:
|
|
58
|
+
|
|
59
|
+
- `payment_method.store_pickup?`
|
|
60
|
+
- `payment_method.store_pickup_available?(order)` (true when the order's selected shipping method is store pickup)
|
|
63
61
|
|
|
64
62
|
## Developing
|
|
65
63
|
|
|
66
64
|
1. Create a dummy app
|
|
67
65
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
```bash
|
|
67
|
+
bundle update
|
|
68
|
+
bundle exec rake test_app
|
|
69
|
+
```
|
|
72
70
|
|
|
73
71
|
2. Add your new code
|
|
74
72
|
|
|
75
73
|
3. Run tests
|
|
76
74
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
```bash
|
|
76
|
+
bundle exec rspec
|
|
77
|
+
```
|
|
80
78
|
|
|
81
79
|
When testing your applications integration with this extension you may use it's factories.
|
|
82
80
|
Simply add this require statement to your spec_helper:
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module PaymentMethodStorePickupDecorator
|
|
3
|
+
def store_pickup?
|
|
4
|
+
method_type == 'store_pickup'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def store_pickup_available?(order)
|
|
8
|
+
order.shipping_method&.store_pickup?
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def available_for_order?(order)
|
|
12
|
+
return false unless super
|
|
13
|
+
|
|
14
|
+
# Store pickup payment is only available with store pickup shipping.
|
|
15
|
+
return store_pickup_available?(order) if store_pickup?
|
|
16
|
+
|
|
17
|
+
# Optionally restrict store pickup shipping to the store pickup payment method only.
|
|
18
|
+
return false if SpreeStorePickup::Config[:exclusive_payment_method] && store_pickup_available?(order)
|
|
19
|
+
|
|
20
|
+
true
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
PaymentMethod.prepend PaymentMethodStorePickupDecorator
|
|
25
|
+
end
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
module SpreeStorePickup
|
|
2
2
|
class Configuration < Spree::Preferences::Configuration
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
# https://docs.spreecommerce.org/developer/contributing/creating-an-extension
|
|
6
|
-
|
|
7
|
-
# preference :enabled, :boolean, default: true
|
|
8
|
-
# preference :dark_chocolate, :boolean, default: true
|
|
9
|
-
# preference :color, :string, default: 'Red'
|
|
10
|
-
# preference :favorite_number, :integer
|
|
11
|
-
# preference :supported_locales, :array, default: [:en]
|
|
3
|
+
# When true, selecting store pickup shipping shows only the store pickup payment method.
|
|
4
|
+
preference :exclusive_payment_method, :boolean, default: false
|
|
12
5
|
end
|
|
13
6
|
end
|
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.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- OlympusOne
|
|
@@ -92,7 +92,7 @@ files:
|
|
|
92
92
|
- app/javascript/spree_store_pickup/application.js
|
|
93
93
|
- app/javascript/spree_store_pickup/controllers/spree_store_pickup_controller.js
|
|
94
94
|
- app/models/spree/payment_method/store_pickup.rb
|
|
95
|
-
- app/models/spree/
|
|
95
|
+
- app/models/spree/payment_method_store_pickup_decorator.rb
|
|
96
96
|
- app/views/spree/admin/payment_methods/_store_pickup.html.erb
|
|
97
97
|
- app/views/spree/admin/payment_methods/descriptions/_store_pickup.html.erb
|
|
98
98
|
- app/views/spree/admin/payments/source_views/_store_pickup.html.erb
|
|
@@ -117,10 +117,10 @@ licenses:
|
|
|
117
117
|
- MIT
|
|
118
118
|
metadata:
|
|
119
119
|
bug_tracker_uri: https://github.com/olympusone/spree_store_pickup/issues
|
|
120
|
-
changelog_uri: https://github.com/olympusone/spree_store_pickup/releases/tag/v1.
|
|
120
|
+
changelog_uri: https://github.com/olympusone/spree_store_pickup/releases/tag/v1.2.0
|
|
121
121
|
documentation_uri: https://github.com/olympusone/spree_store_pickup
|
|
122
122
|
homepage_uri: https://github.com/olympusone/spree_store_pickup
|
|
123
|
-
source_code_uri: https://github.com/olympusone/spree_store_pickup/tree/v1.
|
|
123
|
+
source_code_uri: https://github.com/olympusone/spree_store_pickup/tree/v1.2.0
|
|
124
124
|
rdoc_options: []
|
|
125
125
|
require_paths:
|
|
126
126
|
- lib
|
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
136
136
|
version: '0'
|
|
137
137
|
requirements:
|
|
138
138
|
- none
|
|
139
|
-
rubygems_version:
|
|
139
|
+
rubygems_version: 4.0.3
|
|
140
140
|
specification_version: 4
|
|
141
141
|
summary: Spree Commerce Store Pickup Extension
|
|
142
142
|
test_files: []
|