Module: SolidusFriendlyPromotions
- Defined in:
- app/models/solidus_friendly_promotions/calculators/distributed_amount.rb,
lib/solidus_friendly_promotions.rb,
lib/solidus_friendly_promotions/engine.rb,
lib/solidus_friendly_promotions/version.rb,
lib/solidus_friendly_promotions/configuration.rb,
lib/solidus_friendly_promotions/promotion_map.rb,
app/models/solidus_friendly_promotions/benefit.rb,
lib/solidus_friendly_promotions/testing_support.rb,
app/models/solidus_friendly_promotions/condition.rb,
app/models/solidus_friendly_promotions/promotion.rb,
lib/solidus_friendly_promotions/nested_class_set.rb,
lib/solidus_friendly_promotions/promotion_migrator.rb,
lib/solidus_friendly_promotions/migrate_adjustments.rb,
app/models/solidus_friendly_promotions/item_discount.rb,
app/models/solidus_friendly_promotions/condition_user.rb,
app/models/solidus_friendly_promotions/promotion_code.rb,
lib/solidus_friendly_promotions/environment_extension.rb,
app/models/solidus_friendly_promotions/condition_store.rb,
app/models/solidus_friendly_promotions/condition_taxon.rb,
app/models/solidus_friendly_promotions/conditions/user.rb,
app/models/solidus_friendly_promotions/order_promotion.rb,
app/models/solidus_friendly_promotions/conditions/store.rb,
app/models/solidus_friendly_promotions/conditions/taxon.rb,
app/models/solidus_friendly_promotions/condition_product.rb,
lib/solidus_friendly_promotions/migrate_order_promotions.rb,
app/models/solidus_friendly_promotions/conditions/product.rb,
app/models/solidus_friendly_promotions/eligibility_result.rb,
app/models/solidus_friendly_promotions/promotion_category.rb,
app/models/solidus_friendly_promotions/calculators/percent.rb,
app/models/solidus_friendly_promotions/eligibility_results.rb,
app/models/solidus_friendly_promotions/conditions/nth_order.rb,
app/models/solidus_friendly_promotions/conditions/user_role.rb,
app/models/solidus_friendly_promotions/promotion_advertiser.rb,
app/models/solidus_friendly_promotions/promotion_code_batch.rb,
app/models/solidus_friendly_promotions/calculators/flat_rate.rb,
app/models/solidus_friendly_promotions/conditions/item_total.rb,
app/models/solidus_friendly_promotions/simple_order_contents.rb,
app/helpers/solidus_friendly_promotions/admin/benefits_helper.rb,
app/jobs/solidus_friendly_promotions/promotion_code_batch_job.rb,
app/models/solidus_friendly_promotions/calculators/flexi_rate.rb,
app/models/solidus_friendly_promotions/conditions/first_order.rb,
app/models/solidus_friendly_promotions/promotion_handler/null.rb,
app/models/solidus_friendly_promotions/promotion_handler/page.rb,
app/models/solidus_friendly_promotions/shipping_rate_discount.rb,
app/models/solidus_friendly_promotions/conditions/option_value.rb,
app/helpers/solidus_friendly_promotions/admin/conditions_helper.rb,
app/helpers/solidus_friendly_promotions/admin/promotions_helper.rb,
app/models/solidus_friendly_promotions/benefits/adjust_shipment.rb,
app/models/solidus_friendly_promotions/promotion_handler/coupon.rb,
app/models/solidus_friendly_promotions/benefits/adjust_line_item.rb,
app/models/solidus_friendly_promotions/conditions/user_logged_in.rb,
app/controllers/solidus_friendly_promotions/admin/base_controller.rb,
app/decorators/models/solidus_friendly_promotions/order_decorator.rb,
app/models/solidus_friendly_promotions/calculators/tiered_percent.rb,
app/models/solidus_friendly_promotions/conditions/line_item_taxon.rb,
app/models/solidus_friendly_promotions/conditions/shipping_method.rb,
app/models/solidus_friendly_promotions/conditions/minimum_quantity.rb,
app/models/solidus_friendly_promotions/conditions/one_use_per_user.rb,
app/models/solidus_friendly_promotions/distributed_amounts_handler.rb,
app/models/solidus_friendly_promotions/friendly_promotion_adjuster.rb,
app/mailers/solidus_friendly_promotions/promotion_code_batch_mailer.rb,
app/models/concerns/solidus_friendly_promotions/discountable_amount.rb,
app/models/solidus_friendly_promotions/calculators/tiered_flat_rate.rb,
app/models/solidus_friendly_promotions/conditions/line_item_product.rb,
app/models/solidus_friendly_promotions/promotion_code/batch_builder.rb,
app/decorators/models/solidus_friendly_promotions/shipment_decorator.rb,
lib/generators/solidus_friendly_promotions/install/install_generator.rb,
app/controllers/solidus_friendly_promotions/admin/benefits_controller.rb,
app/decorators/models/solidus_friendly_promotions/line_item_decorator.rb,
app/decorators/models/solidus_friendly_promotions/adjustment_decorator.rb,
app/models/concerns/solidus_friendly_promotions/benefits/order_benefit.rb,
app/models/solidus_friendly_promotions/benefits/create_discounted_item.rb,
app/controllers/solidus_friendly_promotions/admin/conditions_controller.rb,
app/controllers/solidus_friendly_promotions/admin/promotions_controller.rb,
app/models/solidus_friendly_promotions/conditions/discounted_item_total.rb,
app/models/solidus_friendly_promotions/conditions/line_item_option_value.rb,
app/decorators/models/solidus_friendly_promotions/shipping_rate_decorator.rb,
app/controllers/solidus_friendly_promotions/admin/promotion_codes_controller.rb,
app/models/solidus_friendly_promotions/conditions/first_repeat_purchase_since.rb,
app/decorators/models/solidus_friendly_promotions/order_recalculator_decorator.rb,
app/models/solidus_friendly_promotions/migration_support/order_promotion_syncer.rb,
app/models/concerns/solidus_friendly_promotions/calculators/promotion_calculator.rb,
app/models/concerns/solidus_friendly_promotions/conditions/order_level_condition.rb,
app/models/solidus_friendly_promotions/benefits/adjust_line_item_quantity_groups.rb,
app/controllers/solidus_friendly_promotions/admin/promotion_categories_controller.rb,
app/models/solidus_friendly_promotions/friendly_promotion_adjuster/discount_order.rb,
app/models/solidus_friendly_promotions/friendly_promotion_adjuster/load_promotions.rb,
app/controllers/solidus_friendly_promotions/admin/promotion_code_batches_controller.rb,
app/models/concerns/solidus_friendly_promotions/conditions/shipment_level_condition.rb,
app/models/solidus_friendly_promotions/friendly_promotion_adjuster/choose_discounts.rb,
app/models/concerns/solidus_friendly_promotions/conditions/line_item_level_condition.rb,
app/models/solidus_friendly_promotions/permission_sets/friendly_promotion_management.rb,
app/models/solidus_friendly_promotions/calculators/tiered_percent_on_eligible_item_quantity.rb,
app/models/solidus_friendly_promotions/friendly_promotion_adjuster/persist_discounted_order.rb,
app/models/concerns/solidus_friendly_promotions/conditions/line_item_applicable_order_condition.rb
Overview
This is a calculator for line item adjustment actions. It accepts a line item and calculates its weighted adjustment amount based on the value of the preferred amount and the price of the other line items. More expensive line items will receive a greater share of the preferred amount.
Defined Under Namespace
Modules: AdjustmentDecorator, Admin, Benefits, Calculators, Conditions, DiscountableAmount, EnvironmentExtension, Generators, LineItemDecorator, MigrationSupport, OrderDecorator, OrderRecalculatorDecorator, PermissionSets, PromotionHandler, ShipmentDecorator, ShippingRateDecorator, TestingSupport Classes: Benefit, Condition, ConditionProduct, ConditionStore, ConditionTaxon, ConditionUser, Configuration, DistributedAmountsHandler, EligibilityResult, EligibilityResults, Engine, FriendlyPromotionAdjuster, ItemDiscount, MigrateAdjustments, MigrateOrderPromotions, NestedClassSet, OrderPromotion, Promotion, PromotionAdvertiser, PromotionCategory, PromotionCode, PromotionCodeBatch, PromotionCodeBatchJob, PromotionCodeBatchMailer, PromotionMigrator, ShippingRateDiscount, SimpleOrderContents
Constant Summary collapse
- VERSION =
"1.9.3"
- PROMOTION_MAP =
{ conditions: { Spree::Promotion::Rules::ItemTotal => SolidusFriendlyPromotions::Conditions::ItemTotal, Spree::Promotion::Rules::Product => SolidusFriendlyPromotions::Conditions::Product, Spree::Promotion::Rules::User => SolidusFriendlyPromotions::Conditions::User, Spree::Promotion::Rules::FirstOrder => SolidusFriendlyPromotions::Conditions::FirstOrder, Spree::Promotion::Rules::UserLoggedIn => SolidusFriendlyPromotions::Conditions::UserLoggedIn, Spree::Promotion::Rules::OneUsePerUser => SolidusFriendlyPromotions::Conditions::OneUsePerUser, Spree::Promotion::Rules::Taxon => SolidusFriendlyPromotions::Conditions::Taxon, Spree::Promotion::Rules::NthOrder => SolidusFriendlyPromotions::Conditions::NthOrder, Spree::Promotion::Rules::OptionValue => SolidusFriendlyPromotions::Conditions::OptionValue, Spree::Promotion::Rules::FirstRepeatPurchaseSince => SolidusFriendlyPromotions::Conditions::FirstRepeatPurchaseSince, Spree::Promotion::Rules::UserRole => SolidusFriendlyPromotions::Conditions::UserRole, Spree::Promotion::Rules::Store => SolidusFriendlyPromotions::Conditions::Store }, actions: { Spree::Promotion::Actions::CreateAdjustment => ->(old_action) { calculator = case old_action.calculator when Spree::Calculator::FlatRate SolidusFriendlyPromotions::Calculators::DistributedAmount.new(preferences: old_action.calculator.preferences) when Spree::Calculator::FlatPercentItemTotal SolidusFriendlyPromotions::Calculators::Percent.new(preferred_percent: old_action.calculator.preferred_flat_percent) end SolidusFriendlyPromotions::Benefits::AdjustLineItem.new( calculator: calculator ) }, Spree::Promotion::Actions::CreateItemAdjustments => ->(old_action) { preferences = old_action.calculator.preferences calculator = case old_action.calculator when Spree::Calculator::FlatRate SolidusFriendlyPromotions::Calculators::FlatRate.new(preferences: preferences) when Spree::Calculator::PercentOnLineItem SolidusFriendlyPromotions::Calculators::Percent.new(preferences: preferences) when Spree::Calculator::FlexiRate SolidusFriendlyPromotions::Calculators::FlexiRate.new(preferences: preferences) when Spree::Calculator::DistributedAmount SolidusFriendlyPromotions::Calculators::DistributedAmount.new(preferences: preferences) when Spree::Calculator::TieredFlatRate SolidusFriendlyPromotions::Calculators::TieredFlatRate.new(preferences: preferences) when Spree::Calculator::TieredPercent SolidusFriendlyPromotions::Calculators::TieredPercent.new(preferences: preferences) end SolidusFriendlyPromotions::Benefits::AdjustLineItem.new( calculator: calculator ) }, Spree::Promotion::Actions::CreateQuantityAdjustments => ->(old_action) { preferences = old_action.calculator.preferences calculator = case old_action.calculator when Spree::Calculator::FlatRate SolidusFriendlyPromotions::Calculators::FlatRate.new(preferences: preferences) when Spree::Calculator::PercentOnLineItem SolidusFriendlyPromotions::Calculators::Percent.new(preferences: preferences) when Spree::Calculator::FlexiRate SolidusFriendlyPromotions::Calculators::FlexiRate.new(preferences: preferences) when Spree::Calculator::DistributedAmount SolidusFriendlyPromotions::Calculators::DistributedAmount.new(preferences: preferences) when Spree::Calculator::TieredFlatRate SolidusFriendlyPromotions::Calculators::TieredFlatRate.new(preferences: preferences) when Spree::Calculator::TieredPercent SolidusFriendlyPromotions::Calculators::TieredPercent.new(preferences: preferences) end SolidusFriendlyPromotions::Benefits::AdjustLineItemQuantityGroups.new( preferred_group_size: old_action.preferred_group_size, calculator: calculator ) }, Spree::Promotion::Actions::FreeShipping => ->(old_action) { SolidusFriendlyPromotions::Benefits::AdjustShipment.new( calculator: SolidusFriendlyPromotions::Calculators::Percent.new( preferred_percent: 100 ) ) } } }
Instance Attribute Summary collapse
-
#importmap ⇒ Object
JS Importmap instance.
Class Method Summary collapse
- .configuration ⇒ Object (also: config)
- .configure {|configuration| ... } ⇒ Object
- .table_name_prefix ⇒ Object
Instance Attribute Details
#importmap ⇒ Object
JS Importmap instance
17 18 19 |
# File 'lib/solidus_friendly_promotions.rb', line 17 def importmap @importmap end |
Class Method Details
.configuration ⇒ Object Also known as: config
119 120 121 |
# File 'lib/solidus_friendly_promotions/configuration.rb', line 119 def configuration @configuration ||= Configuration.new end |
.configure {|configuration| ... } ⇒ Object
125 126 127 |
# File 'lib/solidus_friendly_promotions/configuration.rb', line 125 def configure yield configuration end |
.table_name_prefix ⇒ Object
12 13 14 |
# File 'lib/solidus_friendly_promotions.rb', line 12 def self.table_name_prefix "friendly_" end |