spree_promo 1.0.4 → 1.0.6
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.
- data/app/models/spree/promotion.rb +5 -0
- data/app/models/spree/promotion/actions/create_adjustment.rb +7 -5
- data/app/models/spree/promotion/actions/create_line_items.rb +4 -1
- data/app/models/spree/promotion_action.rb +2 -0
- data/app/models/spree/promotion_rule.rb +2 -0
- data/app/views/spree/admin/promotions/actions/_create_line_items.html.erb +3 -2
- data/app/views/spree/admin/promotions/rules/_product.html.erb +2 -1
- metadata +9 -9
|
@@ -14,6 +14,11 @@ module Spree
|
|
|
14
14
|
alias_method :actions, :promotion_actions
|
|
15
15
|
accepts_nested_attributes_for :promotion_actions
|
|
16
16
|
|
|
17
|
+
attr_accessible :name, :event_name, :code, :match_policy,
|
|
18
|
+
:path, :advertise, :description, :usage_limit,
|
|
19
|
+
:starts_at, :expires_at, :promotion_rules_attributes,
|
|
20
|
+
:promotion_actions_attributes
|
|
21
|
+
|
|
17
22
|
# TODO: This shouldn't be necessary with :autosave option but nested attribute updating of actions is broken without it
|
|
18
23
|
after_save :save_rules_and_actions
|
|
19
24
|
def save_rules_and_actions
|
|
@@ -21,11 +21,13 @@ module Spree
|
|
|
21
21
|
# set to false if the amount is 0
|
|
22
22
|
def create_adjustment(label, target, calculable, mandatory=false)
|
|
23
23
|
amount = compute_amount(calculable)
|
|
24
|
-
target.adjustments.create(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
target.adjustments.create({
|
|
25
|
+
:amount => amount,
|
|
26
|
+
:source => calculable,
|
|
27
|
+
:originator => self,
|
|
28
|
+
:label => label,
|
|
29
|
+
:mandatory => mandatory
|
|
30
|
+
}, :without_protection => true)
|
|
29
31
|
end
|
|
30
32
|
|
|
31
33
|
# Ensure a negative amount which does not exceed the sum of the order's item_total and ship_total
|
|
@@ -23,7 +23,10 @@ module Spree
|
|
|
23
23
|
value.to_s.split(',').each do |str|
|
|
24
24
|
variant_id, quantity = str.split('x')
|
|
25
25
|
if variant_id && quantity && variant = Variant.find_by_id(variant_id)
|
|
26
|
-
promotion_action_line_items.create(
|
|
26
|
+
promotion_action_line_items.create({
|
|
27
|
+
:variant => variant,
|
|
28
|
+
:quantity => quantity.to_i,
|
|
29
|
+
}, :without_protection => true)
|
|
27
30
|
end
|
|
28
31
|
end
|
|
29
32
|
end
|
|
@@ -6,6 +6,8 @@ module Spree
|
|
|
6
6
|
|
|
7
7
|
scope :of_type, lambda {|t| {:conditions => {:type => t}}}
|
|
8
8
|
|
|
9
|
+
attr_accessible :line_items_string, :calculator_type, :calculator_attributes
|
|
10
|
+
|
|
9
11
|
# This method should be overriden in subclass
|
|
10
12
|
# Updates the state of the order or performs some other action depending on the subclass
|
|
11
13
|
# options will contain the payload from the event that activated the promotion. This will include
|
|
@@ -8,6 +8,8 @@ module Spree
|
|
|
8
8
|
validate :promotion, :presence => true
|
|
9
9
|
validate :unique_per_activator, :on => :create
|
|
10
10
|
|
|
11
|
+
attr_accessible :preferred_operator, :preferred_amount, :product, :product_ids_string, :preferred_match_policy
|
|
12
|
+
|
|
11
13
|
def eligible?(order, options = {})
|
|
12
14
|
raise 'eligible? should be implemented in a sub-class of Promotion::PromotionRule'
|
|
13
15
|
end
|
|
@@ -36,8 +36,9 @@
|
|
|
36
36
|
<%= text_field_tag :add_quantity, 1 %>
|
|
37
37
|
</div>
|
|
38
38
|
<div style="float:left; width:j0%">
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
<button class="add small">
|
|
40
|
+
<span><%= t(:add) %></span>
|
|
41
|
+
</button>
|
|
41
42
|
</div>
|
|
42
43
|
</fieldset>
|
|
43
44
|
</div>
|
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
</p>
|
|
5
5
|
<p class="field products_rule_product_group">
|
|
6
6
|
<label><%= t(:product_group) %><br />
|
|
7
|
-
<%= select_tag "#{param_prefix}[product_group_id]", options_from_collection_for_select(Spree::ProductGroup.all, :id, :name, promotion_rule.product_group_id) %></label>
|
|
7
|
+
<%= select_tag "#{param_prefix}[product_group_id]", options_from_collection_for_select(Spree::ProductGroup.all, :id, :name, promotion_rule.product_group_id), { :include_blank => true } %></label>
|
|
8
8
|
</p>
|
|
9
9
|
<p class="field products_rule_products">
|
|
10
10
|
<label>
|
|
11
11
|
<%= t('product_rule.choose_products') %><br />
|
|
12
12
|
<%= product_picker_field "#{param_prefix}[product_ids_string]", promotion_rule.product_ids_string %>
|
|
13
|
+
</label>
|
|
13
14
|
</p>
|
|
14
15
|
<p>
|
|
15
16
|
<label>
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spree_promo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.6
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,30 +9,30 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-
|
|
12
|
+
date: 2012-07-13 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: spree_core
|
|
16
|
-
requirement: &
|
|
16
|
+
requirement: &70126384777340 !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - =
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
|
-
version: 1.0.
|
|
21
|
+
version: 1.0.6
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements: *
|
|
24
|
+
version_requirements: *70126384777340
|
|
25
25
|
- !ruby/object:Gem::Dependency
|
|
26
26
|
name: spree_auth
|
|
27
|
-
requirement: &
|
|
27
|
+
requirement: &70126384776440 !ruby/object:Gem::Requirement
|
|
28
28
|
none: false
|
|
29
29
|
requirements:
|
|
30
30
|
- - =
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 1.0.
|
|
32
|
+
version: 1.0.6
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
|
-
version_requirements: *
|
|
35
|
+
version_requirements: *70126384776440
|
|
36
36
|
description: Required dependency for Spree
|
|
37
37
|
email: david@spreecommerce.com
|
|
38
38
|
executables: []
|
|
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
133
133
|
version: '0'
|
|
134
134
|
segments:
|
|
135
135
|
- 0
|
|
136
|
-
hash: -
|
|
136
|
+
hash: -3655872745788768709
|
|
137
137
|
requirements:
|
|
138
138
|
- none
|
|
139
139
|
rubyforge_project:
|