spree_promo 0.70.7 → 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +2 -2
- data/app/assets/javascripts/admin/promotions.js +3 -23
- data/app/controllers/spree/admin/promotion_actions_controller.rb +27 -0
- data/app/controllers/spree/admin/promotion_rules_controller.rb +26 -0
- data/app/controllers/spree/admin/promotions_controller.rb +24 -0
- data/app/controllers/spree/checkout_controller_decorator.rb +39 -0
- data/app/controllers/{content_controller_decorator.rb → spree/content_controller_decorator.rb} +4 -2
- data/app/controllers/{orders_controller_decorator.rb → spree/orders_controller_decorator.rb} +1 -3
- data/app/models/{adjustment_decorator.rb → spree/adjustment_decorator.rb} +1 -1
- data/app/models/spree/calculator/free_shipping.rb +18 -0
- data/app/models/{order_decorator.rb → spree/order_decorator.rb} +5 -4
- data/app/models/{product_decorator.rb → spree/product_decorator.rb} +3 -3
- data/app/models/spree/product_group_decorator.rb +3 -0
- data/app/models/spree/promotion/actions/create_adjustment.rb +33 -0
- data/app/models/spree/promotion/actions/create_line_items.rb +28 -0
- data/app/models/spree/promotion/rules/first_order.rb +7 -0
- data/app/models/spree/promotion/rules/item_total.rb +14 -0
- data/app/models/spree/promotion/rules/landing_page.rb +16 -0
- data/app/models/spree/promotion/rules/product.rb +40 -0
- data/app/models/spree/promotion/rules/user.rb +18 -0
- data/app/models/spree/promotion/rules/user_logged_in.rb +15 -0
- data/app/models/spree/promotion.rb +131 -0
- data/app/models/spree/promotion_action.rb +17 -0
- data/app/models/spree/promotion_action_line_item.rb +6 -0
- data/app/models/spree/promotion_rule.rb +12 -0
- data/app/overrides/promo_admin_tabs.rb +2 -2
- data/app/overrides/promo_coupon_code_field.rb +2 -2
- data/app/overrides/promo_product_properties.rb +2 -2
- data/app/views/{admin → spree/admin}/promotion_actions/create.js.erb +1 -1
- data/app/views/{admin → spree/admin}/promotion_actions/destroy.js.erb +0 -0
- data/app/views/{admin → spree/admin}/promotion_rules/create.js.erb +1 -1
- data/app/views/{admin → spree/admin}/promotion_rules/destroy.js.erb +0 -0
- data/app/views/{admin → spree/admin}/promotions/_actions.html.erb +5 -5
- data/app/views/{admin → spree/admin}/promotions/_form.html.erb +11 -11
- data/app/views/{admin → spree/admin}/promotions/_promotion_action.html.erb +2 -2
- data/app/views/{admin → spree/admin}/promotions/_promotion_rule.html.erb +2 -2
- data/app/views/{admin → spree/admin}/promotions/_rules.html.erb +2 -2
- data/app/views/{admin → spree/admin}/promotions/_tab.html.erb +0 -0
- data/app/views/{admin → spree/admin}/promotions/actions/_create_adjustment.html.erb +1 -1
- data/app/views/{admin → spree/admin}/promotions/actions/_create_line_items.html.erb +1 -0
- data/app/views/{admin → spree/admin}/promotions/actions/_give_store_credit.html.erb +1 -1
- data/app/views/{admin → spree/admin}/promotions/edit.html.erb +3 -3
- data/app/views/{admin → spree/admin}/promotions/index.html.erb +2 -2
- data/app/views/{admin → spree/admin}/promotions/new.html.erb +1 -1
- data/app/views/{admin → spree/admin}/promotions/rules/_first_order.html.erb +0 -0
- data/app/views/{admin → spree/admin}/promotions/rules/_item_total.html.erb +1 -1
- data/app/views/{admin → spree/admin}/promotions/rules/_landing_page.html.erb +0 -0
- data/app/views/{admin → spree/admin}/promotions/rules/_product.html.erb +2 -2
- data/app/views/{admin → spree/admin}/promotions/rules/_user.html.erb +0 -0
- data/app/views/{admin → spree/admin}/promotions/rules/_user_logged_in.html.erb +0 -0
- data/app/views/{checkout → spree/checkout}/_coupon_code_field.html.erb +1 -1
- data/app/views/{products → spree/products}/_promotions.html.erb +0 -0
- data/config/locales/en.yml +7 -0
- data/config/routes.rb +1 -1
- data/db/migrate/20100419190933_rename_coupons_to_promotions.rb +4 -4
- data/db/migrate/20100426100726_create_promotion_rules.rb +4 -4
- data/db/migrate/20100501084722_match_policy_for_promotions.rb +3 -7
- data/db/migrate/20100501095202_create_promotion_rules_users.rb +3 -3
- data/db/migrate/20100502163939_name_for_promotions.rb +3 -7
- data/db/migrate/20100923095305_update_calculable_type_for_promotions.rb +4 -4
- data/db/migrate/20101026184833_migrate_adjustments.rb +4 -4
- data/db/migrate/20110331094351_promotion_changes_to_subclass_of_activator.rb +13 -13
- data/db/migrate/20110404123358_create_promotion_actions.rb +2 -6
- data/db/migrate/20110601202923_create_promotion_action_line_items.rb +4 -6
- data/db/migrate/20111013155037_namespace_promo_tables.rb +9 -0
- data/lib/spree/promo/engine.rb +59 -0
- data/lib/spree/promo/environment.rb +1 -1
- data/lib/spree/promo.rb +10 -0
- data/lib/spree_promo.rb +1 -71
- metadata +77 -72
- data/app/controllers/admin/promotion_actions_controller.rb +0 -28
- data/app/controllers/admin/promotion_rules_controller.rb +0 -26
- data/app/controllers/admin/promotions_controller.rb +0 -21
- data/app/controllers/checkout_controller_decorator.rb +0 -13
- data/app/models/calculator/free_shipping.rb +0 -19
- data/app/models/pending_promotion.rb +0 -4
- data/app/models/product_group_decorator.rb +0 -3
- data/app/models/promotion/actions/create_adjustment.rb +0 -28
- data/app/models/promotion/actions/create_line_items.rb +0 -29
- data/app/models/promotion/rules/first_order.rb +0 -7
- data/app/models/promotion/rules/item_total.rb +0 -13
- data/app/models/promotion/rules/landing_page.rb +0 -17
- data/app/models/promotion/rules/product.rb +0 -40
- data/app/models/promotion/rules/user.rb +0 -17
- data/app/models/promotion/rules/user_logged_in.rb +0 -13
- data/app/models/promotion.rb +0 -97
- data/app/models/promotion_action.rb +0 -17
- data/app/models/promotion_action_line_item.rb +0 -6
- data/app/models/promotion_rule.rb +0 -11
- data/app/models/user_decorator.rb +0 -4
- data/config/cucumber.yml +0 -10
- data/db/migrate/20120119024708_create_pending_promotions.rb +0 -11
- data/lib/tasks/promotions.rake +0 -11
- data/lib/tasks/promotions_extension_tasks.rake +0 -17
@@ -1,4 +1,4 @@
|
|
1
|
-
$('#actions_container').html('<%= escape_javascript( render(:partial => 'admin/promotions/actions') ) %>');
|
1
|
+
$('#actions_container').html('<%= escape_javascript( render(:partial => 'spree/admin/promotions/actions') ) %>');
|
2
2
|
initProductActions();
|
3
3
|
|
4
4
|
$('#<%= dom_id @promotion_action %>').hide();
|
File without changes
|
@@ -1,4 +1,4 @@
|
|
1
|
-
$('#rules').append('<%= escape_javascript( render(:partial => 'admin/promotions/promotion_rule', :object => @promotion_rule) ) %>');
|
1
|
+
$('#rules').append('<%= escape_javascript( render(:partial => 'spree/admin/promotions/promotion_rule', :object => @promotion_rule) ) %>');
|
2
2
|
$('#<%= dom_id @promotion_rule %>').hide();
|
3
3
|
$('#<%= dom_id @promotion_rule %>').fadeIn();
|
4
4
|
initProductRuleSourceField();
|
File without changes
|
@@ -1,13 +1,13 @@
|
|
1
1
|
<fieldset id="action_fields">
|
2
2
|
<legend><%= t(:promotion_actions) %></legend>
|
3
3
|
|
4
|
-
<%= form_for @promotion, :url => admin_promotion_path(@promotion), :html => { :method => :put } do |f| %>
|
4
|
+
<%= form_for @promotion, :url => spree.admin_promotion_path(@promotion), :html => { :method => :put } do |f| %>
|
5
5
|
<div id="actions" class="filter_list">
|
6
6
|
<% if @promotion.actions.any? %>
|
7
7
|
<%#= render :partial => 'promotion_action', :collection => @promotion.actions, :locals => {:f => f} %>
|
8
8
|
|
9
9
|
<%= f.fields_for :promotion_actions do |action_form| %>
|
10
|
-
<%= render 'admin/promotions/promotion_action', :action_form => action_form %>
|
10
|
+
<%= render :partial => 'spree/admin/promotions/promotion_action', :locals => { :action_form => action_form } %>
|
11
11
|
<% end %>
|
12
12
|
|
13
13
|
<% else %>
|
@@ -19,11 +19,11 @@
|
|
19
19
|
</p>
|
20
20
|
<% end %>
|
21
21
|
|
22
|
-
<%= form_tag admin_promotion_promotion_actions_path(@promotion), :remote => true, :id => 'new_promotion_action_form' do
|
22
|
+
<%= form_tag spree.admin_promotion_promotion_actions_path(@promotion), :remote => true, :id => 'new_promotion_action_form' do %>
|
23
23
|
<% options = options_for_select( Rails.application.config.spree.promotions.actions.map(&:name).map {|name| [ t("promotion_action_types.#{name.demodulize.underscore}.name"), name] } ) %>
|
24
24
|
<p>
|
25
|
-
<%= label_tag :
|
26
|
-
<%= select_tag '
|
25
|
+
<%= label_tag :action_type, t(:add_action_of_type) %>
|
26
|
+
<%= select_tag 'action_type', options %>
|
27
27
|
<%= submit_tag t(:add) %>
|
28
28
|
</p>
|
29
29
|
<% end %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= render 'shared/error_messages', :target => @promotion %>
|
1
|
+
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @promotion } %>
|
2
2
|
<fieldset id="general_fields">
|
3
3
|
<legend><%= t(:general) %></legend>
|
4
4
|
<%= f.field_container :name do %>
|
@@ -8,22 +8,22 @@
|
|
8
8
|
|
9
9
|
<%= f.field_container :event_name do %>
|
10
10
|
<%= f.label :event_name, t(:event) %><br />
|
11
|
-
<%= f.select :event_name, Activator.event_names.map{|name| [t("events.#{name}"), name] } %>
|
11
|
+
<%= f.select :event_name, Spree::Activator.event_names.map{|name| [t("events.#{name}"), name] } %>
|
12
12
|
<% end %>
|
13
13
|
|
14
|
-
<%= f.field_container :
|
15
|
-
<%= f.label :
|
16
|
-
<%= f.text_field :
|
14
|
+
<%= f.field_container :code do %>
|
15
|
+
<%= f.label :code, t(:code) %><br />
|
16
|
+
<%= f.text_field :code %>
|
17
17
|
<% end %>
|
18
18
|
|
19
19
|
<%= f.field_container :description do %>
|
20
20
|
<%= f.label :description %><br />
|
21
|
-
<%= f.text_area :description, :style =>
|
21
|
+
<%= f.text_area :description, :style => 'height:50px;' %>
|
22
22
|
<% end %>
|
23
23
|
|
24
|
-
<%= f.field_container :
|
25
|
-
<%= f.check_box :
|
26
|
-
<%= f.label :
|
24
|
+
<%= f.field_container :advertise do %>
|
25
|
+
<%= f.check_box :advertise %>
|
26
|
+
<%= f.label :advertise, t(:advertise) %>
|
27
27
|
<% end %>
|
28
28
|
|
29
29
|
</fieldset>
|
@@ -31,8 +31,8 @@
|
|
31
31
|
<fieldset id="expiry_fields">
|
32
32
|
<legend><%= t(:expiry) %></legend>
|
33
33
|
<p>
|
34
|
-
<%= f.label :
|
35
|
-
<%= f.text_field :
|
34
|
+
<%= f.label :usage_limit, t(:usage_limit) %><br />
|
35
|
+
<%= f.text_field :usage_limit %>
|
36
36
|
</p>
|
37
37
|
|
38
38
|
<p id="starts_at_field">
|
@@ -1,12 +1,12 @@
|
|
1
1
|
<% promotion_action = action_form.object %>
|
2
2
|
<div class="promotion_action <%= promotion_action.type.demodulize.underscore %>" id="<%= dom_id promotion_action %>">
|
3
3
|
<span class="delete">
|
4
|
-
<%= link_to_with_icon 'cross', '', admin_promotion_promotion_action_path(@promotion, promotion_action), :remote => true, :method =>
|
4
|
+
<%= link_to_with_icon 'cross', '', spree.admin_promotion_promotion_action_path(@promotion, promotion_action), :remote => true, :method => :delete %>
|
5
5
|
</span>
|
6
6
|
<% type_name = promotion_action.class.name.demodulize.underscore %>
|
7
7
|
<% param_prefix = "promotion[promotion_actions_attributes][#{promotion_action.id}]" %>
|
8
8
|
<%#= hidden_field_tag "#{param_prefix}[id]", promotion_action.id %>
|
9
9
|
<p><%= t("promotion_action_types.#{type_name}.description") %></p>
|
10
10
|
|
11
|
-
<%= render "admin/promotions/actions/#{type_name}", :action_form => action_form, :promotion_action => promotion_action, :param_prefix => param_prefix %>
|
11
|
+
<%= render :partial => "spree/admin/promotions/actions/#{type_name}", :locals => { :action_form => action_form, :promotion_action => promotion_action, :param_prefix => param_prefix } %>
|
12
12
|
</div>
|
@@ -1,8 +1,8 @@
|
|
1
1
|
<div class="promotion_rule" id="<%= dom_id promotion_rule %>">
|
2
|
-
<span class="delete"><%= link_to_with_icon 'cross', '', admin_promotion_promotion_rule_path(@promotion, promotion_rule), :remote => true, :method =>
|
2
|
+
<span class="delete"><%= link_to_with_icon 'cross', '', spree.admin_promotion_promotion_rule_path(@promotion, promotion_rule), :remote => true, :method => :delete %></span>
|
3
3
|
<% type_name = promotion_rule.class.name.demodulize.underscore %>
|
4
4
|
<% param_prefix = "promotion[promotion_rules_attributes][#{promotion_rule.id}]" %>
|
5
5
|
<%= hidden_field_tag "#{param_prefix}[id]", promotion_rule.id %>
|
6
6
|
<p><%= t("promotion_rule_types.#{type_name}.description") %></p>
|
7
|
-
<%= render "admin/promotions/rules/#{type_name}", :promotion_rule => promotion_rule, :param_prefix => param_prefix %>
|
7
|
+
<%= render :partial => "spree/admin/promotions/rules/#{type_name}", :locals => { :promotion_rule => promotion_rule, :param_prefix => param_prefix } %>
|
8
8
|
</div>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
<%= form_for @promotion, :url => object_url, :html => { :method => :put } do |f| %>
|
5
5
|
<p>
|
6
|
-
<% Promotion::MATCH_POLICIES.each do |policy| %>
|
6
|
+
<% Spree::Promotion::MATCH_POLICIES.each do |policy| %>
|
7
7
|
<label><%= f.radio_button :preferred_match_policy, policy %> <%= t "promotion_form.match_policies.#{policy}" %></label>
|
8
8
|
<% end %>
|
9
9
|
</p>
|
@@ -19,7 +19,7 @@
|
|
19
19
|
</p>
|
20
20
|
<% end %>
|
21
21
|
|
22
|
-
<%= form_tag admin_promotion_promotion_rules_path(@promotion), :remote => true,
|
22
|
+
<%= form_tag spree.admin_promotion_promotion_rules_path(@promotion), :remote => true,
|
23
23
|
:id => 'new_product_rule_form' do %>
|
24
24
|
<% options = options_for_select( Rails.application.config.spree.promotions.rules.map(&:name).map {|name| [ t("promotion_rule_types.#{name.demodulize.underscore}.name"), name] } ) %>
|
25
25
|
<p>
|
File without changes
|
@@ -4,7 +4,7 @@
|
|
4
4
|
<%= action_form.label :calculator_type, t(:calculator) %>
|
5
5
|
<%= action_form.collection_select :calculator_type, @calculators, :to_s, :description, {}, {:class => 'type-select'} %>
|
6
6
|
<% if promotion_action.calculator.respond_to?(:preferences) %>
|
7
|
-
<span class="warning"><%= t(:calculator_settings_warning)%></span>
|
7
|
+
<span class="warning"><%= t(:calculator_settings_warning) %></span>
|
8
8
|
<% end %>
|
9
9
|
</p>
|
10
10
|
|
@@ -27,6 +27,7 @@
|
|
27
27
|
<div style="float:left; width:50%; margin-right:5%;">
|
28
28
|
<%= label_tag :add_product_name, t(:name_or_sku) %>
|
29
29
|
<%= text_field_tag :add_product_name, nil, :class => 'fullwidth' %>
|
30
|
+
<%= hidden_field_tag :add_variant_id %>
|
30
31
|
<%= hidden_field_tag :add_line_item_variant_id %>
|
31
32
|
</div>
|
32
33
|
<div style="float:left; width:10%; margin-right:5%;">
|
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
<%= form_for @promotion, :url => object_url, :html => { :method => :put } do |f| %>
|
4
4
|
<%= render :partial => 'form', :locals => { :f => f } %>
|
5
|
-
<%= render 'admin/shared/edit_resource_links' %>
|
5
|
+
<%= render :partial => 'spree/admin/shared/edit_resource_links' %>
|
6
6
|
<% end %>
|
7
7
|
|
8
|
-
<%= render 'rules' %>
|
8
|
+
<%= render :partial => 'rules' %>
|
9
9
|
|
10
10
|
<div id="actions_container">
|
11
|
-
<%= render 'actions' %>
|
11
|
+
<%= render :partial => 'actions' %>
|
12
12
|
</div>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<div class='toolbar'>
|
2
2
|
<ul class='actions'>
|
3
3
|
<li>
|
4
|
-
<%= button_link_to t(:new_promotion),
|
4
|
+
<%= button_link_to t(:new_promotion), spree.new_admin_promotion_path, :icon => 'add' %>
|
5
5
|
</li>
|
6
6
|
</ul>
|
7
7
|
<br class="clear" />
|
@@ -35,4 +35,4 @@
|
|
35
35
|
</tr>
|
36
36
|
<% end %>
|
37
37
|
</tbody>
|
38
|
-
</table>
|
38
|
+
</table>
|
File without changes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<p class="field">
|
2
2
|
<label for="<%= "#{param_prefix}_preferred_amount" %>">
|
3
3
|
<%= t('promotion_rule_types.item_total.description') %>
|
4
|
-
<%= select_tag "#{param_prefix}[preferred_operator]", options_for_select(Promotion::Rules::ItemTotal::OPERATORS.map{|o| [t("item_total_rule.operators.#{o}"),o]}, promotion_rule.preferred_operator) %>
|
4
|
+
<%= select_tag "#{param_prefix}[preferred_operator]", options_for_select(Spree::Promotion::Rules::ItemTotal::OPERATORS.map{|o| [t("item_total_rule.operators.#{o}"),o]}, promotion_rule.preferred_operator) %>
|
5
5
|
<%= text_field_tag "#{param_prefix}[preferred_amount]", promotion_rule.preferred_amount, :size => 10 %>
|
6
6
|
</label>
|
7
7
|
</p>
|
File without changes
|
@@ -4,7 +4,7 @@
|
|
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(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) %></label>
|
8
8
|
</p>
|
9
9
|
<p class="field products_rule_products">
|
10
10
|
<label>
|
@@ -13,6 +13,6 @@
|
|
13
13
|
</p>
|
14
14
|
<p>
|
15
15
|
<label>
|
16
|
-
<%= t('product_rule.label', :select => select_tag("#{param_prefix}[preferred_match_policy]", options_for_select(Promotion::Rules::Product::MATCH_POLICIES.map{|s| [t("product_rule.match_#{s}"),s] }, promotion_rule.preferred_match_policy))).html_safe %>
|
16
|
+
<%= t('product_rule.label', :select => select_tag("#{param_prefix}[preferred_match_policy]", options_for_select(Spree::Promotion::Rules::Product::MATCH_POLICIES.map{|s| [t("product_rule.match_#{s}"),s] }, promotion_rule.preferred_match_policy))).html_safe %>
|
17
17
|
</label>
|
18
18
|
</p>
|
File without changes
|
File without changes
|
File without changes
|
data/config/locales/en.yml
CHANGED
@@ -15,10 +15,15 @@ en:
|
|
15
15
|
coupon: Coupon
|
16
16
|
coupon_code: Coupon code
|
17
17
|
editing_promotion: Editing Promotion
|
18
|
+
events:
|
19
|
+
spree:
|
20
|
+
checkout:
|
21
|
+
coupon_code_added: Coupon code added
|
18
22
|
expiry: Expiry
|
19
23
|
free_shipping: Free Shipping
|
20
24
|
new_promotion: New Promotion
|
21
25
|
no_rules_added: No rules added
|
26
|
+
promotion_not_found: The coupon code you entered doesn't exist. Please try again.
|
22
27
|
promotion: Promotion
|
23
28
|
promotion_actions: Actions
|
24
29
|
promotions: Promotions
|
@@ -65,6 +70,8 @@ en:
|
|
65
70
|
group: From product group
|
66
71
|
manual: Manually choose
|
67
72
|
rules: Rules
|
73
|
+
spree/order:
|
74
|
+
coupon_code: Coupon Code
|
68
75
|
user_rule:
|
69
76
|
choose_users: Choose users
|
70
77
|
item_total_rule:
|
data/config/routes.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
class RenameCouponsToPromotions < ActiveRecord::Migration
|
2
|
-
def
|
3
|
-
|
2
|
+
def up
|
3
|
+
drop_table :promotions if table_exists?(:promotions)
|
4
4
|
rename_table :coupons, :promotions
|
5
5
|
end
|
6
6
|
|
7
|
-
def
|
7
|
+
def down
|
8
8
|
rename_table :promotions, :coupons
|
9
9
|
end
|
10
|
-
end
|
10
|
+
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
class CreatePromotionRules < ActiveRecord::Migration
|
2
|
-
def
|
2
|
+
def up
|
3
3
|
create_table :promotion_rules do |t|
|
4
4
|
t.references :promotion, :user, :product_group
|
5
|
-
t.timestamps
|
6
5
|
t.string :type
|
6
|
+
|
7
|
+
t.timestamps
|
7
8
|
end
|
8
9
|
add_index :promotion_rules, :product_group_id
|
9
10
|
add_index :promotion_rules, :user_id
|
@@ -14,10 +15,9 @@ class CreatePromotionRules < ActiveRecord::Migration
|
|
14
15
|
remove_column :products_promotion_rules, :id
|
15
16
|
add_index :products_promotion_rules, :product_id
|
16
17
|
add_index :products_promotion_rules, :promotion_rule_id
|
17
|
-
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
20
|
+
def down
|
21
21
|
drop_table :promotion_rules
|
22
22
|
drop_table :products_promotion_rules
|
23
23
|
end
|
@@ -1,9 +1,5 @@
|
|
1
1
|
class MatchPolicyForPromotions < ActiveRecord::Migration
|
2
|
-
def
|
3
|
-
add_column
|
2
|
+
def change
|
3
|
+
add_column :promotions, :match_policy, :string, :default => 'all'
|
4
4
|
end
|
5
|
-
|
6
|
-
def self.down
|
7
|
-
remove_column "promotions", "match_policy"
|
8
|
-
end
|
9
|
-
end
|
5
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class CreatePromotionRulesUsers < ActiveRecord::Migration
|
2
|
-
def
|
2
|
+
def up
|
3
3
|
create_table :promotion_rules_users do |t|
|
4
4
|
t.integer :user_id, :promotion_rule_id
|
5
5
|
end
|
@@ -8,7 +8,7 @@ class CreatePromotionRulesUsers < ActiveRecord::Migration
|
|
8
8
|
add_index :promotion_rules_users, :promotion_rule_id
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
11
|
+
def down
|
12
12
|
drop_table :promotion_rules_users
|
13
13
|
end
|
14
|
-
end
|
14
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
class UpdateCalculableTypeForPromotions < ActiveRecord::Migration
|
2
|
-
def
|
3
|
-
|
2
|
+
def up
|
3
|
+
execute "UPDATE spree_calculators SET calculable_type = 'Promotion' WHERE calculable_type = 'Coupon'"
|
4
4
|
end
|
5
5
|
|
6
|
-
def
|
7
|
-
|
6
|
+
def down
|
7
|
+
execute "UPDATE spree_calculators SET calculable_type = 'Coupon' WHERE calculable_type = 'Promotion'"
|
8
8
|
end
|
9
9
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
class MigrateAdjustments < ActiveRecord::Migration
|
2
|
-
def
|
3
|
-
execute
|
4
|
-
execute
|
2
|
+
def up
|
3
|
+
execute "UPDATE spree_adjustments SET amount = 0.0 WHERE amount IS NULL"
|
4
|
+
execute "UPDATE spree_adjustments SET mandatory = 't' WHERE locked = 't'"
|
5
5
|
end
|
6
6
|
|
7
|
-
def
|
7
|
+
def down
|
8
8
|
end
|
9
9
|
end
|
@@ -1,21 +1,21 @@
|
|
1
1
|
class PromotionChangesToSubclassOfActivator < ActiveRecord::Migration
|
2
|
-
def
|
2
|
+
def up
|
3
3
|
drop_table :promotions
|
4
4
|
rename_column :promotion_rules, :promotion_id, :activator_id
|
5
5
|
end
|
6
6
|
|
7
|
-
def
|
8
|
-
create_table
|
9
|
-
t.string
|
10
|
-
t.string
|
11
|
-
t.string
|
12
|
-
t.integer
|
13
|
-
t.boolean
|
14
|
-
t.datetime
|
15
|
-
t.datetime
|
16
|
-
t.
|
17
|
-
|
18
|
-
t.
|
7
|
+
def down
|
8
|
+
create_table :promotions, :force => true do |t|
|
9
|
+
t.string :name
|
10
|
+
t.string :code
|
11
|
+
t.string :description
|
12
|
+
t.integer :usage_limit
|
13
|
+
t.boolean :combine
|
14
|
+
t.datetime :expires_at
|
15
|
+
t.datetime :starts_at
|
16
|
+
t.string :match_policy, :default => 'all'
|
17
|
+
|
18
|
+
t.timestamps
|
19
19
|
end
|
20
20
|
rename_column :promotion_rules, :activator_id, :promotion_id
|
21
21
|
end
|
@@ -1,13 +1,9 @@
|
|
1
1
|
class CreatePromotionActions < ActiveRecord::Migration
|
2
|
-
def
|
2
|
+
def change
|
3
3
|
create_table :promotion_actions do |t|
|
4
4
|
t.integer :activator_id
|
5
5
|
t.integer :position
|
6
|
-
t.string
|
6
|
+
t.string :type
|
7
7
|
end
|
8
8
|
end
|
9
|
-
|
10
|
-
def self.down
|
11
|
-
drop_table :promotion_actions
|
12
|
-
end
|
13
9
|
end
|
@@ -1,12 +1,10 @@
|
|
1
1
|
class CreatePromotionActionLineItems < ActiveRecord::Migration
|
2
|
-
def
|
3
|
-
create_table
|
2
|
+
def change
|
3
|
+
create_table :promotion_action_line_items do |t|
|
4
4
|
t.integer :promotion_action_id, :variant_id
|
5
5
|
t.integer :quantity, :default => 1
|
6
|
+
t.references :promotion_action
|
7
|
+
t.references :variant
|
6
8
|
end
|
7
9
|
end
|
8
|
-
|
9
|
-
def self.down
|
10
|
-
drop_table "promotion_action_line_items"
|
11
|
-
end
|
12
10
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class NamespacePromoTables < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
rename_table :promotion_actions, :spree_promotion_actions
|
4
|
+
rename_table :promotion_rules, :spree_promotion_rules
|
5
|
+
rename_table :promotion_rules_users, :spree_promotion_rules_users
|
6
|
+
rename_table :promotion_action_line_items, :spree_promotion_action_line_items
|
7
|
+
rename_table :products_promotion_rules, :spree_products_promotion_rules
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Spree
|
2
|
+
module Promo
|
3
|
+
class Engine < Rails::Engine
|
4
|
+
isolate_namespace Spree
|
5
|
+
engine_name 'spree_promo'
|
6
|
+
|
7
|
+
def self.activate
|
8
|
+
Dir.glob(File.join(File.dirname(__FILE__), '../../../app/**/*_decorator*.rb')) do |c|
|
9
|
+
Rails.configuration.cache_classes ? require(c) : load(c)
|
10
|
+
end
|
11
|
+
|
12
|
+
Dir.glob(File.join(File.dirname(__FILE__), '../../../app/overrides/*.rb')) do |c|
|
13
|
+
Rails.configuration.cache_classes ? require(c) : load(c)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Include list of visited paths in notification payload hash
|
17
|
+
Spree::Core::ControllerHelpers::InstanceMethods.class_eval do
|
18
|
+
def default_notification_payload
|
19
|
+
{ :user => current_user, :order => current_order, :visited_paths => session[:visited_paths] }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
25
|
+
config.to_prepare &method(:activate).to_proc
|
26
|
+
|
27
|
+
initializer 'spree.promo.environment', :after => 'spree.environment' do |app|
|
28
|
+
app.config.spree.add_class('promotions')
|
29
|
+
app.config.spree.promotions = Spree::Promo::Environment.new
|
30
|
+
end
|
31
|
+
|
32
|
+
initializer 'spree.promo.register.promotion.calculators' do |app|
|
33
|
+
app.config.spree.calculators.add_class('promotion_actions_create_adjustments')
|
34
|
+
app.config.spree.calculators.promotion_actions_create_adjustments = [
|
35
|
+
Spree::Calculator::FlatPercentItemTotal,
|
36
|
+
Spree::Calculator::FlatRate,
|
37
|
+
Spree::Calculator::FlexiRate,
|
38
|
+
Spree::Calculator::PerItem,
|
39
|
+
Spree::Calculator::FreeShipping
|
40
|
+
]
|
41
|
+
end
|
42
|
+
|
43
|
+
initializer 'spree.promo.register.promotions.rules' do |app|
|
44
|
+
app.config.spree.promotions.rules = [
|
45
|
+
Spree::Promotion::Rules::ItemTotal,
|
46
|
+
Spree::Promotion::Rules::Product,
|
47
|
+
Spree::Promotion::Rules::User,
|
48
|
+
Spree::Promotion::Rules::FirstOrder,
|
49
|
+
Spree::Promotion::Rules::LandingPage,
|
50
|
+
Spree::Promotion::Rules::UserLoggedIn]
|
51
|
+
end
|
52
|
+
|
53
|
+
initializer 'spree.promo.register.promotions.actions' do |app|
|
54
|
+
app.config.spree.promotions.actions = [Spree::Promotion::Actions::CreateAdjustment,
|
55
|
+
Spree::Promotion::Actions::CreateLineItems]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|