spree_store_pickup 1.0.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19b22e5eb5f6769935eaf302b68075f00bfde9c33653c5923d7d82fd7878b0d8
4
- data.tar.gz: 8fb8b461b0609a39c0795a8682eda0710d748f8578092699edf8db8a664902dd
3
+ metadata.gz: d02ed985c2068cff724a0e6f46d67839695b2b61d34200955475959e5a27719f
4
+ data.tar.gz: 6710d56720b1beab6a6876549ee05f89d24ad9969cfa5c3e7ab1e25cf378d31f
5
5
  SHA512:
6
- metadata.gz: 97c4980d8e20f69ddaaa79bb023e26dea1ba66baa365473caab2b3e2837c3441c7eb34007425417a9fac9d12b0d1889cd1df9bee4cc78a046257e4bf27835604
7
- data.tar.gz: 18661da3303c6ac143bd9007e7b364dc766ee598d814b5f0a9d995f45b0918b764747e947a47d8538cb9bfcf3489bb47325b85a344e008be274e9797d9e0cf0a
6
+ metadata.gz: 85d9824885ed2706e53b8dd0916a51070609b808597de131a1d649a2d02ab708ad99cecefd47d9dad8e28d8ce060db0626e808e6da22dfa2ec7c43aa6f32ed41
7
+ data.tar.gz: 44c0ff744bcdc62683045652a3d020422ec80b2db76bfbb6e6f970d4c06a1ecb14e2bc77d82a772c225c225b1e2ea6bbb46cb729dfa40f220e0ad5fcec4715ef
data/LICENSE.md CHANGED
@@ -1,21 +1,15 @@
1
- # MIT License
1
+ # LICENSE
2
2
 
3
- Copyright (c) 2025 OlympusOne
3
+ Copyright (c) 2025 OlympusOne. All rights reserved.
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
5
+ This program is free software: you can redistribute it and/or modify it under the terms of the
6
+ GNU Affero General Public License as published by the Free Software Foundation, either
7
+ version 3 of the License, or any later version.
11
8
 
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Affero General Public License for more details.
14
13
 
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
14
+ You should have received a copy of the GNU Affero General Public License
15
+ along with this program. If not, see [https://www.gnu.org/licenses/](https://www.gnu.org/licenses/).
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # SpreeStorePickup
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 option during checkout.
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
  [![Gem Version](https://badge.fury.io/rb/spree_store_pickup.svg)](https://badge.fury.io/rb/spree_store_pickup)
6
6
 
@@ -8,26 +8,59 @@ 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
- ```ruby
11
+ ```bash
12
12
  bundle add spree_store_pickup
13
13
  ```
14
14
 
15
- 2. Install the migrations:
16
-
17
- ```sh
18
- bundle exec rake railties:install:migrations FROM=spree_store_pickup
19
- ```
20
-
21
- 3. Run the migrations:
15
+ 2. Run the install generator
22
16
 
23
- ```sh
24
- bundle exec rails db:migrate
17
+ ```bash
18
+ bundle exec rails g spree_store_pickup:install
25
19
  ```
26
20
 
27
- 4. Restart your server
21
+ 3. Restart your server
28
22
 
29
23
  If your server was running, restart it so that it can find the assets properly.
30
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
59
+
60
+ PaymentMethod.prepend PaymentMethodDecorator
61
+ end
62
+ ````
63
+
31
64
  ## Developing
32
65
 
33
66
  1. Create a dummy app
@@ -38,6 +71,7 @@ This is a Store Pickup extension for [Spree Commerce](https://spreecommerce.org)
38
71
  ```
39
72
 
40
73
  2. Add your new code
74
+
41
75
  3. Run tests
42
76
 
43
77
  ```bash
@@ -53,7 +87,7 @@ require 'spree_store_pickup/factories'
53
87
 
54
88
  ## Releasing a new version
55
89
 
56
- ```shell
90
+ ```bash
57
91
  bundle exec gem bump -p -t
58
92
  bundle exec gem release
59
93
  ```
@@ -66,4 +100,4 @@ If you'd like to contribute, please take a look at the
66
100
  [instructions](CONTRIBUTING.md) for installing dependencies and crafting a good
67
101
  pull request.
68
102
 
69
- Copyright (c) 2025 OlympusOne, released under the MIT
103
+ Copyright (c) 2025 OlympusOne, released under the AGPL-3.0 or later.
@@ -0,0 +1,5 @@
1
+ //= link_tree ../images
2
+ //= link spree_store_pickup/application.js
3
+ //= link_tree ../../javascript/spree_store_pickup/controllers .js
4
+ //= link_tree ../../../vendor/javascript .js
5
+ //= link_tree ../../../vendor/stylesheets .css
@@ -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)
@@ -0,0 +1,7 @@
1
+ import { Controller } from '@hotwired/stimulus'
2
+
3
+ export default class extends Controller {
4
+ connect() {
5
+ // TODO: Add any initialization logic if needed
6
+ }
7
+ }
@@ -8,6 +8,10 @@ module Spree
8
8
  Spree.t(:store_pickup_method)
9
9
  end
10
10
 
11
+ def payment_icon_name
12
+ 'storecredit'
13
+ end
14
+
11
15
  def source_required?
12
16
  false
13
17
  end
@@ -8,6 +8,6 @@ module Spree
8
8
  order.shipping_method&.store_pickup?
9
9
  end
10
10
  end
11
- end
12
11
 
13
- Spree::PaymentMethod.prepend Spree::PaymentMethodDecorator
12
+ PaymentMethod.prepend PaymentMethodDecorator
13
+ end
@@ -5,10 +5,6 @@
5
5
  </h5>
6
6
  </div>
7
7
  <div class="card-body">
8
- <div class="custom-control custom-checkbox">
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' %>
@@ -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,7 +1,7 @@
1
1
  Rails.application.config.after_initialize do
2
- Rails.application.config.spree.payment_methods << Spree::PaymentMethod::StorePickup
2
+ Spree.payment_methods << Spree::PaymentMethod::StorePickup
3
3
 
4
- 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'
5
5
 
6
6
  Spree::PermittedAttributes.shipping_method_attributes << :store_pickup
7
7
  end
@@ -0,0 +1,13 @@
1
+ module SpreeStorePickup
2
+ class Configuration < Spree::Preferences::Configuration
3
+
4
+ # Some example preferences are shown below, for more information visit:
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]
12
+ end
13
+ end
@@ -9,6 +9,23 @@ module SpreeStorePickup
9
9
  g.test_framework :rspec
10
10
  end
11
11
 
12
+ initializer 'spree_store_pickup.environment', before: :load_config_initializers do |_app|
13
+ SpreeStorePickup::Config = SpreeStorePickup::Configuration.new
14
+ end
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
+
12
29
  def self.activate
13
30
  Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
14
31
  Rails.configuration.cache_classes ? require(c) : load(c)
@@ -1,5 +1,5 @@
1
1
  module SpreeStorePickup
2
- VERSION = '1.0.1'.freeze
2
+ VERSION = '1.1.4'.freeze
3
3
 
4
4
  def gem_version
5
5
  Gem::Version.new(VERSION)
@@ -2,3 +2,4 @@ require 'spree_core'
2
2
  require 'spree_extension'
3
3
  require 'spree_store_pickup/engine'
4
4
  require 'spree_store_pickup/version'
5
+ require 'spree_store_pickup/configuration'
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.0.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.0.4
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.0.4
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.0.4
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.0.4
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.0.4
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.0.4
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
@@ -104,18 +109,19 @@ files:
104
109
  - db/migrate/20250601165042_add_store_pickup_to_shipping_methods.rb
105
110
  - lib/generators/spree_store_pickup/install/install_generator.rb
106
111
  - lib/spree_store_pickup.rb
112
+ - lib/spree_store_pickup/configuration.rb
107
113
  - lib/spree_store_pickup/engine.rb
108
114
  - lib/spree_store_pickup/factories.rb
109
115
  - lib/spree_store_pickup/version.rb
110
116
  homepage: https://github.com/olympusone/spree_store_pickup
111
117
  licenses:
112
- - MIT
118
+ - AGPL-3.0-or-later
113
119
  metadata:
114
120
  bug_tracker_uri: https://github.com/olympusone/spree_store_pickup/issues
115
- changelog_uri: https://github.com/olympusone/spree_store_pickup/releases/tag/v1.0.1
121
+ changelog_uri: https://github.com/olympusone/spree_store_pickup/releases/tag/v1.1.4
116
122
  documentation_uri: https://github.com/olympusone/spree_store_pickup
117
123
  homepage_uri: https://github.com/olympusone/spree_store_pickup
118
- source_code_uri: https://github.com/olympusone/spree_store_pickup/tree/v1.0.1
124
+ source_code_uri: https://github.com/olympusone/spree_store_pickup/tree/v1.1.4
119
125
  rdoc_options: []
120
126
  require_paths:
121
127
  - lib