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)
View helper for discount actions.
Instance Method Summary collapse
-
#adjustable_calculation_tip(calc_method) ⇒ String?
Returns a human-readable description of an adjustable calculation method.
-
#discount_action_label(discount) ⇒ String
Renders the icon/label for the discount toggle/remove action.
-
#discount_return_link ⇒ String
Renders the "Done with coupons" return link for the discount flow.
Instance Method Details
#adjustable_calculation_tip(calc_method) ⇒ String?
Returns a human-readable description of an adjustable calculation method.
35 36 37 38 39 40 41 42 43 44 |
# File 'app/helpers/discounts_helper.rb', line 35 def adjustable_calculation_tip(calc_method) case calc_method when '+?' 'credit ($)' when '-?' 'discount ($)' when '?' 'adjustment (+$ or -$)' end end |
#discount_action_label(discount) ⇒ String
Renders the icon/label for the discount toggle/remove action.
22 23 24 25 26 27 28 29 30 |
# File 'app/helpers/discounts_helper.rb', line 22 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 ⇒ String
Renders the "Done with coupons" return link for the discount flow.
48 49 50 51 52 53 |
# File 'app/helpers/discounts_helper.rb', line 48 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 |