spree_core 2.2.11 → 2.2.12
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92b5e846d05190304783fa5e19dd8b0e69c2fc42
|
4
|
+
data.tar.gz: 993fec4f99e61b8a22498f8a331dc2367bde321d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 973fe4de757aaf4d9513120337d2e8f09b74d6583279fd179c00a9947a9f12de5d63a2a5d052dfe58d58500829f0a7febab70c1f9ef461591c50639c978f41be
|
7
|
+
data.tar.gz: 23d1efe8df2ec9095d9f3a8cc11bd8e96db31fc680764fae7ba22cb3444b2e23832ce3acb7d66d765b622972c0d3ec27bead93cc8bb39c17538d03c6e9b7c163
|
@@ -39,14 +39,23 @@ module Spree
|
|
39
39
|
order = options[:order]
|
40
40
|
return unless self.eligible? order
|
41
41
|
|
42
|
+
action_taken = false
|
42
43
|
promotion_action_line_items.each do |item|
|
43
44
|
current_quantity = order.quantity_of(item.variant)
|
44
|
-
if current_quantity < item.quantity
|
45
|
-
order.contents.add(item.variant, item.quantity - current_quantity)
|
45
|
+
if current_quantity < item.quantity && item_available?(item)
|
46
|
+
line_item = order.contents.add(item.variant, item.quantity - current_quantity)
|
47
|
+
action_taken = true if line_item.try(:valid?)
|
46
48
|
end
|
47
49
|
end
|
48
|
-
|
50
|
+
action_taken
|
49
51
|
end
|
52
|
+
|
53
|
+
# Checks that there's enough stock to add the line item to the order
|
54
|
+
def item_available?(item)
|
55
|
+
quantifier = Spree::Stock::Quantifier.new(item.variant)
|
56
|
+
quantifier.can_supply? item.quantity
|
57
|
+
end
|
58
|
+
|
50
59
|
end
|
51
60
|
end
|
52
61
|
end
|
@@ -105,7 +105,8 @@ module Spree
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def adjusted_credits_count(promotable)
|
108
|
-
|
108
|
+
adjustments = promotable.is_a?(Order) ? promotable.all_adjustments : promotable.adjustments
|
109
|
+
credits_count - adjustments.promotion.where(:source_id => actions.pluck(:id)).count
|
109
110
|
end
|
110
111
|
|
111
112
|
def credits
|
data/lib/spree/core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Schofield
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemerchant
|