solidus_friendly_promotions 1.0.1 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/Gemfile +1 -1
- data/MIGRATING.md +1 -1
- data/README.md +22 -16
- data/app/assets/config/solidus_friendly_promotions/manifest.js +7 -1
- data/app/controllers/solidus_friendly_promotions/admin/benefits_controller.rb +85 -0
- data/app/controllers/solidus_friendly_promotions/admin/conditions_controller.rb +69 -0
- data/app/controllers/solidus_friendly_promotions/admin/promotions_controller.rb +3 -3
- data/app/decorators/models/solidus_friendly_promotions/adjustment_decorator.rb +4 -4
- data/app/decorators/models/solidus_friendly_promotions/line_item_decorator.rb +2 -2
- data/app/decorators/models/solidus_friendly_promotions/order_decorator.rb +6 -6
- data/app/helpers/solidus_friendly_promotions/admin/benefits_helper.rb +19 -0
- data/app/helpers/solidus_friendly_promotions/admin/conditions_helper.rb +12 -0
- data/app/javascript/solidus_friendly_promotions/controllers/product_option_values_controller.js +1 -1
- data/app/javascript/solidus_friendly_promotions/web_components/number_with_currency.js +35 -0
- data/app/javascript/solidus_friendly_promotions/{jquery → web_components}/option_value_picker.js +8 -0
- data/app/javascript/solidus_friendly_promotions/web_components/product_picker.js +7 -0
- data/app/javascript/solidus_friendly_promotions/web_components/select_two.js +11 -0
- data/app/javascript/solidus_friendly_promotions/web_components/taxon_picker.js +7 -0
- data/app/javascript/solidus_friendly_promotions/web_components/user_picker.js +7 -0
- data/app/javascript/solidus_friendly_promotions/web_components/variant_picker.js +7 -0
- data/app/javascript/solidus_friendly_promotions.js +7 -11
- data/app/models/concerns/solidus_friendly_promotions/{actions/order_level_action.rb → benefits/order_benefit.rb} +2 -2
- data/app/models/concerns/solidus_friendly_promotions/{rules/line_item_applicable_order_rule.rb → conditions/line_item_applicable_order_condition.rb} +2 -2
- data/app/models/concerns/solidus_friendly_promotions/{rules/line_item_level_rule.rb → conditions/line_item_level_condition.rb} +2 -2
- data/app/models/concerns/solidus_friendly_promotions/{rules/order_level_rule.rb → conditions/order_level_condition.rb} +2 -2
- data/app/models/concerns/solidus_friendly_promotions/{rules/shipment_level_rule.rb → conditions/shipment_level_condition.rb} +2 -2
- data/app/models/solidus_friendly_promotions/{promotion_action.rb → benefit.rb} +48 -11
- data/app/models/solidus_friendly_promotions/{actions → benefits}/adjust_line_item.rb +6 -2
- data/app/models/solidus_friendly_promotions/{actions → benefits}/adjust_line_item_quantity_groups.rb +3 -3
- data/app/models/solidus_friendly_promotions/{actions → benefits}/adjust_shipment.rb +6 -2
- data/app/models/solidus_friendly_promotions/{actions → benefits}/create_discounted_item.rb +6 -7
- data/app/models/solidus_friendly_promotions/calculators/distributed_amount.rb +1 -1
- data/app/models/solidus_friendly_promotions/calculators/tiered_flat_rate.rb +1 -1
- data/app/models/solidus_friendly_promotions/calculators/tiered_percent.rb +1 -1
- data/app/models/solidus_friendly_promotions/calculators/tiered_percent_on_eligible_item_quantity.rb +4 -2
- data/app/models/solidus_friendly_promotions/{promotion_rule.rb → condition.rb} +13 -7
- data/app/models/solidus_friendly_promotions/condition_product.rb +8 -0
- data/app/models/solidus_friendly_promotions/condition_store.rb +8 -0
- data/app/models/solidus_friendly_promotions/condition_taxon.rb +8 -0
- data/app/models/solidus_friendly_promotions/{promotion_rules_user.rb → condition_user.rb} +2 -2
- data/app/models/solidus_friendly_promotions/{rules → conditions}/discounted_item_total.rb +3 -3
- data/app/models/solidus_friendly_promotions/{rules → conditions}/first_order.rb +3 -3
- data/app/models/solidus_friendly_promotions/{rules → conditions}/first_repeat_purchase_since.rb +3 -3
- data/app/models/solidus_friendly_promotions/{rules → conditions}/item_total.rb +5 -5
- data/app/models/solidus_friendly_promotions/{rules → conditions}/line_item_option_value.rb +3 -3
- data/app/models/solidus_friendly_promotions/{rules → conditions}/line_item_product.rb +8 -8
- data/app/models/solidus_friendly_promotions/{rules → conditions}/line_item_taxon.rb +8 -8
- data/app/models/solidus_friendly_promotions/{rules → conditions}/minimum_quantity.rb +8 -8
- data/app/models/solidus_friendly_promotions/{rules → conditions}/nth_order.rb +5 -5
- data/app/models/solidus_friendly_promotions/{rules → conditions}/one_use_per_user.rb +3 -3
- data/app/models/solidus_friendly_promotions/{rules → conditions}/option_value.rb +3 -3
- data/app/models/solidus_friendly_promotions/{rules → conditions}/product.rb +9 -9
- data/app/models/solidus_friendly_promotions/{rules → conditions}/shipping_method.rb +3 -3
- data/app/models/solidus_friendly_promotions/{rules → conditions}/store.rb +6 -6
- data/app/models/solidus_friendly_promotions/{rules → conditions}/taxon.rb +12 -12
- data/app/models/solidus_friendly_promotions/{rules → conditions}/user.rb +7 -7
- data/app/models/solidus_friendly_promotions/{rules → conditions}/user_logged_in.rb +3 -3
- data/app/models/solidus_friendly_promotions/{rules → conditions}/user_role.rb +3 -3
- data/app/models/solidus_friendly_promotions/eligibility_result.rb +1 -1
- data/app/models/solidus_friendly_promotions/eligibility_results.rb +7 -7
- data/app/models/solidus_friendly_promotions/friendly_promotion_adjuster/discount_order.rb +28 -29
- data/app/models/solidus_friendly_promotions/friendly_promotion_adjuster/load_promotions.rb +10 -11
- data/app/models/solidus_friendly_promotions/friendly_promotion_adjuster/persist_discounted_order.rb +2 -2
- data/app/models/solidus_friendly_promotions/order_promotion.rb +1 -1
- data/app/models/solidus_friendly_promotions/permission_sets/friendly_promotion_management.rb +1 -1
- data/app/models/solidus_friendly_promotions/promotion.rb +14 -43
- data/app/models/solidus_friendly_promotions/promotion_advertiser.rb +10 -0
- data/app/models/solidus_friendly_promotions/promotion_code.rb +1 -1
- data/app/models/solidus_friendly_promotions/shipping_rate_discount.rb +1 -1
- data/app/views/solidus_friendly_promotions/admin/benefit_fields/_adjust_line_item.html.erb +6 -0
- data/app/views/solidus_friendly_promotions/admin/{promotion_actions/actions → benefit_fields}/_adjust_line_item_quantity_groups.html.erb +4 -4
- data/app/views/solidus_friendly_promotions/admin/benefit_fields/_adjust_shipment.html.erb +6 -0
- data/app/views/solidus_friendly_promotions/admin/benefit_fields/_calculator_fields.erb +11 -0
- data/app/views/solidus_friendly_promotions/admin/{promotion_actions/actions → benefit_fields}/_create_discounted_item.html.erb +8 -6
- data/app/views/solidus_friendly_promotions/admin/benefits/_benefit.html.erb +50 -0
- data/app/views/solidus_friendly_promotions/admin/benefits/_calculator_select.html.erb +16 -0
- data/app/views/solidus_friendly_promotions/admin/benefits/_form.html.erb +3 -0
- data/app/views/solidus_friendly_promotions/admin/benefits/_new_benefit.html.erb +33 -0
- data/app/views/solidus_friendly_promotions/admin/benefits/_type_select.html.erb +16 -0
- data/app/views/solidus_friendly_promotions/admin/benefits/edit.html.erb +19 -0
- data/app/views/solidus_friendly_promotions/admin/benefits/new.html.erb +1 -0
- data/app/views/solidus_friendly_promotions/admin/{promotion_actions/calculators → calculator_fields}/_default_fields.html.erb +1 -1
- data/app/views/solidus_friendly_promotions/admin/{promotion_actions/calculators → calculator_fields}/distributed_amount/_fields.html.erb +3 -3
- data/app/views/solidus_friendly_promotions/admin/calculator_fields/flat_rate/_fields.html.erb +6 -0
- data/app/views/solidus_friendly_promotions/admin/calculator_fields/flexi_rate/_fields.html.erb +24 -0
- data/app/views/solidus_friendly_promotions/admin/calculator_fields/percent/_fields.html.erb +6 -0
- data/app/views/solidus_friendly_promotions/admin/calculator_fields/tiered_flat_rate/_fields.html.erb +32 -0
- data/app/views/solidus_friendly_promotions/admin/{promotion_actions/calculators → calculator_fields}/tiered_flat_rate/_tier_fields.html.erb +7 -8
- data/app/views/solidus_friendly_promotions/admin/calculator_fields/tiered_percent/_fields.html.erb +47 -0
- data/app/views/solidus_friendly_promotions/admin/{promotion_actions/calculators → calculator_fields}/tiered_percent/_tier_fields.html.erb +8 -7
- data/app/views/solidus_friendly_promotions/admin/{promotion_actions/calculators → calculator_fields}/tiered_percent_on_eligible_item_quantity/_fields.html.erb +11 -9
- data/app/views/solidus_friendly_promotions/admin/calculator_fields/tiered_percent_on_eligible_item_quantity/_tier_fields.html.erb +35 -0
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_first_order.html.erb +3 -0
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_first_repeat_purchase_since.html.erb +7 -0
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_item_total.html.erb +15 -0
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_line_item_option_value.html.erb +25 -0
- data/app/views/solidus_friendly_promotions/admin/{promotion_rules/rules → condition_fields}/_line_item_product.html.erb +7 -7
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_line_item_taxon.html.erb +17 -0
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_minimum_quantity.html.erb +5 -0
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_nth_order.html.erb +15 -0
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_one_use_per_user.html.erb +3 -0
- data/app/views/solidus_friendly_promotions/admin/{promotion_rules/rules → condition_fields}/_option_value.html.erb +10 -10
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_product.html.erb +28 -0
- data/app/views/solidus_friendly_promotions/admin/{promotion_rules/rules → condition_fields}/_shipping_method.html.erb +3 -3
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_store.html.erb +9 -0
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_taxon.html.erb +28 -0
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_user.html.erb +7 -0
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_user_logged_in.html.erb +3 -0
- data/app/views/solidus_friendly_promotions/admin/condition_fields/_user_role.html.erb +15 -0
- data/app/views/solidus_friendly_promotions/admin/condition_fields/line_item_option_value/_option_value_fields.html.erb +21 -0
- data/app/views/solidus_friendly_promotions/admin/conditions/_condition.html.erb +26 -0
- data/app/views/solidus_friendly_promotions/admin/conditions/_new_condition.html.erb +26 -0
- data/app/views/solidus_friendly_promotions/admin/conditions/_type_select.html.erb +20 -0
- data/app/views/solidus_friendly_promotions/admin/conditions/new.html.erb +1 -0
- data/app/views/solidus_friendly_promotions/admin/promotion_code_batches/_form_fields.html.erb +5 -5
- data/app/views/solidus_friendly_promotions/admin/promotions/_form.html.erb +4 -4
- data/app/views/solidus_friendly_promotions/admin/promotions/_table_filter.html.erb +6 -6
- data/app/views/solidus_friendly_promotions/admin/promotions/edit.html.erb +7 -41
- data/app/views/solidus_friendly_promotions/admin/shared/_number_with_currency.html.erb +20 -0
- data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_boolean.html.erb +14 -0
- data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_decimal.html.erb +12 -0
- data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_encrypted_string.html.erb +12 -0
- data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_integer.html.erb +12 -0
- data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_password.html.erb +12 -0
- data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_string.html.erb +12 -0
- data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_text.html.erb +12 -0
- data/bin/sandbox +3 -3
- data/config/importmap.rb +2 -0
- data/config/locales/en.yml +128 -94
- data/config/routes.rb +3 -2
- data/db/migrate/20231011120928_add_db_comments_to_friendly_promotion_rules_taxons.rb +2 -2
- data/db/migrate/20231011142040_add_db_comments_to_friendly_promotion_rules_users.rb +1 -1
- data/db/migrate/20231011190222_add_db_comments_to_friendly_promotion_actions.rb +1 -1
- data/db/migrate/20240409093831_add_action_reference_to_rules.rb +34 -0
- data/db/migrate/20240506142650_remove_promotion_rules_promotion_id.rb +5 -0
- data/db/migrate/20240508080834_rename_promotion_rules_to_conditions.rb +19 -0
- data/db/migrate/20240508131514_rename_friendly_promotion_actions_to_friendly_benefits.rb +19 -0
- data/db/migrate/20240612113608_update_column_comments_for_benefits.rb +31 -0
- data/db/migrate/20240612114132_update_column_comments_for_conditions.rb +30 -0
- data/db/migrate/20240612115209_update_column_comments_for_condition_stores.rb +23 -0
- data/db/migrate/20240612115749_update_column_comments_for_condition_products.rb +22 -0
- data/db/migrate/20240612120411_update_column_comments_for_condition_taxons.rb +24 -0
- data/db/migrate/20240612121049_update_column_comments_for_condition_users.rb +23 -0
- data/lib/generators/solidus_friendly_promotions/install/templates/initializer.rb +30 -30
- data/lib/solidus_friendly_promotions/configuration.rb +11 -3
- data/lib/solidus_friendly_promotions/migrate_adjustments.rb +11 -11
- data/lib/solidus_friendly_promotions/promotion_map.rb +17 -17
- data/lib/solidus_friendly_promotions/promotion_migrator.rb +16 -16
- data/lib/solidus_friendly_promotions/testing_support/factories/friendly_promotion_factory.rb +8 -34
- data/lib/solidus_friendly_promotions/testing_support/factories/friendly_shipping_rate_discount_factory.rb +2 -2
- data/lib/solidus_friendly_promotions/version.rb +1 -1
- data/lib/tasks/solidus_friendly_promotions/migrate_adjustments.rake +2 -2
- data/solidus_friendly_promotions.gemspec +2 -2
- metadata +114 -86
- data/.rubocop_todo.yml +0 -157
- data/app/controllers/solidus_friendly_promotions/admin/promotion_actions_controller.rb +0 -103
- data/app/controllers/solidus_friendly_promotions/admin/promotion_rules_controller.rb +0 -105
- data/app/helpers/solidus_friendly_promotions/admin/promotion_actions_helper.rb +0 -23
- data/app/helpers/solidus_friendly_promotions/admin/promotion_rules_helper.rb +0 -25
- data/app/models/solidus_friendly_promotions/products_promotion_rule.rb +0 -8
- data/app/models/solidus_friendly_promotions/promotion_rules_store.rb +0 -8
- data/app/models/solidus_friendly_promotions/promotion_rules_taxon.rb +0 -8
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/_calculator_select.html.erb +0 -16
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/_form.html.erb +0 -3
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/_promotion_action.html.erb +0 -29
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/_type_select.html.erb +0 -14
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/actions/_adjust_line_item.html.erb +0 -6
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/actions/_adjust_shipment.html.erb +0 -6
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/actions/_calculator_fields.erb +0 -9
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/flat_rate/_fields.html.erb +0 -6
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/tiered_flat_rate/_fields.html.erb +0 -34
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/tiered_percent/_fields.html.erb +0 -34
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/tiered_percent_on_eligible_item_quantity/_tier_fields.html.erb +0 -27
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/edit.html.erb +0 -23
- data/app/views/solidus_friendly_promotions/admin/promotion_actions/new.html.erb +0 -26
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/_promotion_rule.html.erb +0 -22
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/_type_select.html.erb +0 -20
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/new.html.erb +0 -24
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_first_order.html.erb +0 -3
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_first_repeat_purchase_since.html.erb +0 -6
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_item_total.html.erb +0 -17
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_line_item_option_value.html.erb +0 -25
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_line_item_taxon.html.erb +0 -17
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_minimum_quantity.html.erb +0 -5
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_nth_order.html.erb +0 -15
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_one_use_per_user.html.erb +0 -3
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_product.html.erb +0 -44
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_store.html.erb +0 -9
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_taxon.html.erb +0 -44
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_user.html.erb +0 -7
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_user_logged_in.html.erb +0 -3
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_user_role.html.erb +0 -15
- data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/line_item_option_value/_option_value_fields.html.erb +0 -17
data/config/locales/en.yml
CHANGED
@@ -10,47 +10,49 @@ en:
|
|
10
10
|
legacy_promotions: Legacy Promotions
|
11
11
|
legacy_promotion_categories: Legacy Promotion Categories
|
12
12
|
hints:
|
13
|
-
solidus_friendly_promotions/calculator:
|
14
|
-
promotions: This is used to determine the promotional discount to be applied to an order, an item, or shipping charges.
|
15
13
|
solidus_friendly_promotions/promotion:
|
16
14
|
expires_at: This determines when the promotion expires. <br> If no value is specified, the promotion will never expire.
|
17
|
-
promo_code_will_be_disabled: Selecting this option, promo codes will be disabled for this promotion because all its
|
15
|
+
promo_code_will_be_disabled: Selecting this option, promo codes will be disabled for this promotion because all its conditions / benefits will be applied automatically to all orders.
|
18
16
|
starts_at: This determines when the promotion can be applied to orders. <br> If no value is specified, the promotion will be immediately available.
|
19
17
|
solidus_friendly_promotions:
|
20
|
-
|
18
|
+
hints:
|
19
|
+
solidus_friendly_promotions/benefit:
|
20
|
+
conditions: This is used to determine if the benefit should be applied.
|
21
|
+
type: This is the type of benefit that will be applied.
|
22
|
+
calculator: This is used to determine the promotional discount to be applied to an order, an item, or shipping charges.
|
23
|
+
benefits: Benefits
|
21
24
|
adjustment_labels:
|
22
25
|
line_item: "%{promotion} (%{promotion_customer_label})"
|
23
26
|
shipment: "%{promotion} (%{promotion_customer_label})"
|
24
27
|
shipping_rate: "%{promotion} (%{promotion_customer_label})"
|
25
28
|
adjustment_type: Adjustment type
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
invalid_promotion_rule: Invalid promotion rule.
|
29
|
+
add_benefit: Add Benefit
|
30
|
+
add_condition: Add Condition
|
31
|
+
order_conditions: Order Conditions
|
32
|
+
line_item_conditions: Line Item Conditions
|
33
|
+
shipment_conditions: Shipment Conditions
|
34
|
+
line_item_benefits: Line Item Benefits
|
35
|
+
shipment_benefits: Shipment Benefits
|
36
|
+
order_benefits: Order Benefits
|
37
|
+
invalid_benefit: Invalid promotion benefit.
|
38
|
+
invalid_condition: Invalid promotion condition.
|
37
39
|
create_promotion_code: Create promotion code
|
38
40
|
current_promotion_usage: 'Current Usage: %{count}'
|
39
|
-
|
41
|
+
discount_conditions: Promotion Conditions
|
40
42
|
download_promotion_codes_list: Download codes list
|
41
43
|
new_promotion: New Promotion
|
42
44
|
new_promotion_category: New Promotion Category
|
43
45
|
new_promotion_code_batch: New Promotion Code Batch
|
44
46
|
number_of_codes: "%{count} codes"
|
45
47
|
legacy_promotions: Legacy Promotions
|
46
|
-
|
48
|
+
no_conditions_added: No Conditions Added
|
47
49
|
promotion_successfully_created: Promotion has been successfully created!
|
48
50
|
promotion_total_changed_before_complete: One or more of the promotions on your order have become ineligible and were removed. Please check the new order amounts and try again.
|
49
51
|
promotion_code_batches:
|
50
52
|
finished: Finished
|
51
53
|
errored: Errored
|
52
54
|
view_promotion_codes_list: View codes list
|
53
|
-
|
55
|
+
conditions:
|
54
56
|
line_item_product:
|
55
57
|
match_policies:
|
56
58
|
include: Line item's product is one of the chosen products
|
@@ -59,6 +61,17 @@ en:
|
|
59
61
|
match_policies:
|
60
62
|
include: Line item's product has one of the chosen taxons
|
61
63
|
exclude: Line item's product does not have one of the chosen taxons
|
64
|
+
item_total_condition:
|
65
|
+
operators:
|
66
|
+
gt: greater than
|
67
|
+
gte: greater than or equal to
|
68
|
+
user_condition:
|
69
|
+
choose_users: Choose Users
|
70
|
+
user_role_condition:
|
71
|
+
choose_roles: Choose Roles
|
72
|
+
label: User must contain %{select} of these roles
|
73
|
+
match_all: all
|
74
|
+
match_any: at least one
|
62
75
|
coupon_code: Coupon code
|
63
76
|
eligibility_results:
|
64
77
|
coupon_code_applied: The coupon code was successfully applied to your order.
|
@@ -71,50 +84,50 @@ en:
|
|
71
84
|
coupon_code_not_found: The coupon code you entered doesn't exist. Please try again.
|
72
85
|
coupon_code_not_present: The coupon code you are trying to remove is not present on this order.
|
73
86
|
coupon_code_unknown_error: This coupon code could not be applied to the cart at this time.
|
74
|
-
solidus_friendly_promotions/
|
87
|
+
solidus_friendly_promotions/conditions/first_order:
|
75
88
|
not_first_order: This coupon code can only be applied to your first order.
|
76
|
-
solidus_friendly_promotions/
|
77
|
-
solidus_friendly_promotions/
|
89
|
+
solidus_friendly_promotions/conditions/first_repeat_purchase_since:
|
90
|
+
solidus_friendly_promotions/conditions/item_total:
|
78
91
|
item_total_doesnt_match_with_operator: This coupon code can't be applied to orders %{operator} %{amount}.
|
79
92
|
item_total_less_than: This coupon code can't be applied to orders less than %{amount}.
|
80
93
|
item_total_less_than_or_equal: This coupon code can't be applied to orders less than or equal to %{amount}.
|
81
|
-
solidus_friendly_promotions/
|
94
|
+
solidus_friendly_promotions/conditions/discounted_item_total:
|
82
95
|
item_total_doesnt_match_with_operator: This coupon code can't be applied to orders %{operator} %{amount}.
|
83
96
|
item_total_less_than: This coupon code can't be applied to orders less than %{amount}.
|
84
97
|
item_total_less_than_or_equal: This coupon code can't be applied to orders less than or equal to %{amount}.
|
85
|
-
solidus_friendly_promotions/
|
86
|
-
solidus_friendly_promotions/
|
87
|
-
solidus_friendly_promotions/
|
98
|
+
solidus_friendly_promotions/conditions/landing_page:
|
99
|
+
solidus_friendly_promotions/conditions/nth_order:
|
100
|
+
solidus_friendly_promotions/conditions/one_use_per_user:
|
88
101
|
no_user_specified: You need to login before applying this coupon code.
|
89
102
|
limit_once_per_user: This coupon code can only be used once per user.
|
90
|
-
solidus_friendly_promotions/
|
91
|
-
solidus_friendly_promotions/
|
92
|
-
solidus_friendly_promotions/
|
103
|
+
solidus_friendly_promotions/conditions/option_value:
|
104
|
+
solidus_friendly_promotions/conditions/line_item_option_value:
|
105
|
+
solidus_friendly_promotions/conditions/product:
|
93
106
|
has_excluded_product: Your cart contains a product that prevents this coupon code from being applied.
|
94
107
|
missing_product: This coupon code can't be applied because you don't have all of the necessary products in your cart.
|
95
108
|
no_applicable_products: You need to add an applicable product before applying this coupon code.
|
96
|
-
solidus_friendly_promotions/
|
109
|
+
solidus_friendly_promotions/conditions/line_item_product:
|
97
110
|
has_excluded_product: Your cart contains a product that prevents this coupon code from being applied.
|
98
111
|
missing_product: This coupon code can't be applied because you don't have all of the necessary products in your cart.
|
99
112
|
no_applicable_products: You need to add an applicable product before applying this coupon code.
|
100
|
-
solidus_friendly_promotions/
|
113
|
+
solidus_friendly_promotions/conditions/taxon:
|
101
114
|
has_excluded_taxon: Your cart contains a product from an excluded category that prevents this coupon code from being applied.
|
102
115
|
missing_taxon: You need to add a product from all applicable categories before applying this coupon code.
|
103
116
|
no_matching_taxons: You need to add a product from an applicable category before applying this coupon code.
|
104
|
-
solidus_friendly_promotions/
|
117
|
+
solidus_friendly_promotions/conditions/line_item_taxon:
|
105
118
|
has_excluded_taxon: Your cart contains a product from an excluded category that prevents this coupon code from being applied.
|
106
119
|
missing_taxon: You need to add a product from all applicable categories before applying this coupon code.
|
107
120
|
no_matching_taxons: You need to add a product from an applicable category before applying this coupon code.
|
108
|
-
solidus_friendly_promotions/
|
121
|
+
solidus_friendly_promotions/conditions/user:
|
109
122
|
no_user_specified: You need to login before applying this coupon code.
|
110
|
-
solidus_friendly_promotions/
|
123
|
+
solidus_friendly_promotions/conditions/user_logged_in:
|
111
124
|
no_user_specified: You need to login before applying this coupon code.
|
112
|
-
solidus_friendly_promotions/
|
113
|
-
solidus_friendly_promotions/
|
125
|
+
solidus_friendly_promotions/conditions/user_role:
|
126
|
+
solidus_friendly_promotions/conditions/minimum_quantity:
|
114
127
|
quantity_less_than_minimum:
|
115
128
|
one: "You need to add a least 1 applicable item to your order."
|
116
129
|
other: "You need to add a least %{count} applicable items to your order."
|
117
|
-
|
130
|
+
product_condition:
|
118
131
|
choose_products: Choose products
|
119
132
|
label: Order must contain %{select} these products
|
120
133
|
match_all: all of
|
@@ -124,19 +137,23 @@ en:
|
|
124
137
|
product_source:
|
125
138
|
group: From product group
|
126
139
|
manual: Manually choose
|
127
|
-
|
140
|
+
taxon_condition:
|
128
141
|
choose_taxons: Choose taxons
|
129
142
|
label: Order must contain %{select} of these taxons
|
130
143
|
match_all: all
|
131
144
|
match_any: at least one
|
132
145
|
match_none: none
|
146
|
+
line_item_option_value_condition:
|
147
|
+
add_product: Add product
|
148
|
+
option_value_condition:
|
149
|
+
add_product: Add product
|
133
150
|
crud:
|
134
151
|
add: Add
|
135
152
|
destroy: Delete
|
136
153
|
update: Update
|
137
154
|
admin:
|
138
155
|
promotions:
|
139
|
-
|
156
|
+
benefits:
|
140
157
|
calculator_label: Calculated by
|
141
158
|
activations_edit:
|
142
159
|
auto: All orders will attempt to use this promotion
|
@@ -153,7 +170,7 @@ en:
|
|
153
170
|
starts_at_placeholder: Immediately
|
154
171
|
codes_present: This promotion has promotion codes defined. You cannot select the apply automatically option.
|
155
172
|
edit:
|
156
|
-
|
173
|
+
order_conditions: Order Conditions
|
157
174
|
calculator:
|
158
175
|
add_tier: Add tier
|
159
176
|
promotion_status:
|
@@ -170,34 +187,34 @@ en:
|
|
170
187
|
subject: Promotion code batch finished
|
171
188
|
activerecord:
|
172
189
|
models:
|
173
|
-
solidus_friendly_promotions/
|
174
|
-
solidus_friendly_promotions/
|
175
|
-
solidus_friendly_promotions/
|
176
|
-
solidus_friendly_promotions/
|
190
|
+
solidus_friendly_promotions/benefits/adjust_shipment: Discount matching shipments
|
191
|
+
solidus_friendly_promotions/benefits/adjust_line_item: Discount matching line items
|
192
|
+
solidus_friendly_promotions/benefits/create_discounted_item: Create discounted line item
|
193
|
+
solidus_friendly_promotions/benefits/adjust_line_item_quantity_groups: Discount matching line items based on quantity groups
|
177
194
|
solidus_friendly_promotions/calculators/distributed_amount: Distributed Amount
|
178
|
-
solidus_friendly_promotions/calculators/percent:
|
195
|
+
solidus_friendly_promotions/calculators/percent: Percent
|
179
196
|
solidus_friendly_promotions/calculators/flat_rate: Flat Rate
|
180
197
|
solidus_friendly_promotions/calculators/flexi_rate: Flexible Rate
|
181
198
|
solidus_friendly_promotions/calculators/tiered_flat_rate: Tiered Flat Rate
|
182
199
|
solidus_friendly_promotions/calculators/tiered_percent: Tiered Percent
|
183
200
|
solidus_friendly_promotions/calculators/tiered_percent_on_eligible_item_quantity: Tiered Percent based on eligible item quantity
|
184
|
-
solidus_friendly_promotions/
|
185
|
-
solidus_friendly_promotions/
|
186
|
-
solidus_friendly_promotions/
|
187
|
-
solidus_friendly_promotions/
|
188
|
-
solidus_friendly_promotions/
|
189
|
-
solidus_friendly_promotions/
|
190
|
-
solidus_friendly_promotions/
|
191
|
-
solidus_friendly_promotions/
|
192
|
-
solidus_friendly_promotions/
|
193
|
-
solidus_friendly_promotions/
|
194
|
-
solidus_friendly_promotions/
|
195
|
-
solidus_friendly_promotions/
|
196
|
-
solidus_friendly_promotions/
|
197
|
-
solidus_friendly_promotions/
|
198
|
-
solidus_friendly_promotions/
|
199
|
-
solidus_friendly_promotions/
|
200
|
-
solidus_friendly_promotions/
|
201
|
+
solidus_friendly_promotions/conditions/first_order: First Order
|
202
|
+
solidus_friendly_promotions/conditions/first_repeat_purchase_since: First Repeat Purchase Since
|
203
|
+
solidus_friendly_promotions/conditions/item_total: Item Total
|
204
|
+
solidus_friendly_promotions/conditions/discounted_item_total: Item Total after previous lanes
|
205
|
+
solidus_friendly_promotions/conditions/landing_page: Landing Page
|
206
|
+
solidus_friendly_promotions/conditions/minimum_quantity: Minimum Quantity
|
207
|
+
solidus_friendly_promotions/conditions/nth_order: Nth Order
|
208
|
+
solidus_friendly_promotions/conditions/one_use_per_user: One Use Per User
|
209
|
+
solidus_friendly_promotions/conditions/option_value: Option Value(s)
|
210
|
+
solidus_friendly_promotions/conditions/line_item_option_value: Line Item Option Value(s)
|
211
|
+
solidus_friendly_promotions/conditions/product: Order Product(s)
|
212
|
+
solidus_friendly_promotions/conditions/line_item_product: Line Item Product(s)
|
213
|
+
solidus_friendly_promotions/conditions/taxon: Order Taxon(s)
|
214
|
+
solidus_friendly_promotions/conditions/line_item_taxon: Line Item Taxon(s)
|
215
|
+
solidus_friendly_promotions/conditions/user: User
|
216
|
+
solidus_friendly_promotions/conditions/user_logged_in: User Logged In
|
217
|
+
solidus_friendly_promotions/conditions/user_role: User Role(s)
|
201
218
|
solidus_friendly_promotions/promotion_code_batch:
|
202
219
|
one: Code batch
|
203
220
|
other: Code batches
|
@@ -210,57 +227,61 @@ en:
|
|
210
227
|
pre: Pre
|
211
228
|
default: Default
|
212
229
|
post: Post
|
213
|
-
solidus_friendly_promotions/
|
214
|
-
type:
|
215
|
-
solidus_friendly_promotions/
|
230
|
+
solidus_friendly_promotions/benefit:
|
231
|
+
type: Benefit Type
|
232
|
+
solidus_friendly_promotions/condition:
|
233
|
+
type: Condition Type
|
234
|
+
solidus_friendly_promotions/benefits/adjust_line_item:
|
216
235
|
description: Creates a promotion credit on matching line items
|
217
|
-
solidus_friendly_promotions/
|
236
|
+
solidus_friendly_promotions/benefits/adjust_shipment:
|
218
237
|
description: Creates a promotion credit on matching shipments
|
219
|
-
solidus_friendly_promotions/
|
238
|
+
solidus_friendly_promotions/benefits/create_discounted_item:
|
220
239
|
description: Creates a discounted item with the quantity the applicable line items.
|
221
240
|
preferred_quantity: Quantity per applicable line item quantity
|
222
241
|
preferred_necessary_quantity: Number of items needed for a discounted item
|
223
|
-
solidus_friendly_promotions/
|
242
|
+
solidus_friendly_promotions/conditions/first_order:
|
224
243
|
description: Must be the customer's first order
|
225
|
-
solidus_friendly_promotions/
|
226
|
-
description: Available only to
|
227
|
-
|
228
|
-
solidus_friendly_promotions/
|
229
|
-
description: Order total
|
230
|
-
|
244
|
+
solidus_friendly_promotions/conditions/first_repeat_purchase_since:
|
245
|
+
description: Available only to users who have not purchased in a while
|
246
|
+
preferred_days_ago: Last purchase was at least this many days ago
|
247
|
+
solidus_friendly_promotions/conditions/item_total:
|
248
|
+
description: Order total must be greater than or equal to the specified amount
|
249
|
+
preferred_operator: Operator
|
250
|
+
preferred_amount: Amount
|
251
|
+
solidus_friendly_promotions/conditions/landing_page:
|
231
252
|
description: Customer must have visited the specified page
|
232
|
-
solidus_friendly_promotions/
|
233
|
-
description: Apply a promotion to
|
253
|
+
solidus_friendly_promotions/conditions/nth_order:
|
254
|
+
description: Apply a promotion to the nth order a user has completed.
|
234
255
|
form_text: 'Apply this promotion on the users Nth order: '
|
235
|
-
solidus_friendly_promotions/
|
256
|
+
solidus_friendly_promotions/conditions/one_use_per_user:
|
236
257
|
description: Only one use per user
|
237
|
-
solidus_friendly_promotions/
|
258
|
+
solidus_friendly_promotions/conditions/option_value:
|
238
259
|
description: Order includes specified product(s) with matching option value(s)
|
239
260
|
preferred_line_item_applicable: Should also apply to line items
|
240
|
-
solidus_friendly_promotions/
|
261
|
+
solidus_friendly_promotions/conditions/line_item_option_value:
|
241
262
|
description: Line Item has specified product with matching option value
|
242
|
-
solidus_friendly_promotions/
|
263
|
+
solidus_friendly_promotions/conditions/minimum_quantity:
|
243
264
|
description: Order contains minimum quantity of applicable items
|
244
|
-
solidus_friendly_promotions/
|
265
|
+
solidus_friendly_promotions/conditions/product:
|
245
266
|
description: Order includes specified product(s)
|
246
267
|
line_item_level_description: 'Line item matches the specified products:'
|
247
268
|
preferred_line_item_applicable: Should also apply to line items
|
248
|
-
solidus_friendly_promotions/
|
269
|
+
solidus_friendly_promotions/conditions/line_item_product:
|
249
270
|
description: Line item matches specified product(s)
|
250
271
|
preferred_match_policy: Match Policy
|
251
|
-
solidus_friendly_promotions/
|
272
|
+
solidus_friendly_promotions/conditions/store:
|
252
273
|
description: Available only to the specified stores
|
253
|
-
solidus_friendly_promotions/
|
274
|
+
solidus_friendly_promotions/conditions/taxon:
|
254
275
|
description: Order includes products with specified taxon(s)
|
255
276
|
preferred_line_item_applicable: Should also apply to line items
|
256
|
-
solidus_friendly_promotions/
|
277
|
+
solidus_friendly_promotions/conditions/line_item_taxon:
|
257
278
|
description: Line Item has product with specified taxon(s)
|
258
279
|
preferred_match_policy: Match Policy
|
259
|
-
solidus_friendly_promotions/
|
280
|
+
solidus_friendly_promotions/conditions/user:
|
260
281
|
description: Available only to the specified users
|
261
|
-
solidus_friendly_promotions/
|
282
|
+
solidus_friendly_promotions/conditions/user_logged_in:
|
262
283
|
description: Available only to logged in users
|
263
|
-
solidus_friendly_promotions/
|
284
|
+
solidus_friendly_promotions/conditions/user_role:
|
264
285
|
description: Order includes User with specified Role(s)
|
265
286
|
solidus_friendly_promotions/calculators/tiered_flat_rate:
|
266
287
|
description: Flat Rate in tiers based on item amount
|
@@ -270,16 +291,26 @@ en:
|
|
270
291
|
description: Tiered percentage based on order's item total
|
271
292
|
preferred_base_percent: Base Percent
|
272
293
|
tiers: Tiers
|
294
|
+
order_item_total: Order Item Total
|
295
|
+
percent: Percent
|
273
296
|
solidus_friendly_promotions/calculators/tiered_percent_on_eligible_item_quantity:
|
274
297
|
description: Tiered percentage based on eligible item quantity
|
275
298
|
preferred_base_percent: Base Percent
|
276
299
|
tiers: Tiers
|
300
|
+
order_item_total: Order Item Total
|
301
|
+
discount: Discount
|
277
302
|
solidus_friendly_promotions/calculators/flat_rate:
|
278
303
|
description: Provides a flat rate discount
|
304
|
+
solidus_friendly_promotions/calculators/flexi_rate:
|
305
|
+
description: Calculates a discount for the first item and (separately) any additional items, with a maximum number of items that can be specified.
|
306
|
+
preferred_first_item: Discount for the first item
|
307
|
+
preferred_additional_item: Discount for additional items
|
308
|
+
preferred_max_items: Maximum number of items
|
309
|
+
preferred_currency: Currency
|
279
310
|
solidus_friendly_promotions/calculators/percent:
|
280
311
|
description: Provides a discount calculated by percent of the discountable amount of the item being discounted
|
281
312
|
solidus_friendly_promotions/calculators/distributed_amount:
|
282
|
-
description:
|
313
|
+
description: Distributes the configured amount among all eligible line items of the order.
|
283
314
|
explanation: |
|
284
315
|
<p>
|
285
316
|
This amount will be distributed to line items weighted relative to
|
@@ -316,17 +347,20 @@ en:
|
|
316
347
|
</tr>
|
317
348
|
</tbody>
|
318
349
|
</table>
|
350
|
+
preferred_amount: Amount
|
319
351
|
|
320
352
|
errors:
|
321
353
|
models:
|
322
|
-
solidus_friendly_promotions/
|
354
|
+
solidus_friendly_promotions/benefit:
|
323
355
|
attributes:
|
324
356
|
base:
|
325
|
-
cannot_destroy_if_order_completed:
|
326
|
-
solidus_friendly_promotions/
|
357
|
+
cannot_destroy_if_order_completed: Benefit has been applied to complete orders. It cannot be destroyed.
|
358
|
+
solidus_friendly_promotions/condition:
|
327
359
|
attributes:
|
328
|
-
|
329
|
-
|
360
|
+
benefit:
|
361
|
+
already_contains_condition_type: already contains this condition type
|
362
|
+
type:
|
363
|
+
invalid_condition_type: is not a valid condition type
|
330
364
|
solidus_friendly_promotions/promotion_code:
|
331
365
|
attributes:
|
332
366
|
base:
|
@@ -334,7 +368,7 @@ en:
|
|
334
368
|
spree/line_item:
|
335
369
|
attributes:
|
336
370
|
quantity:
|
337
|
-
cannot_be_changed_for_automated_items: cannot be changed on a line item managed by a promotion
|
371
|
+
cannot_be_changed_for_automated_items: cannot be changed on a line item managed by a promotion benefit
|
338
372
|
solidus_friendly_promotions/promotion:
|
339
373
|
attributes:
|
340
374
|
apply_automatically:
|
data/config/routes.rb
CHANGED
@@ -6,8 +6,9 @@ SolidusFriendlyPromotions::Engine.routes.draw do
|
|
6
6
|
resources :promotion_categories, except: [:show]
|
7
7
|
|
8
8
|
resources :promotions do
|
9
|
-
resources :
|
10
|
-
|
9
|
+
resources :benefits do
|
10
|
+
resources :conditions
|
11
|
+
end
|
11
12
|
resources :promotion_codes, only: [:index, :new, :create]
|
12
13
|
resources :promotion_code_batches, only: [:index, :new, :create] do
|
13
14
|
get "/download", to: "promotion_code_batches#download", defaults: {format: "csv"}
|
@@ -16,8 +16,8 @@ class AddDbCommentsToFriendlyPromotionRulesTaxons < ActiveRecord::Migration[6.1]
|
|
16
16
|
|
17
17
|
def friendly_promotion_rules_taxons_table_comment
|
18
18
|
<<~COMMENT
|
19
|
-
Join table between promotion rules and taxons. Only used if the promotion rule's type is SolidusFriendlyPromotion::
|
20
|
-
SolidusFriendlyPromotion::
|
19
|
+
Join table between promotion rules and taxons. Only used if the promotion rule's type is SolidusFriendlyPromotion::Conditions::Taxon or
|
20
|
+
SolidusFriendlyPromotion::Conditions::LineItemTaxon. Represents those taxons that the promotion rule matches on using its any/all/none
|
21
21
|
or include/exclude match policy.
|
22
22
|
COMMENT
|
23
23
|
end
|
@@ -16,7 +16,7 @@ class AddDbCommentsToFriendlyPromotionRulesUsers < ActiveRecord::Migration[6.1]
|
|
16
16
|
|
17
17
|
def friendly_promotion_rules_users_table_comment
|
18
18
|
<<~COMMENT
|
19
|
-
Join table between promotion rules and users. Used with promotion rules of type "SolidusFriendlyPromotions::
|
19
|
+
Join table between promotion rules and users. Used with promotion rules of type "SolidusFriendlyPromotions::Conditions::User".
|
20
20
|
An entry here indicates that a promotion is eligible for the user ID specified here.
|
21
21
|
COMMENT
|
22
22
|
end
|
@@ -38,7 +38,7 @@ class AddDbCommentsToFriendlyPromotionActions < ActiveRecord::Migration[6.1]
|
|
38
38
|
def type_comment
|
39
39
|
<<~COMMENT
|
40
40
|
A class name representing which promotion action this represents.
|
41
|
-
Usually SolidusFriendlyPromotions::
|
41
|
+
Usually SolidusFriendlyPromotions::PromotionAction::Adjust{LineItem,Shipment}.
|
42
42
|
COMMENT
|
43
43
|
end
|
44
44
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class AddActionReferenceToRules < ActiveRecord::Migration[7.0]
|
2
|
+
class LocalBenefit < ApplicationRecord
|
3
|
+
self.table_name = "friendly_promotion_actions"
|
4
|
+
has_many :actions, class_name: "SolidusFriendlyPromotions::Condition", foreign_key: :action_id
|
5
|
+
end
|
6
|
+
|
7
|
+
def up
|
8
|
+
remove_foreign_key :friendly_promotion_rules, :friendly_promotions
|
9
|
+
change_column :friendly_promotion_rules, :promotion_id, :integer, null: true
|
10
|
+
|
11
|
+
add_reference :friendly_promotion_rules, :action, index: {name: :rule}, null: true, foreign_key: {to_table: :friendly_promotion_actions}
|
12
|
+
|
13
|
+
SolidusFriendlyPromotions::Condition.reset_column_information
|
14
|
+
|
15
|
+
LocalBenefit.find_each do |action|
|
16
|
+
SolidusFriendlyPromotions::Condition.where(promotion_id: action.promotion_id).each do |rule|
|
17
|
+
rule.dup.tap do |new_rule|
|
18
|
+
new_rule.preload_relations.each do |relation|
|
19
|
+
new_rule.send(:"#{relation}=", rule.send(relation).dup)
|
20
|
+
end
|
21
|
+
new_rule.action = action
|
22
|
+
new_rule.save!
|
23
|
+
end
|
24
|
+
rule.destroy!
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def down
|
30
|
+
SolidusFriendlyPromotions::Condition.where.not(action_id: nil).delete_all
|
31
|
+
change_column :friendly_promotion_rules, :promotion_id, :integer, null: true
|
32
|
+
add_foreign_key :friendly_promotion_rules, :friendly_promotions, column: :promotion_id
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class RenamePromotionRulesToConditions < ActiveRecord::Migration[7.1]
|
2
|
+
def change
|
3
|
+
rename_table :friendly_promotion_rules, :friendly_conditions
|
4
|
+
rename_table :friendly_promotion_rules_stores, :friendly_condition_stores
|
5
|
+
rename_table :friendly_promotion_rules_taxons, :friendly_condition_taxons
|
6
|
+
rename_table :friendly_promotion_rules_users, :friendly_condition_users
|
7
|
+
rename_table :friendly_products_promotion_rules, :friendly_condition_products
|
8
|
+
rename_column :friendly_condition_stores, :promotion_rule_id, :condition_id
|
9
|
+
rename_column :friendly_condition_taxons, :promotion_rule_id, :condition_id
|
10
|
+
rename_column :friendly_condition_users, :promotion_rule_id, :condition_id
|
11
|
+
rename_column :friendly_condition_products, :promotion_rule_id, :condition_id
|
12
|
+
sql = <<~SQL
|
13
|
+
UPDATE friendly_conditions
|
14
|
+
SET type = REPLACE(type, 'SolidusFriendlyPromotions::Rules', 'SolidusFriendlyPromotions::Conditions')
|
15
|
+
SQL
|
16
|
+
|
17
|
+
execute(sql)
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class RenameFriendlyPromotionActionsToFriendlyBenefits < ActiveRecord::Migration[7.1]
|
2
|
+
def change
|
3
|
+
rename_table :friendly_promotion_actions, :friendly_benefits
|
4
|
+
rename_column :friendly_conditions, :action_id, :benefit_id
|
5
|
+
rename_column :spree_line_items, :managed_by_order_action_id, :managed_by_order_benefit_id
|
6
|
+
rename_column :friendly_shipping_rate_discounts, :promotion_action_id, :benefit_id
|
7
|
+
update_benefit_type_sql = <<~SQL
|
8
|
+
UPDATE friendly_benefits
|
9
|
+
SET type = REPLACE(type, 'SolidusFriendlyPromotions::Actions', 'SolidusFriendlyPromotions::Benefits')
|
10
|
+
SQL
|
11
|
+
execute(update_benefit_type_sql)
|
12
|
+
update_adjustment_source_type_sql = <<~SQL
|
13
|
+
UPDATE spree_adjustments
|
14
|
+
SET source_type = REPLACE(source_type, 'SolidusFriendlyPromotions::Actions', 'SolidusFriendlyPromotions::Benefits')
|
15
|
+
WHERE source_type LIKE 'SolidusFriendlyPromotions::Actions%'
|
16
|
+
SQL
|
17
|
+
execute(update_adjustment_source_type_sql)
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class UpdateColumnCommentsForBenefits < ActiveRecord::Migration[6.1]
|
2
|
+
def up
|
3
|
+
if connection.supports_comments?
|
4
|
+
change_table_comment(:friendly_benefits, friendly_benefits_table_comment)
|
5
|
+
change_column_comment(:friendly_benefits, :type, type_comment)
|
6
|
+
change_column_comment(:friendly_benefits, :preferences, preferences_comment)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def friendly_benefits_table_comment
|
13
|
+
<<~COMMENT
|
14
|
+
Single Table inheritance table. Represents what to do to an order when the linked promotion is eligible.
|
15
|
+
Promotions can have many benefits.
|
16
|
+
COMMENT
|
17
|
+
end
|
18
|
+
|
19
|
+
def type_comment
|
20
|
+
<<~COMMENT
|
21
|
+
A class name representing which benefit this represents.
|
22
|
+
Usually SolidusFriendlyPromotions::Benefits::Adjust{LineItem,Shipment}.
|
23
|
+
COMMENT
|
24
|
+
end
|
25
|
+
|
26
|
+
def preferences_comment
|
27
|
+
<<~COMMENT
|
28
|
+
Preferences for this benefit. Serialized YAML.
|
29
|
+
COMMENT
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class UpdateColumnCommentsForConditions < ActiveRecord::Migration[7.1]
|
2
|
+
def up
|
3
|
+
if connection.supports_comments?
|
4
|
+
change_table_comment(:friendly_conditions, friendly_conditions_table_comment)
|
5
|
+
change_column_comment(:friendly_conditions, :benefit_id, benefit_id_comment)
|
6
|
+
change_column_comment(:friendly_conditions, :preferences, preferences_comment)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def friendly_conditions_table_comment
|
13
|
+
<<~COMMENT
|
14
|
+
Represents a promotion benefit condition. A promotion benefit may have many conditions, which determine whether the benefit is eligible.
|
15
|
+
All conditions must be eligible for the benefit to be eligible. If there are no conditions, the benefit is always eligible.
|
16
|
+
COMMENT
|
17
|
+
end
|
18
|
+
|
19
|
+
def benefit_id_comment
|
20
|
+
<<~COMMENT
|
21
|
+
Foreign key to the friendly_benefits table.
|
22
|
+
COMMENT
|
23
|
+
end
|
24
|
+
|
25
|
+
def preferences_comment
|
26
|
+
<<~COMMENT
|
27
|
+
Preferences for this promotion condition. Serialized YAML column with preferences for this promotion condition.
|
28
|
+
COMMENT
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class UpdateColumnCommentsForConditionStores < ActiveRecord::Migration[7.1]
|
2
|
+
def up
|
3
|
+
if connection.supports_comments?
|
4
|
+
change_table_comment(:friendly_condition_stores, friendly_condition_stores_table_comment)
|
5
|
+
change_column_comment(:friendly_condition_stores, :condition_id, condition_id_comment)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def friendly_condition_stores_table_comment
|
12
|
+
<<~COMMENT
|
13
|
+
Join table between conditions and stores. Only used with the condition "Store", which checks that an order
|
14
|
+
has been placed in a particular Spree::Store instance.
|
15
|
+
COMMENT
|
16
|
+
end
|
17
|
+
|
18
|
+
def condition_id_comment
|
19
|
+
<<~COMMENT
|
20
|
+
Foreign key to the friendly_conditions table.
|
21
|
+
COMMENT
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class UpdateColumnCommentsForConditionProducts < ActiveRecord::Migration[7.1]
|
2
|
+
def up
|
3
|
+
if connection.supports_comments?
|
4
|
+
change_table_comment(:friendly_condition_products, friendly_condition_products_table_comment)
|
5
|
+
change_column_comment(:friendly_condition_products, :condition_id, condition_id_comment)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def friendly_condition_products_table_comment
|
12
|
+
<<~COMMENT
|
13
|
+
Join table between promotion conditions and products.
|
14
|
+
COMMENT
|
15
|
+
end
|
16
|
+
|
17
|
+
def condition_id_comment
|
18
|
+
<<~COMMENT
|
19
|
+
Foreign key to the friendly_conditions table.
|
20
|
+
COMMENT
|
21
|
+
end
|
22
|
+
end
|