Module: DiscountsHelper
- Defined in:
- app/helpers/discounts_helper.rb
Overview
== Schema Information
Table name: discounts
id :integer not null, primary key
coupon_id :integer not null
itemizable_type :string(50)
itemizable_id :integer not null
amount :decimal(8, 2)
notes :text
effective_date :datetime
blacklisted :boolean
user_amount :decimal(8, 2)
Instance Method Summary collapse
- #adjustable_calculation_tip(calc_method) ⇒ Object
- #discount_action_label(discount) ⇒ Object
- #discount_return_link ⇒ Object
Instance Method Details
#adjustable_calculation_tip(calc_method) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'app/helpers/discounts_helper.rb', line 28 def adjustable_calculation_tip(calc_method) return case calc_method when '+?' 'credit ($)' when '-?' 'discount ($)' when '?' 'adjustment (+$ or -$)' end end |
#discount_action_label(discount) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/discounts_helper.rb', line 18 def discount_action_label(discount) if discount.blacklisted? fa_icon('circle-plus', text: 'Enable') elsif discount.auto_apply fa_icon('circle-xmark', text: 'Disable') else fa_icon('trash', text: 'Remove') end end |
#discount_return_link ⇒ Object
39 40 41 42 43 44 |
# File 'app/helpers/discounts_helper.rb', line 39 def discount_return_link return_path = @return_path return_path ||= new_order_payment_path(@context_object) if @context_object.is_a?Order return_path ||= polymorphic_path(@context_object) link_to "Done with coupons", return_path, class: 'btn btn-primary' end |