solidus_promotions 4.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.eslintrc.json +10 -0
- data/.github/stale.yml +1 -0
- data/MIGRATING.md +184 -0
- data/README.md +122 -0
- data/Rakefile +20 -0
- data/app/assets/config/solidus_promotions/manifest.js +13 -0
- data/app/decorators/models/solidus_promotions/adjustment_decorator.rb +11 -0
- data/app/decorators/models/solidus_promotions/line_item_decorator.rb +27 -0
- data/app/decorators/models/solidus_promotions/order_decorator.rb +42 -0
- data/app/decorators/models/solidus_promotions/order_recalculator_decorator.rb +15 -0
- data/app/decorators/models/solidus_promotions/shipment_decorator.rb +14 -0
- data/app/decorators/models/solidus_promotions/shipping_rate_decorator.rb +29 -0
- data/app/helpers/solidus_promotions/admin/benefits_helper.rb +19 -0
- data/app/helpers/solidus_promotions/admin/conditions_helper.rb +14 -0
- data/app/helpers/solidus_promotions/admin/promotions_helper.rb +15 -0
- data/app/javascript/backend/solidus_promotions/controllers/application.js +9 -0
- data/app/javascript/backend/solidus_promotions/controllers/calculator_tiers_controller.js +37 -0
- data/app/javascript/backend/solidus_promotions/controllers/flash_controller.js +10 -0
- data/app/javascript/backend/solidus_promotions/controllers/index.js +8 -0
- data/app/javascript/backend/solidus_promotions/controllers/product_option_values_controller.js +62 -0
- data/app/javascript/backend/solidus_promotions/web_components/number_with_currency.js +35 -0
- data/app/javascript/backend/solidus_promotions/web_components/option_value_picker.js +52 -0
- data/app/javascript/backend/solidus_promotions/web_components/product_picker.js +7 -0
- data/app/javascript/backend/solidus_promotions/web_components/select_two.js +11 -0
- data/app/javascript/backend/solidus_promotions/web_components/taxon_picker.js +7 -0
- data/app/javascript/backend/solidus_promotions/web_components/user_picker.js +7 -0
- data/app/javascript/backend/solidus_promotions/web_components/variant_picker.js +7 -0
- data/app/javascript/backend/solidus_promotions.js +11 -0
- data/app/jobs/solidus_promotions/promotion_code_batch_job.rb +26 -0
- data/app/mailers/solidus_promotions/promotion_code_batch_mailer.rb +15 -0
- data/app/models/concerns/solidus_promotions/benefits/line_item_benefit.rb +15 -0
- data/app/models/concerns/solidus_promotions/benefits/order_benefit.rb +15 -0
- data/app/models/concerns/solidus_promotions/benefits/shipment_benefit.rb +15 -0
- data/app/models/concerns/solidus_promotions/calculators/promotion_calculator.rb +11 -0
- data/app/models/concerns/solidus_promotions/conditions/line_item_applicable_order_level_condition.rb +23 -0
- data/app/models/concerns/solidus_promotions/conditions/line_item_level_condition.rb +15 -0
- data/app/models/concerns/solidus_promotions/conditions/order_level_condition.rb +15 -0
- data/app/models/concerns/solidus_promotions/conditions/shipment_level_condition.rb +15 -0
- data/app/models/concerns/solidus_promotions/discountable_amount.rb +21 -0
- data/app/models/solidus_promotions/benefit.rb +123 -0
- data/app/models/solidus_promotions/benefits/adjust_line_item.rb +13 -0
- data/app/models/solidus_promotions/benefits/adjust_line_item_quantity_groups.rb +107 -0
- data/app/models/solidus_promotions/benefits/adjust_shipment.rb +13 -0
- data/app/models/solidus_promotions/benefits/create_discounted_item.rb +49 -0
- data/app/models/solidus_promotions/calculators/distributed_amount.rb +31 -0
- data/app/models/solidus_promotions/calculators/flat_rate.rb +23 -0
- data/app/models/solidus_promotions/calculators/flexi_rate.rb +26 -0
- data/app/models/solidus_promotions/calculators/percent.rb +19 -0
- data/app/models/solidus_promotions/calculators/tiered_flat_rate.rb +58 -0
- data/app/models/solidus_promotions/calculators/tiered_percent.rb +68 -0
- data/app/models/solidus_promotions/calculators/tiered_percent_on_eligible_item_quantity.rb +40 -0
- data/app/models/solidus_promotions/condition.rb +61 -0
- data/app/models/solidus_promotions/condition_product.rb +8 -0
- data/app/models/solidus_promotions/condition_store.rb +8 -0
- data/app/models/solidus_promotions/condition_taxon.rb +8 -0
- data/app/models/solidus_promotions/condition_user.rb +8 -0
- data/app/models/solidus_promotions/conditions/discounted_item_total.rb +22 -0
- data/app/models/solidus_promotions/conditions/first_order.rb +31 -0
- data/app/models/solidus_promotions/conditions/first_repeat_purchase_since.rb +31 -0
- data/app/models/solidus_promotions/conditions/item_total.rb +75 -0
- data/app/models/solidus_promotions/conditions/line_item_option_value.rb +37 -0
- data/app/models/solidus_promotions/conditions/line_item_product.rb +56 -0
- data/app/models/solidus_promotions/conditions/line_item_taxon.rb +59 -0
- data/app/models/solidus_promotions/conditions/minimum_quantity.rb +42 -0
- data/app/models/solidus_promotions/conditions/nth_order.rb +40 -0
- data/app/models/solidus_promotions/conditions/one_use_per_user.rb +25 -0
- data/app/models/solidus_promotions/conditions/option_value.rb +28 -0
- data/app/models/solidus_promotions/conditions/product.rb +85 -0
- data/app/models/solidus_promotions/conditions/shipping_method.rb +19 -0
- data/app/models/solidus_promotions/conditions/store.rb +26 -0
- data/app/models/solidus_promotions/conditions/taxon.rb +98 -0
- data/app/models/solidus_promotions/conditions/user.rb +35 -0
- data/app/models/solidus_promotions/conditions/user_logged_in.rb +16 -0
- data/app/models/solidus_promotions/conditions/user_role.rb +42 -0
- data/app/models/solidus_promotions/distributed_amounts_handler.rb +39 -0
- data/app/models/solidus_promotions/eligibility_result.rb +5 -0
- data/app/models/solidus_promotions/eligibility_results.rb +47 -0
- data/app/models/solidus_promotions/item_discount.rb +21 -0
- data/app/models/solidus_promotions/migration_support/order_promotion_syncer.rb +54 -0
- data/app/models/solidus_promotions/order_adjuster/choose_discounts.rb +21 -0
- data/app/models/solidus_promotions/order_adjuster/discount_order.rb +93 -0
- data/app/models/solidus_promotions/order_adjuster/load_promotions.rb +53 -0
- data/app/models/solidus_promotions/order_adjuster/persist_discounted_order.rb +79 -0
- data/app/models/solidus_promotions/order_adjuster.rb +33 -0
- data/app/models/solidus_promotions/order_promotion.rb +23 -0
- data/app/models/solidus_promotions/permission_sets/solidus_promotion_management.rb +15 -0
- data/app/models/solidus_promotions/promotion.rb +163 -0
- data/app/models/solidus_promotions/promotion_advertiser.rb +10 -0
- data/app/models/solidus_promotions/promotion_category.rb +9 -0
- data/app/models/solidus_promotions/promotion_code/batch_builder.rb +73 -0
- data/app/models/solidus_promotions/promotion_code.rb +56 -0
- data/app/models/solidus_promotions/promotion_code_batch.rb +25 -0
- data/app/models/solidus_promotions/promotion_finder.rb +10 -0
- data/app/models/solidus_promotions/promotion_handler/coupon.rb +113 -0
- data/app/models/solidus_promotions/promotion_handler/page.rb +30 -0
- data/app/models/solidus_promotions/shipping_rate_discount.rb +11 -0
- data/app/subscribers/solidus_promotions/order_promotion_subscriber.rb +20 -0
- data/bin/rails +13 -0
- data/config/importmap.rb +14 -0
- data/config/locales/en.yml +376 -0
- data/config/locales/promotion_categories.en.yml +6 -0
- data/config/locales/promotions.en.yml +6 -0
- data/config/routes.rb +38 -0
- data/db/migrate/20230703101637_create_promotions.rb +25 -0
- data/db/migrate/20230703113625_create_promotion_benefits.rb +15 -0
- data/db/migrate/20230703141116_create_promotion_categories.rb +14 -0
- data/db/migrate/20230703143943_create_promotion_conditions.rb +12 -0
- data/db/migrate/20230704083830_add_condition_join_tables.rb +31 -0
- data/db/migrate/20230704102444_create_promotion_codes.rb +11 -0
- data/db/migrate/20230704102656_create_promotion_code_batches.rb +34 -0
- data/db/migrate/20230705171556_create_order_promotions.rb +11 -0
- data/db/migrate/20230725074235_create_shipping_rate_discounts.rb +12 -0
- data/db/migrate/20231011100059_add_db_comments_to_order_promotions.rb +61 -0
- data/db/migrate/20231011120928_add_db_comments_to_condition_taxons.rb +54 -0
- data/db/migrate/20231011131324_add_db_comments_to_conditions.rb +60 -0
- data/db/migrate/20231011142040_add_db_comments_to_condition_users.rb +53 -0
- data/db/migrate/20231011155822_add_db_comments_to_promotions.rb +123 -0
- data/db/migrate/20231011163030_add_db_comments_to_promotion_codes.rb +60 -0
- data/db/migrate/20231011173312_add_db_comments_to_promotion_code_batches.rb +91 -0
- data/db/migrate/20231011184205_add_db_comments_to_condition_stores.rb +53 -0
- data/db/migrate/20231011190222_add_db_comments_to_benefits.rb +61 -0
- data/db/migrate/20231012020928_add_db_comments_to_condition_products.rb +52 -0
- data/db/migrate/20231012120928_add_db_comments_to_promotion_categories.rb +52 -0
- data/db/migrate/20231104135812_add_managed_by_order_benefit_to_line_items.rb +5 -0
- data/lib/components/admin/solidus_admin/orders/show/adjustments/index/source/solidus_promotions_benefit/component.rb +17 -0
- data/lib/components/admin/solidus_promotions/orders/index/component.rb +15 -0
- data/lib/components/admin/solidus_promotions/orders/index/component.yml +3 -0
- data/lib/components/admin/solidus_promotions/promotion_categories/index/component.rb +60 -0
- data/lib/components/admin/solidus_promotions/promotions/index/component.rb +108 -0
- data/lib/components/admin/solidus_promotions/promotions/index/component.yml +10 -0
- data/lib/controllers/admin/solidus_promotions/promotion_categories_controller.rb +29 -0
- data/lib/controllers/admin/solidus_promotions/promotions_controller.rb +46 -0
- data/lib/controllers/backend/solidus_promotions/admin/base_controller.rb +15 -0
- data/lib/controllers/backend/solidus_promotions/admin/benefits_controller.rb +85 -0
- data/lib/controllers/backend/solidus_promotions/admin/conditions_controller.rb +69 -0
- data/lib/controllers/backend/solidus_promotions/admin/promotion_categories_controller.rb +13 -0
- data/lib/controllers/backend/solidus_promotions/admin/promotion_code_batches_controller.rb +42 -0
- data/lib/controllers/backend/solidus_promotions/admin/promotion_codes_controller.rb +58 -0
- data/lib/controllers/backend/solidus_promotions/admin/promotions_controller.rb +65 -0
- data/lib/generators/solidus_promotions/install/install_generator.rb +56 -0
- data/lib/generators/solidus_promotions/install/templates/initializer.rb +6 -0
- data/lib/solidus_promotions/configuration.rb +125 -0
- data/lib/solidus_promotions/engine.rb +115 -0
- data/lib/solidus_promotions/migrate_adjustments.rb +62 -0
- data/lib/solidus_promotions/migrate_order_promotions.rb +73 -0
- data/lib/solidus_promotions/promotion_map.rb +126 -0
- data/lib/solidus_promotions/promotion_migrator.rb +103 -0
- data/lib/solidus_promotions/testing_support/factories/completed_order_with_solidus_promotion_factory.rb +20 -0
- data/lib/solidus_promotions/testing_support/factories/solidus_order_promotion_factory.rb +8 -0
- data/lib/solidus_promotions/testing_support/factories/solidus_promotion_category_factory.rb +7 -0
- data/lib/solidus_promotions/testing_support/factories/solidus_promotion_code_factory.rb +8 -0
- data/lib/solidus_promotions/testing_support/factories/solidus_promotion_factory.rb +65 -0
- data/lib/solidus_promotions/testing_support/factories/solidus_shipping_rate_discount_factory.rb +14 -0
- data/lib/solidus_promotions/testing_support/factory_bot.rb +30 -0
- data/lib/solidus_promotions.rb +37 -0
- data/lib/tasks/solidus_promotions/migrate_adjustments.rake +17 -0
- data/lib/tasks/solidus_promotions/migrate_existing_promotions.rake +12 -0
- data/lib/tasks/solidus_promotions/migrate_order_promotions.rake +17 -0
- data/lib/views/backend/solidus_promotions/admin/benefit_fields/_adjust_line_item.html.erb +6 -0
- data/lib/views/backend/solidus_promotions/admin/benefit_fields/_adjust_line_item_quantity_groups.html.erb +13 -0
- data/lib/views/backend/solidus_promotions/admin/benefit_fields/_adjust_shipment.html.erb +6 -0
- data/lib/views/backend/solidus_promotions/admin/benefit_fields/_calculator_fields.erb +11 -0
- data/lib/views/backend/solidus_promotions/admin/benefit_fields/_create_discounted_item.html.erb +21 -0
- data/lib/views/backend/solidus_promotions/admin/benefits/_benefit.html.erb +50 -0
- data/lib/views/backend/solidus_promotions/admin/benefits/_calculator_select.html.erb +16 -0
- data/lib/views/backend/solidus_promotions/admin/benefits/_form.html.erb +3 -0
- data/lib/views/backend/solidus_promotions/admin/benefits/_new_benefit.html.erb +33 -0
- data/lib/views/backend/solidus_promotions/admin/benefits/_type_select.html.erb +16 -0
- data/lib/views/backend/solidus_promotions/admin/benefits/edit.html.erb +19 -0
- data/lib/views/backend/solidus_promotions/admin/benefits/new.html.erb +1 -0
- data/lib/views/backend/solidus_promotions/admin/calculator_fields/_default_fields.html.erb +6 -0
- data/lib/views/backend/solidus_promotions/admin/calculator_fields/distributed_amount/_fields.html.erb +18 -0
- data/lib/views/backend/solidus_promotions/admin/calculator_fields/flat_rate/_fields.html.erb +6 -0
- data/lib/views/backend/solidus_promotions/admin/calculator_fields/flexi_rate/_fields.html.erb +24 -0
- data/lib/views/backend/solidus_promotions/admin/calculator_fields/percent/_fields.html.erb +6 -0
- data/lib/views/backend/solidus_promotions/admin/calculator_fields/tiered_flat_rate/_fields.html.erb +32 -0
- data/lib/views/backend/solidus_promotions/admin/calculator_fields/tiered_flat_rate/_tier_fields.html.erb +31 -0
- data/lib/views/backend/solidus_promotions/admin/calculator_fields/tiered_percent/_fields.html.erb +47 -0
- data/lib/views/backend/solidus_promotions/admin/calculator_fields/tiered_percent/_tier_fields.html.erb +33 -0
- data/lib/views/backend/solidus_promotions/admin/calculator_fields/tiered_percent_on_eligible_item_quantity/_fields.html.erb +36 -0
- data/lib/views/backend/solidus_promotions/admin/calculator_fields/tiered_percent_on_eligible_item_quantity/_tier_fields.html.erb +35 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_first_order.html.erb +3 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_first_repeat_purchase_since.html.erb +7 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_item_total.html.erb +15 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_line_item_option_value.html.erb +25 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_line_item_product.html.erb +21 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_line_item_taxon.html.erb +17 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_minimum_quantity.html.erb +5 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_nth_order.html.erb +15 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_one_use_per_user.html.erb +3 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_option_value.html.erb +63 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_product.html.erb +27 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_shipping_method.html.erb +10 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_store.html.erb +9 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_taxon.html.erb +27 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_user.html.erb +7 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_user_logged_in.html.erb +3 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/_user_role.html.erb +15 -0
- data/lib/views/backend/solidus_promotions/admin/condition_fields/line_item_option_value/_option_value_fields.html.erb +21 -0
- data/lib/views/backend/solidus_promotions/admin/conditions/_condition.html.erb +26 -0
- data/lib/views/backend/solidus_promotions/admin/conditions/_new_condition.html.erb +26 -0
- data/lib/views/backend/solidus_promotions/admin/conditions/_type_select.html.erb +20 -0
- data/lib/views/backend/solidus_promotions/admin/conditions/new.html.erb +1 -0
- data/lib/views/backend/solidus_promotions/admin/promotion_categories/_form.html.erb +14 -0
- data/lib/views/backend/solidus_promotions/admin/promotion_categories/edit.html.erb +10 -0
- data/lib/views/backend/solidus_promotions/admin/promotion_categories/index.html.erb +47 -0
- data/lib/views/backend/solidus_promotions/admin/promotion_categories/new.html.erb +10 -0
- data/lib/views/backend/solidus_promotions/admin/promotion_code_batches/_form_fields.html.erb +22 -0
- data/lib/views/backend/solidus_promotions/admin/promotion_code_batches/download.csv.ruby +8 -0
- data/lib/views/backend/solidus_promotions/admin/promotion_code_batches/index.html.erb +65 -0
- data/lib/views/backend/solidus_promotions/admin/promotion_code_batches/new.html.erb +8 -0
- data/lib/views/backend/solidus_promotions/admin/promotion_codes/index.csv.ruby +8 -0
- data/lib/views/backend/solidus_promotions/admin/promotion_codes/index.html.erb +32 -0
- data/lib/views/backend/solidus_promotions/admin/promotion_codes/new.html.erb +31 -0
- data/lib/views/backend/solidus_promotions/admin/promotions/_form.html.erb +124 -0
- data/lib/views/backend/solidus_promotions/admin/promotions/_table.html.erb +57 -0
- data/lib/views/backend/solidus_promotions/admin/promotions/_table_filter.html.erb +78 -0
- data/lib/views/backend/solidus_promotions/admin/promotions/edit.html.erb +41 -0
- data/lib/views/backend/solidus_promotions/admin/promotions/index.html.erb +23 -0
- data/lib/views/backend/solidus_promotions/admin/promotions/new.html.erb +9 -0
- data/lib/views/backend/solidus_promotions/admin/shared/_number_with_currency.html.erb +20 -0
- data/lib/views/backend/solidus_promotions/admin/shared/_promotion_sub_menu.html.erb +14 -0
- data/lib/views/backend/solidus_promotions/admin/shared/preference_fields/_boolean.html.erb +14 -0
- data/lib/views/backend/solidus_promotions/admin/shared/preference_fields/_decimal.html.erb +12 -0
- data/lib/views/backend/solidus_promotions/admin/shared/preference_fields/_encrypted_string.html.erb +12 -0
- data/lib/views/backend/solidus_promotions/admin/shared/preference_fields/_integer.html.erb +12 -0
- data/lib/views/backend/solidus_promotions/admin/shared/preference_fields/_password.html.erb +12 -0
- data/lib/views/backend/solidus_promotions/admin/shared/preference_fields/_string.html.erb +12 -0
- data/lib/views/backend/solidus_promotions/admin/shared/preference_fields/_text.html.erb +12 -0
- data/lib/views/backend/solidus_promotions/promotion_code_batch_mailer/promotion_code_batch_errored.text.erb +2 -0
- data/lib/views/backend/solidus_promotions/promotion_code_batch_mailer/promotion_code_batch_finished.text.erb +2 -0
- data/solidus_promotions.gemspec +33 -0
- metadata +366 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
<%= form_with model: benefit, scope: :benefit, url: solidus_promotions.new_admin_promotion_benefit_path(@promotion), method: :get do |form| %>
|
2
|
+
<div class="form-group">
|
3
|
+
<%= form.label :type %>
|
4
|
+
<%= admin_hint SolidusPromotions::Benefit.human_attribute_name(:type), t(:type, scope: [:solidus_promotions, :hints, "solidus_promotions/benefit"]) %>
|
5
|
+
<%=
|
6
|
+
form.select :type,
|
7
|
+
options_for_benefit_types(form.object),
|
8
|
+
{
|
9
|
+
include_blank: t(:choose_benefit, scope: 'solidus_promotions')
|
10
|
+
},
|
11
|
+
class: 'custom-select w-100',
|
12
|
+
onchange: 'this.form.requestSubmit()',
|
13
|
+
required: true
|
14
|
+
%>
|
15
|
+
</div>
|
16
|
+
<% end %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<%= turbo_frame_tag @promotion, dom_id(@benefit) do %>
|
2
|
+
<%= render 'calculator_select', path: solidus_promotions.edit_admin_promotion_benefit_path(@promotion, @benefit), benefit: @benefit %>
|
3
|
+
|
4
|
+
<%=
|
5
|
+
form_with(
|
6
|
+
model: @benefit,
|
7
|
+
scope: :benefit,
|
8
|
+
url: solidus_promotions.admin_promotion_benefit_path(@promotion, @benefit),
|
9
|
+
) do |form| %>
|
10
|
+
<%= render "form", form: form %>
|
11
|
+
|
12
|
+
<div class="row">
|
13
|
+
<div class="col-12">
|
14
|
+
<%= button_tag "Update", class: "btn btn-secondary float-right" %>
|
15
|
+
</div>
|
16
|
+
</div>
|
17
|
+
|
18
|
+
<% end %>
|
19
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render "new_benefit", benefit: @benefit %>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<% calculator.admin_form_preference_names.map do |name| %>
|
2
|
+
<%= render "solidus_promotions/admin/shared/preference_fields/#{calculator.preference_type(name)}",
|
3
|
+
name: "#{prefix}[calculator_attributes][preferred_#{name}]",
|
4
|
+
value: calculator.get_preference(name),
|
5
|
+
label: t(name.to_s, scope: 'spree', default: name.to_s.humanize) %>
|
6
|
+
<% end %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<div class="form-group">
|
2
|
+
<%= fields_for "#{prefix}[calculator_attributes]", calculator do |f| %>
|
3
|
+
<%= f.label :preferred_amount %>
|
4
|
+
<%= render "solidus_promotions/admin/shared/number_with_currency", f: f, amount_attr: :preferred_amount, currency_attr: :preferred_currency %>
|
5
|
+
<% end %>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<div class="form-group">
|
9
|
+
<p>
|
10
|
+
<%= admin_hint(
|
11
|
+
calculator.model_name.human,
|
12
|
+
calculator.class.human_attribute_name(:explanation)
|
13
|
+
) %>
|
14
|
+
|
15
|
+
This amount will be the <strong>total</strong> discount spread amongst all
|
16
|
+
of the line items.
|
17
|
+
</p>
|
18
|
+
</div>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<div class="form-group">
|
2
|
+
<%= fields_for "#{prefix}[calculator_attributes]", calculator do |f| %>
|
3
|
+
<%= f.label :preferred_amount %>
|
4
|
+
<%= render "solidus_promotions/admin/shared/number_with_currency", f: f, amount_attr: :preferred_amount, currency_attr: :preferred_currency %>
|
5
|
+
<% end %>
|
6
|
+
</div>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<div class="form-group">
|
2
|
+
<%= fields_for "#{prefix}[calculator_attributes]", calculator do |f| %>
|
3
|
+
<%= f.label :preferred_first_item %>
|
4
|
+
<%= render "solidus_promotions/admin/shared/number_with_currency", f: f, amount_attr: :preferred_first_item, currency: f.object.preferred_currency %>
|
5
|
+
<% end %>
|
6
|
+
</div>
|
7
|
+
<div class="form-group">
|
8
|
+
<%= fields_for "#{prefix}[calculator_attributes]", calculator do |f| %>
|
9
|
+
<%= f.label :preferred_additional_item %>
|
10
|
+
<%= render "solidus_promotions/admin/shared/number_with_currency", f: f, amount_attr: :preferred_additional_item, currency: f.object.preferred_currency %>
|
11
|
+
<% end %>
|
12
|
+
</div>
|
13
|
+
<div class="form-group">
|
14
|
+
<%= fields_for "#{prefix}[calculator_attributes]", calculator do |f| %>
|
15
|
+
<%= f.label :preferred_max_items %>
|
16
|
+
<%= f.number_field :preferred_max_items, step: 1, min: 1, default: 1, class: "form-control" %>
|
17
|
+
<% end %>
|
18
|
+
</div>
|
19
|
+
<div class="form-group">
|
20
|
+
<%= fields_for "#{prefix}[calculator_attributes]", calculator do |f| %>
|
21
|
+
<%= f.label :preferred_currency %>
|
22
|
+
<%= f.select :preferred_currency, Spree::Config.available_currencies.map(&:iso_code), {selected: f.object.preferred_currency }, { is: "select-two", class: "w-100"} %>
|
23
|
+
<% end %>
|
24
|
+
</div>
|
data/lib/views/backend/solidus_promotions/admin/calculator_fields/tiered_flat_rate/_fields.html.erb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
<div class="form-group">
|
2
|
+
<%= fields_for "#{prefix}[calculator_attributes]", calculator do |f| %>
|
3
|
+
<%= f.label :preferred_base_amount %>
|
4
|
+
<%= render "solidus_promotions/admin/shared/number_with_currency", f: f, amount_attr: :preferred_base_amount, currency_attr: :preferred_currency %>
|
5
|
+
<% end %>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<div class="form-group">
|
9
|
+
<%= label_tag nil, calculator.class.human_attribute_name(:tiers) %>
|
10
|
+
<div data-controller="calculator-tiers">
|
11
|
+
<div class="d-flex">
|
12
|
+
<div class="item-total-label" style="flex-grow: 1">
|
13
|
+
<%= SolidusPromotions::Calculators::TieredFlatRate.human_attribute_name(:order_item_total) %>
|
14
|
+
</div>
|
15
|
+
<div class="discount-label mx-2" style="flex-grow: 1">
|
16
|
+
<%= SolidusPromotions::Calculators::TieredFlatRate.human_attribute_name(:discount) %>
|
17
|
+
</div>
|
18
|
+
<div class="tools m-3">
|
19
|
+
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
<template data-calculator-tiers-target="template">
|
23
|
+
<%= render "solidus_promotions/admin/calculator_fields/tiered_flat_rate/tier_fields", tier: [nil, nil], form: form, currency: calculator.preferred_currency %>
|
24
|
+
</template>
|
25
|
+
<% form.object.calculator.preferred_tiers.each do |tier| %>
|
26
|
+
<%= render "solidus_promotions/admin/calculator_fields/tiered_flat_rate/tier_fields", tier: tier, form: form, currency: calculator.preferred_currency %>
|
27
|
+
<% end %>
|
28
|
+
<div class="my-3" data-calculator-tiers-target="links">
|
29
|
+
<%= link_to t(:add_tier, scope: [:solidus_promotions, :admin, :promotions, :calculator]), "#", class: "btn btn-outline-primary", data: { action: "click->calculator-tiers#add_association" } %>
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
</div>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<div class="fullwidth tier calculator-tiers mb-3">
|
2
|
+
<div class="d-flex">
|
3
|
+
<div class="mr-2">
|
4
|
+
<div class="input-group">
|
5
|
+
<div class="input-group-prepend">
|
6
|
+
<span class="input-group-text"><%= ::Money::Currency.find(currency).symbol %></span>
|
7
|
+
</div>
|
8
|
+
<input
|
9
|
+
class="js-base-input form-control"
|
10
|
+
data-action="calculator-tiers#propagate_base_to_value_input"
|
11
|
+
type="text"
|
12
|
+
value="<%= tier[0] %>"
|
13
|
+
>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
<div class="mx-2">
|
17
|
+
<div class="input-group">
|
18
|
+
<div class="input-group-prepend">
|
19
|
+
<span class="input-group-text"><%= ::Money::Currency.find(currency).symbol %></span>
|
20
|
+
</div>
|
21
|
+
<input
|
22
|
+
class="js-value-input form-control"
|
23
|
+
name="<%= form.object_name %>[calculator_attributes][preferred_tiers][<%= tier[0] %>]"
|
24
|
+
type="text"
|
25
|
+
value="<%= tier[1] %>"
|
26
|
+
>
|
27
|
+
</div>
|
28
|
+
</div>
|
29
|
+
<a class="fa fa-trash remove p-2" data-action="click->calculator-tiers#remove_association"></a>
|
30
|
+
</div>
|
31
|
+
</div>
|
data/lib/views/backend/solidus_promotions/admin/calculator_fields/tiered_percent/_fields.html.erb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
<div class="form-group">
|
2
|
+
<%= fields_for "#{prefix}[calculator_attributes]", calculator do |f| %>
|
3
|
+
<%= f.label :preferred_base_percent %>
|
4
|
+
<%= f.number_field :preferred_base_percent, step: 1, min: 0, max: 100, default: 1, class: "form-control" %>
|
5
|
+
<% end %>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<div class="form-group">
|
9
|
+
<%= label_tag(
|
10
|
+
"#{prefix}[calculator_attributes][preferred_currency]",
|
11
|
+
t('spree.currency')
|
12
|
+
) %>
|
13
|
+
<%= select_tag(
|
14
|
+
"#{prefix}[calculator_attributes][preferred_currency]",
|
15
|
+
options_for_select(
|
16
|
+
Spree::Config.available_currencies,
|
17
|
+
calculator.preferred_currency || Spree::Config[:currency]
|
18
|
+
),
|
19
|
+
{ is: "select-two", class: 'fullwidth' }
|
20
|
+
) %>
|
21
|
+
</div>
|
22
|
+
|
23
|
+
<div class="form-group">
|
24
|
+
<%= label_tag nil, calculator.class.human_attribute_name(:tiers) %>
|
25
|
+
<div data-controller="calculator-tiers">
|
26
|
+
<div class="d-flex">
|
27
|
+
<div class="item-total-label" style="flex-grow: 1">
|
28
|
+
<%= SolidusPromotions::Calculators::TieredPercent.human_attribute_name(:order_item_total) %>
|
29
|
+
</div>
|
30
|
+
<div class="discount-label mx-2" style="flex-grow: 1">
|
31
|
+
<%= SolidusPromotions::Calculators::TieredPercent.human_attribute_name(:percent) %>
|
32
|
+
</div>
|
33
|
+
<div class="tools m-3">
|
34
|
+
|
35
|
+
</div>
|
36
|
+
</div>
|
37
|
+
<template data-calculator-tiers-target="template">
|
38
|
+
<%= render "solidus_promotions/admin/calculator_fields/tiered_percent/tier_fields", tier: [nil, nil], form: form %>
|
39
|
+
</template>
|
40
|
+
<% form.object.calculator.preferred_tiers.each do |tier| %>
|
41
|
+
<%= render "solidus_promotions/admin/calculator_fields/tiered_percent/tier_fields", tier: tier, form: form %>
|
42
|
+
<% end %>
|
43
|
+
<div class="mb-3" data-calculator-tiers-target="links">
|
44
|
+
<%= link_to t(:add_tier, scope: [:solidus_promotions, :admin, :promotions, :calculator]), "#", class: "btn btn-outline-primary", data: { action: "click->calculator-tiers#add_association" } %>
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
</div>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<div class="fullwidth tier calculator-tiers mb-3">
|
2
|
+
<div class="d-flex">
|
3
|
+
<div class="mr-2">
|
4
|
+
<div class="input-group">
|
5
|
+
<div class="input-group-prepend">
|
6
|
+
<span class="input-group-text">$</span>
|
7
|
+
</div>
|
8
|
+
<input
|
9
|
+
class="js-base-input form-control"
|
10
|
+
data-action="calculator-tiers#propagate_base_to_value_input"
|
11
|
+
type="text"
|
12
|
+
value="<%= tier[0] %>"
|
13
|
+
>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
<div class="mx-2">
|
17
|
+
<div class="input-group">
|
18
|
+
<input
|
19
|
+
class="js-value-input form-control right-align"
|
20
|
+
name="<%= form.object_name %>[calculator_attributes][preferred_tiers][<%= tier[0] %>]"
|
21
|
+
type="number"
|
22
|
+
min="0"
|
23
|
+
max="100"
|
24
|
+
value="<%= tier[1] %>"
|
25
|
+
>
|
26
|
+
<div class="input-group-append">
|
27
|
+
<span class="input-group-text">%</span>
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
</div>
|
31
|
+
<a class="fa fa-trash remove p-2" data-action="click->calculator-tiers#remove_association"></a>
|
32
|
+
</div>
|
33
|
+
</div>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<div class="form-group">
|
2
|
+
<%= fields_for "#{prefix}[calculator_attributes]", calculator do |f| %>
|
3
|
+
<%= f.label :preferred_base_percent %>
|
4
|
+
<%= f.number_field :preferred_base_percent, step: 1, min: 0, max: 100, default: 1, class: "form-control" %>
|
5
|
+
<% end %>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<div class="form-group">
|
9
|
+
<%= label_tag(
|
10
|
+
"#{prefix}[calculator_attributes][preferred_currency]",
|
11
|
+
t('spree.currency')
|
12
|
+
) %>
|
13
|
+
<%= select_tag(
|
14
|
+
"#{prefix}[calculator_attributes][preferred_currency]",
|
15
|
+
options_for_select(
|
16
|
+
Spree::Config.available_currencies,
|
17
|
+
calculator.preferred_currency || Spree::Config[:currency]
|
18
|
+
),
|
19
|
+
{ is: "select-two", class: 'fullwidth' }
|
20
|
+
) %>
|
21
|
+
</div>
|
22
|
+
|
23
|
+
<div class="form-group">
|
24
|
+
<%= label_tag nil, calculator.class.human_attribute_name(:tiers) %>
|
25
|
+
<div data-controller="calculator-tiers">
|
26
|
+
<template data-calculator-tiers-target="template">
|
27
|
+
<%= render "solidus_promotions/admin/calculator_fields/tiered_percent_on_eligible_item_quantity/tier_fields", tier: [nil, nil], form: form %>
|
28
|
+
</template>
|
29
|
+
<% form.object.calculator.preferred_tiers.each do |tier| %>
|
30
|
+
<%= render "solidus_promotions/admin/calculator_fields/tiered_percent_on_eligible_item_quantity/tier_fields", tier: tier, form: form %>
|
31
|
+
<% end %>
|
32
|
+
<div class="mb-3" data-calculator-tiers-target="links">
|
33
|
+
<%= link_to t(:add_tier, scope: [:solidus_promotions, :admin, :promotions, :calculator]), "#", class: "btn btn-outline-primary", data: { action: "click->calculator-tiers#add_association" } %>
|
34
|
+
</div>
|
35
|
+
</div>
|
36
|
+
</div>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<div class="fullwidth tier calculator-tiers mb-3">
|
2
|
+
<div class="d-flex">
|
3
|
+
<div class="mr-2">
|
4
|
+
<div class="input-group">
|
5
|
+
<div class="input-group-prepend">
|
6
|
+
<span class="input-group-text">∑</span>
|
7
|
+
</div>
|
8
|
+
<input
|
9
|
+
class="js-base-input form-control"
|
10
|
+
data-action="calculator-tiers#propagate_base_to_value_input"
|
11
|
+
type="number"
|
12
|
+
min=="1"
|
13
|
+
step="1"
|
14
|
+
value="<%= tier[0] %>"
|
15
|
+
>
|
16
|
+
</div>
|
17
|
+
</div>
|
18
|
+
<div class="mx-2">
|
19
|
+
<div class="input-group">
|
20
|
+
<input
|
21
|
+
class="js-value-input form-control right-align"
|
22
|
+
name="<%= form.object_name %>[calculator_attributes][preferred_tiers][<%= tier[0] %>]"
|
23
|
+
type="number"
|
24
|
+
min="1"
|
25
|
+
max="100"
|
26
|
+
value="<%= tier[1] %>"
|
27
|
+
>
|
28
|
+
<div class="input-group-append">
|
29
|
+
<span class="input-group-text">%</span>
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
</div>
|
33
|
+
<a class="fa fa-trash remove p-2" data-action="click->calculator-tiers#remove_association"></a>
|
34
|
+
</div>
|
35
|
+
</div>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<p>
|
2
|
+
<%= condition.class.human_attribute_name(:description) %>
|
3
|
+
</p>
|
4
|
+
<div class="form-group">
|
5
|
+
<%= label_tag "#{param_prefix}[preferred_days_ago]", condition.class.human_attribute_name(:preferred_days_ago) %>
|
6
|
+
<%= number_field_tag "#{param_prefix}[preferred_days_ago]", condition.preferred_days_ago, class: 'fullwidth' %>
|
7
|
+
</div>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<p>
|
2
|
+
<%= condition.class.human_attribute_name(:description) %>
|
3
|
+
</p>
|
4
|
+
|
5
|
+
<div class="form-group">
|
6
|
+
<%= label_tag "#{param_prefix}[preferred_operator]", condition.class.human_attribute_name(:preferred_operator) %>
|
7
|
+
<%= select_tag "#{param_prefix}[preferred_operator]", options_for_select(condition.class.operator_options, condition.preferred_operator), {class: 'custom-select select_item_total fullwidth'} %>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<div class="form-group">
|
11
|
+
<%= fields_for param_prefix, condition do |f| %>
|
12
|
+
<%= f.label :preferred_amount %>
|
13
|
+
<%= render "solidus_promotions/admin/shared/number_with_currency", f: f, amount_attr: :preferred_amount, currency_attr: :preferred_currency %>
|
14
|
+
<% end %>
|
15
|
+
</div>
|
data/lib/views/backend/solidus_promotions/admin/condition_fields/_line_item_option_value.html.erb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
<p>
|
3
|
+
<%= condition.class.human_attribute_name(:description) %>
|
4
|
+
</p>
|
5
|
+
<div class="field promo-condition-option-values">
|
6
|
+
<div class="param-prefix hidden" data-param-prefix="<%= param_prefix %>"></div>
|
7
|
+
<div class="row">
|
8
|
+
<div class="col-6"><%= label_tag nil, Spree::Product.model_name.human %></div>
|
9
|
+
<div class="col-6"><%= label_tag nil, plural_resource_name(Spree::OptionValue) %></div>
|
10
|
+
</div>
|
11
|
+
|
12
|
+
<div class="form-group">
|
13
|
+
<div data-controller="product-option-values">
|
14
|
+
<template data-product-option-values-target="template">
|
15
|
+
<%= render "solidus_promotions/admin/condition_fields/line_item_option_value/option_value_fields", product_option_values: [nil, []], form: form %>
|
16
|
+
</template>
|
17
|
+
<% form.object.preferred_eligible_values.each do |product_option_values| %>
|
18
|
+
<%= render "solidus_promotions/admin/condition_fields/line_item_option_value/option_value_fields", product_option_values: product_option_values, form: form %>
|
19
|
+
<% end %>
|
20
|
+
<div class="mb-3" data-product-option-values-target="links">
|
21
|
+
<%= link_to t(:add_product, scope: [:solidus_promotions, :line_item_option_value_condition]), "#", class: "btn btn-outline-primary", data: { action: "click->product-option-values#add_row" } %>
|
22
|
+
</div>
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
</div>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<p>
|
2
|
+
<%= condition.class.human_attribute_name(:description) %>
|
3
|
+
</p>
|
4
|
+
<div class="row">
|
5
|
+
<div class="col-12">
|
6
|
+
<div class="field products_condition_products">
|
7
|
+
<%= label_tag "#{param_prefix}_product_ids_string", t('solidus_promotions.product_condition.choose_products') %>
|
8
|
+
<%= hidden_field_tag "#{param_prefix}[product_ids_string]", condition.product_ids.join(","), class: "fullwidth", is: "product-picker" %>
|
9
|
+
</div>
|
10
|
+
</div>
|
11
|
+
<div class="col-12">
|
12
|
+
<div class="form-group">
|
13
|
+
<%= label_tag("#{param_prefix}_preferred_match_policy", condition.class.human_attribute_name(:preferred_match_policy)) %>
|
14
|
+
<%= select_tag(
|
15
|
+
"#{param_prefix}[preferred_match_policy]",
|
16
|
+
options_for_select(I18n.t("solidus_promotions.conditions.line_item_product.match_policies").to_a.map(&:reverse), condition.preferred_match_policy),
|
17
|
+
class: "custom-select fullwidth"
|
18
|
+
) %>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
</div>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<p>
|
2
|
+
<%= condition.class.human_attribute_name(:description) %>
|
3
|
+
</p>
|
4
|
+
<div class="field taxons_condition_taxons">
|
5
|
+
<%= label_tag "#{param_prefix}_taxon_ids_string", t("solidus_promotions.taxon_condition.choose_taxons") %>
|
6
|
+
<%= hidden_field_tag "#{param_prefix}[taxon_ids_string]", condition.taxon_ids.join(","), is: "taxon-picker", class: "fullwidth", id: "product_taxon_ids" %>
|
7
|
+
</div>
|
8
|
+
<div class="form-group">
|
9
|
+
<div class="form-group">
|
10
|
+
<%= label_tag("#{param_prefix}_preferred_match_policy", condition.class.human_attribute_name(:preferred_match_policy)) %>
|
11
|
+
<%= select_tag(
|
12
|
+
"#{param_prefix}[preferred_match_policy]",
|
13
|
+
options_for_select(I18n.t("solidus_promotions.conditions.line_item_taxon.match_policies").to_a.map(&:reverse), condition.preferred_match_policy),
|
14
|
+
class: "custom-select fullwidth",
|
15
|
+
) %>
|
16
|
+
</div>
|
17
|
+
</div>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<p>
|
2
|
+
<%= condition.class.human_attribute_name(:description) %>
|
3
|
+
</p>
|
4
|
+
<div class="row">
|
5
|
+
<div class="col-6">
|
6
|
+
<div class="form-group">
|
7
|
+
<%= SolidusPromotions::Conditions::NthOrder.human_attribute_name(:form_text) %>
|
8
|
+
</div>
|
9
|
+
</div>
|
10
|
+
<div class="col-6">
|
11
|
+
<div class="form-group">
|
12
|
+
<%= number_field_tag "#{param_prefix}[preferred_nth_order]", condition.preferred_nth_order, class: 'fullwidth' %>
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
</div>
|
@@ -0,0 +1,63 @@
|
|
1
|
+
<% context = local_assigns[:context] || :order %>
|
2
|
+
|
3
|
+
<% if context == :order %>
|
4
|
+
<p>
|
5
|
+
<%= condition.class.human_attribute_name(:description) %>
|
6
|
+
</p>
|
7
|
+
<div class="field promo-condition-option-values">
|
8
|
+
<div class="param-prefix hidden" data-param-prefix="<%= param_prefix %>"></div>
|
9
|
+
<div class="row">
|
10
|
+
<div class="col-6"><%= label_tag nil, Spree::Product.model_name.human %></div>
|
11
|
+
<div class="col-6"><%= label_tag nil, plural_resource_name(Spree::OptionValue) %></div>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<div class="form-group">
|
15
|
+
<div data-controller="product-option-values">
|
16
|
+
<template data-product-option-values-target="template">
|
17
|
+
<%= render "solidus_promotions/admin/condition_fields/line_item_option_value/option_value_fields", product_option_values: [nil, []], form: form %>
|
18
|
+
</template>
|
19
|
+
<% form.object.preferred_eligible_values.each do |product_option_values| %>
|
20
|
+
<%= render "solidus_promotions/admin/condition_fields/line_item_option_value/option_value_fields", product_option_values: product_option_values, form: form %>
|
21
|
+
<% end %>
|
22
|
+
<div class="mb-3" data-product-option-values-target="links">
|
23
|
+
<%= link_to t(:add_product, scope: [:solidus_promotions, :option_value_condition]), "#", class: "btn btn-outline-primary", data: { action: "click->product-option-values#add_row" } %>
|
24
|
+
</div>
|
25
|
+
</div>
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<div class="form-group">
|
29
|
+
<%= form.label :preferred_line_item_applicable do %>
|
30
|
+
<%= form.check_box :preferred_line_item_applicable %>
|
31
|
+
<%= condition.class.human_attribute_name(:preferred_line_item_applicable) %>
|
32
|
+
<% end %>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
<% else %>
|
36
|
+
<p>
|
37
|
+
<%= SolidusPromotions::Conditions::LineItemOptionValue.human_attribute_name(:description) %>
|
38
|
+
</p>
|
39
|
+
<table>
|
40
|
+
<thead>
|
41
|
+
<tr>
|
42
|
+
<th>
|
43
|
+
<%= Spree::Product.model_name.human %>
|
44
|
+
</th>
|
45
|
+
<th>
|
46
|
+
<%= Spree::OptionValue.model_name.human(count: :other) %>
|
47
|
+
</th>
|
48
|
+
</tr>
|
49
|
+
</thead>
|
50
|
+
<tbody>
|
51
|
+
<% condition.preferred_eligible_values.each do |product_id, option_value_ids| %>
|
52
|
+
<tr>
|
53
|
+
<td>
|
54
|
+
<%= Spree::Product.find(product_id).name %>
|
55
|
+
</td>
|
56
|
+
<td>
|
57
|
+
<%= Spree::OptionValue.where(id: option_value_ids).map(&:name).join(", ") %>
|
58
|
+
</td>
|
59
|
+
</tr>
|
60
|
+
<% end %>
|
61
|
+
</tbody>
|
62
|
+
</table>
|
63
|
+
<% end %>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<p>
|
2
|
+
<%= condition.class.human_attribute_name(:description) %>
|
3
|
+
</p>
|
4
|
+
<%= fields_for param_prefix, condition do |form| %>
|
5
|
+
<div class="field products_condition_products">
|
6
|
+
<%= form.label :product_ids_string, t('solidus_promotions.product_condition.choose_products') %>
|
7
|
+
<%= form.hidden_field :product_ids_string, value: condition.product_ids.join(","), class: "fullwidth", is: "product-picker" %>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<div class="form-group">
|
11
|
+
<%
|
12
|
+
match_policy_options = options_for_select(
|
13
|
+
SolidusPromotions::Conditions::Product::MATCH_POLICIES.map { |s| [t("solidus_promotions.product_condition.match_#{s}"),s] },
|
14
|
+
condition.preferred_match_policy
|
15
|
+
)
|
16
|
+
%>
|
17
|
+
<% select = form.select :preferred_match_policy, match_policy_options %>
|
18
|
+
<%= form.label :preferred_match_policy, t('solidus_promotions.product_condition.label', select: select).html_safe %>
|
19
|
+
</div>
|
20
|
+
|
21
|
+
<div class="form-group">
|
22
|
+
<%= form.label :preferred_line_item_applicable do %>
|
23
|
+
<%= form.check_box :preferred_line_item_applicable %>
|
24
|
+
<%= condition.class.human_attribute_name(:preferred_line_item_applicable) %>
|
25
|
+
<% end %>
|
26
|
+
</div>
|
27
|
+
<% end %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<p>
|
2
|
+
<%= condition.class.human_attribute_name(:description) %>
|
3
|
+
</p>
|
4
|
+
<div class="form-group">
|
5
|
+
<%= label_tag "#{param_prefix}_preferred_shipping_method_ids", SolidusPromotions::Conditions::ShippingMethod.human_attribute_name(:preferred_shipping_method_ids) %>
|
6
|
+
<%= select_tag "#{param_prefix}[preferred_shipping_method_ids]",
|
7
|
+
options_from_collection_for_select(
|
8
|
+
Spree::ShippingMethod.all, :id, :name, condition.preferred_shipping_method_ids
|
9
|
+
), class: 'select2 fullwidth', multiple: true %>
|
10
|
+
</div>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<p>
|
2
|
+
<%= condition.class.human_attribute_name(:description) %>
|
3
|
+
</p>
|
4
|
+
<div class="form-group">
|
5
|
+
<%= label_tag "#{param_prefix}[store_ids][]", Spree::Store.model_name.human(count: :other) %>
|
6
|
+
<%= select_tag "#{param_prefix}[store_ids][]",
|
7
|
+
options_from_collection_for_select(Spree::Store.all, :id, :name, condition.store_ids),
|
8
|
+
multiple: true, is: "select-two", class: "fullwidth" %>
|
9
|
+
</div>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<p>
|
2
|
+
<%= condition.class.human_attribute_name(:description) %>
|
3
|
+
</p>
|
4
|
+
<%= fields_for param_prefix, condition do |form| %>
|
5
|
+
<div class="field taxons_condition_taxons">
|
6
|
+
<%= form.label :taxon_ids_string, t('solidus_promotions.taxon_condition.choose_taxons') %>
|
7
|
+
<%= form.hidden_field :taxon_ids_string, value: condition.taxon_ids.join(","), is: "taxon-picker", class: "fullwidth" %>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<div class="form-group">
|
11
|
+
<%
|
12
|
+
match_policy_options = options_for_select(
|
13
|
+
SolidusPromotions::Conditions::Taxon::MATCH_POLICIES.map { |s| [t("solidus_promotions.taxon_condition.match_#{s}"),s] },
|
14
|
+
condition.preferred_match_policy
|
15
|
+
)
|
16
|
+
%>
|
17
|
+
<% select = form.select :preferred_match_policy, match_policy_options %>
|
18
|
+
<%= form.label :preferred_match_policy, t('solidus_promotions.taxon_condition.label', select: select).html_safe %>
|
19
|
+
</div>
|
20
|
+
|
21
|
+
<div class="form-group">
|
22
|
+
<%= form.label :preferred_line_item_applicable do %>
|
23
|
+
<%= form.check_box :preferred_line_item_applicable %>
|
24
|
+
<%= condition.class.human_attribute_name(:preferred_line_item_applicable) %>
|
25
|
+
<% end %>
|
26
|
+
</div>
|
27
|
+
<% end %>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<p>
|
2
|
+
<%= condition.class.human_attribute_name(:description) %>
|
3
|
+
</p>
|
4
|
+
<div class="form-group">
|
5
|
+
<label><%= t('solidus_promotions.user_condition.choose_users') %></label><br>
|
6
|
+
<input type='hidden' name='<%= param_prefix %>[user_ids_string]' is="user-picker" class='fullwidth' value='<%= condition.user_ids.join(",") %>'>
|
7
|
+
</div>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<p>
|
2
|
+
<%= condition.class.human_attribute_name(:description) %>
|
3
|
+
</p>
|
4
|
+
<div class="form-group">
|
5
|
+
<%= label_tag "#{param_prefix}_preferred_role_ids", t('solidus_promotions.user_role_condition.choose_roles') %>
|
6
|
+
<%= select_tag "#{param_prefix}[preferred_role_ids]",
|
7
|
+
options_from_collection_for_select(
|
8
|
+
Spree::Role.all, :id, :name, condition.preferred_role_ids
|
9
|
+
), class: 'fullwidth', is: 'select-two', multiple: true %>
|
10
|
+
</div>
|
11
|
+
<div class="form-group">
|
12
|
+
<label>
|
13
|
+
<%= t('solidus_promotions.user_role_condition.label', select: select_tag("#{param_prefix}[preferred_match_policy]", options_for_select(SolidusPromotions::Conditions::UserRole::MATCH_POLICIES.map{ |s| [t("solidus_promotions.user_role_condition.match_#{s}"),s] }, condition.preferred_match_policy), { class: 'custom-select'})).html_safe %>
|
14
|
+
</label>
|
15
|
+
</div>
|