spree_core 5.4.0.beta5 → 5.4.0.beta6

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: a2a4eae0b4e102ba4160e435fe81d656ced27b014ed013670226bb8a522b5996
4
- data.tar.gz: c8c6737253472a4456f29b06f1ae028b2c4144732fba6dae7d8dd8c5e2b92d8f
3
+ metadata.gz: d1e118b3f3198080c2006abcd4956ae76608cf6a6a99ed7f16df2380839fe98f
4
+ data.tar.gz: 8f05ff3e72814788a15c7c145ea62f1f9efb603b5dcd18fcedcd07774274db7a
5
5
  SHA512:
6
- metadata.gz: ec9479d52b6bcbd036354511897d0ee360da7784aef051f20affe23991b1eaebe8525b7a0173fbc7cdc1310a977909e4b78a33b0cd677869d579d1666bbada7a
7
- data.tar.gz: 44b40ddca311ed24ae26cd99b5455a7259a0aa986cb8a9a76598101e4c42ea48042b8f1256365b2734c7e43218337ec7963c78b0bcffc5ab70f62e0f794d4b9e
6
+ metadata.gz: b6b0596bb455d278630cf6df3e1927034c703f15e4319c856cec8eaa798e871ec671597a3bf07f3cb20846b775a460f77df8e828184fc2b1200c4a394760c361
7
+ data.tar.gz: c3693f84de9a1b1c26e3572f8c350a498050765242453b3b2a95d3a6956d06476a54db89ec3f21c0ba4bd0eea27edad7da2a2b1ada5f79d9a1eaf70a44084a28
@@ -127,6 +127,8 @@ module Spree
127
127
  else
128
128
  raise Core::GatewayError, Spree.t(:payment_processing_failed)
129
129
  end
130
+ else
131
+ yield unless processing?
130
132
  end
131
133
  end
132
134
 
@@ -4,6 +4,14 @@ module Spree
4
4
  %w{capture void}
5
5
  end
6
6
 
7
+ def authorize(*)
8
+ simulated_successful_billing_response
9
+ end
10
+
11
+ def purchase(*)
12
+ simulated_successful_billing_response
13
+ end
14
+
7
15
  # Indicates whether its possible to capture the payment
8
16
  def can_capture?(payment)
9
17
  ['checkout', 'pending'].include?(payment.state)
@@ -17,11 +17,14 @@ module Spree
17
17
  # prepared_params = service.call
18
18
  #
19
19
  class PrepareNestedAttributes
20
+ attr_reader :variants_to_discontinue
21
+
20
22
  def initialize(product, store, params, ability)
21
23
  @product = product
22
24
  @store = store
23
25
  @params = params
24
26
  @ability = ability
27
+ @variants_to_discontinue = []
25
28
  end
26
29
 
27
30
  def call
@@ -75,7 +78,8 @@ module Spree
75
78
  params[:option_type_ids] = []
76
79
  params[:variants_attributes] = {}
77
80
 
78
- variants_to_remove.each_with_index do |variant_id, index|
81
+ populate_variants_to_discontinue
82
+ variant_ids_to_destroy.each_with_index do |variant_id, index|
79
83
  params[:variants_attributes][index.to_s] = { id: variant_id, _destroy: '1' }
80
84
  end
81
85
 
@@ -122,15 +126,37 @@ module Spree
122
126
  def removed_variants_attributes
123
127
  return {} unless can_remove_variants?
124
128
 
129
+ populate_variants_to_discontinue
130
+
125
131
  attributes = {}
126
132
  last_index = params[:variants_attributes].keys.map(&:to_i).max
127
- variants_to_remove.each_with_index do |variant_id, index|
128
- attributes[(index + last_index + 1).to_s] = { id: variant_id, _destroy: '1' }
133
+ variant_ids_to_destroy.each_with_index do |variant_id, index|
134
+ attributes[(last_index + 1 + index).to_s] = { id: variant_id, _destroy: '1' }
129
135
  end
130
136
 
131
137
  attributes
132
138
  end
133
139
 
140
+ def populate_variants_to_discontinue
141
+ ids = variants_to_remove.select { |vid| variant_ids_with_completed_orders.include?(vid) }
142
+ @variants_to_discontinue = product.variants.where(id: ids).to_a if ids.any?
143
+ end
144
+
145
+ def variant_ids_to_destroy
146
+ variants_to_remove - variant_ids_with_completed_orders
147
+ end
148
+
149
+ def variant_ids_with_completed_orders
150
+ @variant_ids_with_completed_orders ||=
151
+ product.variants
152
+ .joins(:orders)
153
+ .merge(Spree::Order.complete)
154
+ .reorder(nil)
155
+ .distinct
156
+ .pluck(:id)
157
+ .map(&:to_s)
158
+ end
159
+
134
160
  def removed_product_option_types_attributes
135
161
  return {} unless can_manage_option_types?
136
162
 
@@ -1,5 +1,5 @@
1
1
  module Spree
2
- VERSION = '5.4.0.beta5'.freeze
2
+ VERSION = '5.4.0.beta6'.freeze
3
3
 
4
4
  def self.version
5
5
  VERSION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.4.0.beta5
4
+ version: 5.4.0.beta6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Schofield
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2026-03-10 00:00:00.000000000 Z
13
+ date: 2026-03-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: i18n-tasks
@@ -1656,9 +1656,9 @@ licenses:
1656
1656
  - BSD-3-Clause
1657
1657
  metadata:
1658
1658
  bug_tracker_uri: https://github.com/spree/spree/issues
1659
- changelog_uri: https://github.com/spree/spree/releases/tag/v5.4.0.beta5
1659
+ changelog_uri: https://github.com/spree/spree/releases/tag/v5.4.0.beta6
1660
1660
  documentation_uri: https://docs.spreecommerce.org/
1661
- source_code_uri: https://github.com/spree/spree/tree/v5.4.0.beta5
1661
+ source_code_uri: https://github.com/spree/spree/tree/v5.4.0.beta6
1662
1662
  post_install_message:
1663
1663
  rdoc_options: []
1664
1664
  require_paths: