dup_spree_promo 1.3.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. data/LICENSE +26 -0
  2. data/app/assets/javascripts/admin/promotions.js +98 -0
  3. data/app/assets/javascripts/admin/spree_promo.js +32 -0
  4. data/app/assets/javascripts/store/spree_promo.js +1 -0
  5. data/app/assets/stylesheets/admin/spree_promo.css +3 -0
  6. data/app/assets/stylesheets/store/spree_promo.css +17 -0
  7. data/app/controllers/spree/admin/promotion_actions_controller.rb +27 -0
  8. data/app/controllers/spree/admin/promotion_rules_controller.rb +32 -0
  9. data/app/controllers/spree/admin/promotions_controller.rb +30 -0
  10. data/app/controllers/spree/checkout_controller_decorator.rb +30 -0
  11. data/app/controllers/spree/content_controller_decorator.rb +13 -0
  12. data/app/controllers/spree/orders_controller_decorator.rb +24 -0
  13. data/app/controllers/spree/store_controller_decorator.rb +55 -0
  14. data/app/helpers/spree/promotion_rules_helper.rb +13 -0
  15. data/app/models/spree/adjustment_decorator.rb +7 -0
  16. data/app/models/spree/calculator/free_shipping.rb +18 -0
  17. data/app/models/spree/calculator/percent_per_item.rb +48 -0
  18. data/app/models/spree/order_decorator.rb +19 -0
  19. data/app/models/spree/order_updater_decorator.rb +14 -0
  20. data/app/models/spree/payment_decorator.rb +5 -0
  21. data/app/models/spree/product_decorator.rb +8 -0
  22. data/app/models/spree/promotion.rb +105 -0
  23. data/app/models/spree/promotion/actions/create_adjustment.rb +48 -0
  24. data/app/models/spree/promotion/actions/create_line_items.rb +23 -0
  25. data/app/models/spree/promotion/rules/first_order.rb +12 -0
  26. data/app/models/spree/promotion/rules/item_total.rb +21 -0
  27. data/app/models/spree/promotion/rules/product.rb +46 -0
  28. data/app/models/spree/promotion/rules/user.rb +24 -0
  29. data/app/models/spree/promotion/rules/user_logged_in.rb +20 -0
  30. data/app/models/spree/promotion_action.rb +19 -0
  31. data/app/models/spree/promotion_action_line_item.rb +8 -0
  32. data/app/models/spree/promotion_rule.rb +25 -0
  33. data/app/overrides/promo_admin_tabs.rb +6 -0
  34. data/app/overrides/promo_cart_coupon_code_field.rb +6 -0
  35. data/app/overrides/promo_coupon_code_field.rb +6 -0
  36. data/app/overrides/promo_product_properties.rb +6 -0
  37. data/app/views/spree/admin/promotion_actions/create.js.erb +12 -0
  38. data/app/views/spree/admin/promotion_actions/destroy.js.erb +1 -0
  39. data/app/views/spree/admin/promotion_rules/create.js.erb +13 -0
  40. data/app/views/spree/admin/promotion_rules/destroy.js.erb +3 -0
  41. data/app/views/spree/admin/promotions/_actions.html.erb +32 -0
  42. data/app/views/spree/admin/promotions/_form.html.erb +56 -0
  43. data/app/views/spree/admin/promotions/_promotion_action.html.erb +11 -0
  44. data/app/views/spree/admin/promotions/_promotion_rule.html.erb +9 -0
  45. data/app/views/spree/admin/promotions/_rules.html.erb +45 -0
  46. data/app/views/spree/admin/promotions/_tab.html.erb +1 -0
  47. data/app/views/spree/admin/promotions/actions/_create_adjustment.html.erb +26 -0
  48. data/app/views/spree/admin/promotions/actions/_create_line_items.html.erb +22 -0
  49. data/app/views/spree/admin/promotions/edit.html.erb +28 -0
  50. data/app/views/spree/admin/promotions/index.html.erb +52 -0
  51. data/app/views/spree/admin/promotions/new.html.erb +16 -0
  52. data/app/views/spree/admin/promotions/rules/_first_order.html.erb +0 -0
  53. data/app/views/spree/admin/promotions/rules/_item_total.html.erb +6 -0
  54. data/app/views/spree/admin/promotions/rules/_landing_page.html.erb +5 -0
  55. data/app/views/spree/admin/promotions/rules/_product.html.erb +9 -0
  56. data/app/views/spree/admin/promotions/rules/_user.html.erb +4 -0
  57. data/app/views/spree/admin/promotions/rules/_user_logged_in.html.erb +0 -0
  58. data/app/views/spree/checkout/_coupon_code_field.html.erb +6 -0
  59. data/app/views/spree/orders/_coupon_code_field.html.erb +7 -0
  60. data/app/views/spree/products/_promotions.html.erb +23 -0
  61. data/config/locales/en.yml +98 -0
  62. data/config/routes.rb +8 -0
  63. data/db/migrate/20120831092359_spree_promo_one_two.rb +45 -0
  64. data/lib/spree/promo.rb +9 -0
  65. data/lib/spree/promo/engine.rb +56 -0
  66. data/lib/spree/promo/environment.rb +9 -0
  67. data/lib/spree_promo.rb +1 -0
  68. metadata +129 -0
@@ -0,0 +1,6 @@
1
+ Deface::Override.new(:virtual_path => "spree/layouts/admin",
2
+ :name => "promo_admin_tabs",
3
+ :insert_bottom => "[data-hook='admin_tabs'], #admin_tabs[data-hook]",
4
+ :text => "<%= tab(:promotions, :url => spree.admin_promotions_path, :icon => 'icon-bullhorn') %>",
5
+ :disabled => false,
6
+ :original => '3e847740dc3e7f924aba1ccb4cb00c7b841649e3')
@@ -0,0 +1,6 @@
1
+ Deface::Override.new(:virtual_path => "spree/orders/edit",
2
+ :name => "promo_cart_coupon_code_field",
3
+ :insert_after => "[data-hook='cart_buttons']",
4
+ :partial => "spree/orders/coupon_code_field",
5
+ :disabled => false,
6
+ :original => "c11d9a1996fb86e992aba19035074cf5f688dea2")
@@ -0,0 +1,6 @@
1
+ Deface::Override.new(:virtual_path => "spree/checkout/_payment",
2
+ :name => "promo_coupon_code_field",
3
+ :replace => "[data-hook='coupon_code_field'], #coupon_code_field[data-hook]",
4
+ :partial => "spree/checkout/coupon_code_field",
5
+ :disabled => false,
6
+ :original => '9c9f7058eb6fd9236a241621ab53b43e1caa1a0b' )
@@ -0,0 +1,6 @@
1
+ Deface::Override.new(:virtual_path => "spree/products/show",
2
+ :name => "promo_product_properties",
3
+ :insert_after => "[data-hook='product_properties'], #product_properties[data-hook]",
4
+ :partial => "spree/products/promotions",
5
+ :disabled => false,
6
+ :original => '21a1d0ddb6ae24042f130d64f0ad4b90e69cd088')
@@ -0,0 +1,12 @@
1
+ $('#actions').append('<%= escape_javascript( render(:partial => 'spree/admin/promotions/promotion_action', :object => @promotion_action) ) %>');
2
+ $('#actions .no-objects-found').hide();
3
+ initProductActions();
4
+
5
+ <% unless Rails.env.test? %>
6
+ $('.type-select.select2').select2();
7
+ <% end %>
8
+
9
+ $('#<%= dom_id @promotion_action %>').hide();
10
+ $('#<%= dom_id @promotion_action %>').fadeIn();
11
+ $('#<%= dom_id @promotion_action %> .tokeninput.products').productPicker();
12
+ $('.product_autocomplete').product_autocomplete();
@@ -0,0 +1 @@
1
+ $('#<%= dom_id @promotion_action %>').fadeOut().remove();
@@ -0,0 +1,13 @@
1
+ $('#rules').append('<%= escape_javascript( render(:partial => 'spree/admin/promotions/promotion_rule', :object => @promotion_rule) ) %>');
2
+ $('#rules .no-objects-found').hide();
3
+
4
+ $('#<%= dom_id @promotion_rule %>').hide();
5
+ $('#<%= dom_id @promotion_rule %>').fadeIn();
6
+ $('#<%= dom_id @promotion_rule %> .tokeninput.products').productPicker();
7
+ $('#<%= dom_id @promotion_rule %> .tokeninput.users').userPicker();
8
+
9
+ $('#promotion_rule_type').html('<%= escape_javascript options_for_promotion_rule_types(@promotion) %>');
10
+
11
+ <% unless Rails.env.test? %>
12
+ $('.select_item_total.select2, .select_product.select2').select2();
13
+ <% end %>
@@ -0,0 +1,3 @@
1
+ $('#<%= dom_id @promotion_rule %>').fadeOut().remove();
2
+
3
+ $('#promotion_rule_type').html('<%= escape_javascript options_for_promotion_rule_types(@promotion) %>');
@@ -0,0 +1,32 @@
1
+ <fieldset id="action_fields" class="eight columns omega no-border-top">
2
+
3
+ <%= form_tag spree.admin_promotion_promotion_actions_path(@promotion), :remote => true, :id => 'new_promotion_action_form' do %>
4
+ <% options = options_for_select( Rails.application.config.spree.promotions.actions.map(&:name).map {|name| [ t("promotion_action_types.#{name.demodulize.underscore}.name"), name] } ) %>
5
+ <fieldset>
6
+ <legend align="center"><%= t(:promotion_actions) %></legend>
7
+ <div class="field">
8
+ <%= label_tag :action_type, t(:add_action_of_type)%>
9
+ <%= select_tag 'action_type', options, :class => 'select2 fullwidth' %>
10
+ </div>
11
+ <div class="filter-actions actions">
12
+ <%= button t(:add), 'icon-plus', :class => 'fullwidth' %>
13
+ </div>
14
+ </fieldset>
15
+ <% end %>
16
+
17
+ <%= form_for @promotion, :url => spree.admin_promotion_path(@promotion), :method => :put do |f| %>
18
+ <div id="actions" class="filter_list">
19
+ <% if @promotion.actions.any? %>
20
+ <%= render :partial => 'promotion_action', :collection => @promotion.actions %>
21
+ <% else %>
22
+ <div class="no-objects-found">
23
+ <%= t(:no_actions_added) %>
24
+ </div>
25
+ <% end %>
26
+ </div>
27
+ <div class="filter-actions actions promotion-update">
28
+ <%= button t(:update), 'icon-refresh' %>
29
+ </div>
30
+ <% end %>
31
+
32
+ </fieldset>
@@ -0,0 +1,56 @@
1
+ <%= render :partial => 'spree/shared/error_messages', :locals => { :target => @promotion } %>
2
+ <div class="row">
3
+ <div id="general_fields" class="alpha thirteen columns">
4
+ <div class="alpha four columns">
5
+ <%= f.field_container :name do %>
6
+ <%= f.label :name %>
7
+ <%= f.text_field :name, :class => 'fullwidth' %>
8
+ <% end %>
9
+
10
+ <%= f.field_container :event_name do %>
11
+ <%= f.label :event_name %>
12
+ <%= f.select :event_name, Spree::Activator.event_names.map{|name| [t("events.#{name}"), name] }, {}, {:class => 'select2 fullwidth'} %>
13
+ <% end %>
14
+
15
+ <%= f.field_container :code do %>
16
+ <%= f.label :code %>
17
+ <%= f.text_field :code, :class => 'fullwidth' %>
18
+ <% end %>
19
+
20
+ <%= f.field_container :path do %>
21
+ <%= f.label :path %>
22
+ <%= f.text_field :path, :class => 'fullwidth' %>
23
+ <% end %>
24
+
25
+ <%= f.field_container :advertise do %>
26
+ <%= f.check_box :advertise %>
27
+ <%= f.label :advertise %>
28
+ <% end %>
29
+ </div>
30
+
31
+ <div class="omega nine columns">
32
+ <%= f.field_container :description do %>
33
+ <%= f.label :description %><br />
34
+ <%= f.text_area :description, :rows => 7, :class => 'fullwidth' %>
35
+ <% end %>
36
+ </div>
37
+ </div>
38
+
39
+ <div id="expiry_fields" class="three columns omega">
40
+ <%= f.field_container :usage_limit do %>
41
+ <%= f.label :usage_limit %><br />
42
+ <%= f.number_field :usage_limit, :min => 0, :class => 'fullwidth' %><br>
43
+ <%= t(:current_promotion_usage, :count => @promotion.credits_count) %>
44
+ <% end %>
45
+
46
+ <div id="starts_at_field" class="field">
47
+ <%= f.label :starts_at %>
48
+ <%= f.text_field :starts_at, :class => 'datepicker datepicker-from fullwidth' %>
49
+ </div>
50
+
51
+ <div id="expires_at_field" class="field">
52
+ <%= f.label :expires_at %>
53
+ <%= f.text_field :expires_at, :class => 'datepicker datepicker-top fullwidth' %>
54
+ </div>
55
+ </div>
56
+ </div>
@@ -0,0 +1,11 @@
1
+ <div class="promotion_action promotion-block <%= promotion_action.type.to_s.demodulize.underscore %>" id="<%= dom_id promotion_action %>">
2
+ <% type_name = promotion_action.class.name.demodulize.underscore %>
3
+ <h6 class="promotion-title"><%= t("promotion_action_types.#{type_name}.description") %></h6>
4
+ <%= link_to_with_icon 'icon-trash', '', spree.admin_promotion_promotion_action_path(@promotion, promotion_action), :remote => true, :method => :delete, :class => 'delete' %>
5
+
6
+ <% param_prefix = "promotion[promotion_actions_attributes][#{promotion_action.id}]" %>
7
+ <%= hidden_field_tag "#{param_prefix}[id]", promotion_action.id %>
8
+
9
+ <%= render :partial => "spree/admin/promotions/actions/#{type_name}",
10
+ :locals => { :promotion_action => promotion_action, :param_prefix => param_prefix } %>
11
+ </div>
@@ -0,0 +1,9 @@
1
+ <div class="promotion_rule promotion-block alpha omega eight columns" id="<%= dom_id promotion_rule %>">
2
+ <% type_name = promotion_rule.class.name.demodulize.underscore %>
3
+ <h6 class='promotion-title <%= 'no-text' if type_name == 'user_logged_in' || type_name == 'first_order'%>'><%= t("promotion_rule_types.#{type_name}.description") %></h6>
4
+ <%= link_to_with_icon 'icon-trash', '', spree.admin_promotion_promotion_rule_path(@promotion, promotion_rule), :remote => true, :method => :delete, :class => 'delete' %>
5
+
6
+ <% param_prefix = "promotion[promotion_rules_attributes][#{promotion_rule.id}]" %>
7
+ <%= hidden_field_tag "#{param_prefix}[id]", promotion_rule.id %>
8
+ <%= render :partial => "spree/admin/promotions/rules/#{type_name}", :locals => { :promotion_rule => promotion_rule, :param_prefix => param_prefix } %>
9
+ </div>
@@ -0,0 +1,45 @@
1
+ <fieldset id="rule_fields" class ="alpha eight columns no-border-bottom no-border-top">
2
+
3
+ <%= form_tag spree.admin_promotion_promotion_rules_path(@promotion), :remote => true, :id => 'new_product_rule_form' do %>
4
+ <fieldset>
5
+ <legend align="center"><%= t(:rules) %></legend>
6
+
7
+ <div class="field">
8
+ <%= label_tag :promotion_rule_type, t(:add_rule_of_type) %>
9
+ <%= select_tag('promotion_rule[type]', options_for_promotion_rule_types(@promotion), :class => 'select2 fullwidth') %>
10
+ </div>
11
+ <div class="filter-actions actions">
12
+ <%= button t(:add), 'icon-plus' %>
13
+ </div>
14
+ </fieldset>
15
+ <% end %>
16
+
17
+
18
+ <%= form_for @promotion, :url => object_url, :method => :put do |f| %>
19
+ <fieldset class="no-border-top">
20
+ <div id="promotion-pilicy-select" class="align-center row">
21
+ <% Spree::Promotion::MATCH_POLICIES.each do |policy| %>
22
+ <div class="alpha four columns">
23
+ <label><%= f.radio_button :match_policy, policy %> <%= t "promotion_form.match_policies.#{policy}" %></label>
24
+ </div>
25
+ <% end %>
26
+ </div>
27
+
28
+ <div id="rules" class="filter_list row">
29
+ <% if @promotion.rules.any? %>
30
+ <%= render :partial => 'promotion_rule', :collection => @promotion.rules, :locals => {} %>
31
+ <% else %>
32
+ <div class="no-objects-found">
33
+ <%= t(:no_rules_added) %>
34
+ </div>
35
+ <% end %>
36
+ </div>
37
+
38
+ <div class="promotion-update filter-actions actions">
39
+ <%= button t(:update), 'icon-refresh' %>
40
+ </div>
41
+ </fieldset>
42
+ <% end %>
43
+
44
+
45
+ </fieldset>
@@ -0,0 +1 @@
1
+ <%= tab(:promotions) %>
@@ -0,0 +1,26 @@
1
+ <div class="calculator-fields row">
2
+
3
+ <div class="field alpha four columns">
4
+ <% field_name = "#{param_prefix}[calculator_type]" %>
5
+ <%= label_tag field_name, t(:calculator) %>
6
+ <%= select_tag field_name,
7
+ options_from_collection_for_select(@calculators, :to_s, :description, promotion_action.calculator.type),
8
+ :class => 'type-select select2 fullwidth' %>
9
+ <% if promotion_action.calculator.respond_to?(:preferences) %>
10
+ <span class="warning info"><%= t(:calculator_settings_warning) %></span>
11
+ <% end %>
12
+ </div>
13
+
14
+ <% unless promotion_action.new_record? %>
15
+ <div class="settings field omega four columns">
16
+ <% promotion_action.calculator.preferences.keys.map do |key| %>
17
+ <% field_name = "#{param_prefix}[calculator_attributes][preferred_#{key}]" %>
18
+ <%= label_tag field_name, t(key.to_s) %>
19
+ <%= preference_field_tag(field_name,
20
+ promotion_action.calculator.get_preference(key),
21
+ :type => promotion_action.calculator.preference_type(key)) %>
22
+ <% end %>
23
+ <%= hidden_field_tag "#{param_prefix}[calculator_attributes][id]", promotion_action.calculator.id %>
24
+ </div>
25
+ <% end %>
26
+ </div>
@@ -0,0 +1,22 @@
1
+ <% promotion_action.promotion_action_line_items.each do |item| %>
2
+ <strong><%= item.quantity %> x <%= item.variant.product.name %></strong>
3
+ <%= item.variant.options_text %>
4
+ <% end %>
5
+
6
+ <% if promotion_action.promotion_action_line_items.empty? %>
7
+ <% line_items = promotion_action.promotion_action_line_items %>
8
+ <% line_items.build %>
9
+
10
+ <% line_items.each_with_index do |line_item, index| %>
11
+ <div class="add-line-item row">
12
+ <div class="field alpha four columns">
13
+ <% line_item_prefix = "#{param_prefix}[promotion_action_line_items_attributes][#{index}]" %>
14
+ <%= hidden_field_tag "#{line_item_prefix}[variant_id]", line_item.variant_id, :class => "variant_autocomplete fullwidth" %>
15
+ <div class='options_placeholder'></div>
16
+ </div>
17
+ <div class="field omega four columns">
18
+ <%= number_field_tag "#{line_item_prefix}[quantity]", line_item.quantity, :min => 1, :class => 'fullwidth' %>
19
+ </div>
20
+ </div>
21
+ <% end %>
22
+ <% end %>
@@ -0,0 +1,28 @@
1
+ <% content_for :page_title do %>
2
+ <%= t(:editing_promotion) %>
3
+ <% end %>
4
+
5
+ <% content_for :page_actions do %>
6
+ <li>
7
+ <%= button_link_to t(:back_to_promotions_list), admin_promotions_path, :icon => 'icon-arrow-left' %>
8
+ </li>
9
+ <% end %>
10
+
11
+ <%= form_for @promotion, :url => object_url, :method => :put do |f| %>
12
+ <fieldset class="no-border-top">
13
+ <%= render :partial => 'form', :locals => { :f => f } %>
14
+ <%= render :partial => 'spree/admin/shared/edit_resource_links' %>
15
+ </fieldset>
16
+ <% end %>
17
+
18
+ <div id="promotion-filters" class="row">
19
+ <div id="rules_container" class="alpha eight columns">
20
+ <%= render :partial => 'rules' %>
21
+ </div>
22
+
23
+ <div id="actions_container" class="omega eight columns">
24
+ <%= render :partial => 'actions' %>
25
+ </div>
26
+ </div>
27
+
28
+ <%= render :partial => "spree/admin/variants/autocomplete", :formats => [:js] %>
@@ -0,0 +1,52 @@
1
+ <% content_for :page_title do %>
2
+ <%= t(:promotions) %>
3
+ <% end %>
4
+
5
+ <% content_for :page_actions do %>
6
+ <li>
7
+ <%= button_link_to t(:new_promotion), spree.new_admin_promotion_path, :icon => 'icon-plus' %>
8
+ </li>
9
+ <% end %>
10
+
11
+ <% unless @promotions.any? %>
12
+ <div class="no-objects-found">
13
+ <%= t(:no_promotions_found) %>.
14
+ <%= link_to t(:add_one), spree.new_admin_promotion_path %>!
15
+ </div>
16
+ <% else %>
17
+ <table class="index">
18
+ <colgroup>
19
+ <col style="width: 20%">
20
+ <col style="width: 10%">
21
+ <col style="width: 35%">
22
+ <col style="width: 10%">
23
+ <col style="width: 15%">
24
+ <col style="width: 10%">
25
+ </colgroup>
26
+ <thead>
27
+ <tr>
28
+ <th><%= t(:name) %></th>
29
+ <th><%= t(:code) %></th>
30
+ <th><%= t(:description) %></th>
31
+ <th><%= t(:usage_limit) %></th>
32
+ <th><%= t(:expiration) %></th>
33
+ <th class="actions"></th>
34
+ </tr>
35
+ </thead>
36
+ <tbody>
37
+ <% @promotions.each do |promotion| %>
38
+ <tr id="<%= spree_dom_id promotion %>" class="<%= cycle('odd', 'even')%>">
39
+ <td><%= promotion.name %></td>
40
+ <td class="align-center"><%= promotion.code %></td>
41
+ <td><%= promotion.description %></td>
42
+ <td class="align-center"><%= promotion.usage_limit %></td>
43
+ <td class="align-center"><%= promotion.expires_at.to_date.to_s(:short_date) if promotion.expires_at %></td>
44
+ <td class="actions">
45
+ <%= link_to_edit promotion, :no_text => true %>
46
+ <%= link_to_delete promotion, :no_text => true %>
47
+ </td>
48
+ </tr>
49
+ <% end %>
50
+ </tbody>
51
+ </table>
52
+ <% end %>
@@ -0,0 +1,16 @@
1
+ <% content_for :page_title do %>
2
+ <%= t(:new_promotion) %>
3
+ <% end %>
4
+
5
+ <% content_for :page_actions do %>
6
+ <li>
7
+ <%= button_link_to t(:back_to_promotions_list), spree.admin_promotions_path, :icon => 'icon-arrow-left' %>
8
+ </li>
9
+ <% end %>
10
+
11
+ <%= form_for :promotion, :url => collection_url do |f| %>
12
+ <fieldset class="no-border-top">
13
+ <%= render :partial => 'form', :locals => { :f => f } %>
14
+ <%= render :partial => 'spree/admin/shared/new_resource_links' %>
15
+ </fieldset>
16
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <div class="field alpha four columns">
2
+ <%= 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), {:class => 'select2 select_item_total fullwidth'} %>
3
+ </div>
4
+ <div class="field omega four columns">
5
+ <%= text_field_tag "#{param_prefix}[preferred_amount]", promotion_rule.preferred_amount, :class => 'fullwidth' %>
6
+ </div>
@@ -0,0 +1,5 @@
1
+ <div class="field alpha omega eight columns">
2
+ <label for="<%= "#{param_prefix}_preferred_path" %>"><%= t('promotion_rule_types.landing_page.description') %>:</label>
3
+ <%= text_field_tag "#{param_prefix}[preferred_path]", promotion_rule.preferred_path, :class => 'fullwidth' %>
4
+ <span class="info"><%= t('landing_page_rule.must_have_visited_path') %></span>
5
+ </div>
@@ -0,0 +1,9 @@
1
+ <div class="field alpha omega eight columns products_rule_products">
2
+ <%= label_tag t('product_rule.choose_products') %>
3
+ <%= product_picker_field "#{param_prefix}[product_ids_string]", promotion_rule.product_ids_string %>
4
+ </div>
5
+ <div class="field alpha omega eight columns">
6
+ <label>
7
+ <%= 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), {:class => 'select_product select2'})).html_safe %>
8
+ </label>
9
+ </div>
@@ -0,0 +1,4 @@
1
+ <div class="field alpha omega eight columns">
2
+ <label><%= t('user_rule.choose_users') %></label><br>
3
+ <input type='hidden' name='<%= param_prefix %>[user_ids_string]' class='user_picker fullwidth' value='<%= promotion_rule.user_ids.join(",") %>'>
4
+ </div>
@@ -0,0 +1,6 @@
1
+ <% if Spree::Promotion.count > 0 %>
2
+ <p class='field' data-hook='coupon_code'>
3
+ <%= form.label :coupon_code %><br />
4
+ <%= form.text_field :coupon_code %>
5
+ </p>
6
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <% if Spree::Promotion.count > 0 %>
2
+ <div class="five columns alpha offset-by-nine coupon-code-field">
3
+ <%= order_form.label :coupon_code %><br />
4
+ <%= order_form.text_field :coupon_code, :size => 10 %>
5
+ <%= order_form.submit I18n.t(:apply) %>
6
+ </div>
7
+ <% end %>
@@ -0,0 +1,23 @@
1
+ <% promotions = @product.possible_promotions %>
2
+ <% if promotions.any? %>
3
+ <div id="promotions">
4
+ <h3><%= t(:promotions) %></h3>
5
+
6
+ <% promotions.each do |promotion| %>
7
+ <div>
8
+ <h4><%= promotion.name %></h4>
9
+ <p><%= promotion.description %></p>
10
+ <% if promotion.products.any? %>
11
+ <ul>
12
+ <% promotion.products.each do |product| %>
13
+ <li><%= link_to product.name, product_path(product) %></li>
14
+ <% end %>
15
+ </ul>
16
+ <% end %>
17
+ </div>
18
+ <% end %>
19
+
20
+ </div>
21
+ <% end %>
22
+
23
+