Class: Plugins::Ecommerce::CouponDecorator
- Inherits:
-
CamaleonCms::TermTaxonomyDecorator
- Object
- CamaleonCms::TermTaxonomyDecorator
- Plugins::Ecommerce::CouponDecorator
- Defined in:
- app/decorators/plugins/ecommerce/coupon_decorator.rb
Instance Method Summary collapse
-
#the_amount ⇒ Object
return humanized the amount/value of the coupon.
-
#the_code ⇒ Object
return the code of the coupon.
-
#the_status ⇒ Object
return the html text status of the coupon.
Instance Method Details
#the_amount ⇒ Object
return humanized the amount/value of the coupon
10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/decorators/plugins/ecommerce/coupon_decorator.rb', line 10 def the_amount opts = object. case opts[:discount_type] when 'percent' "#{opts[:amount].to_f}%" when 'money' h.e_parse_price(opts[:amount].to_f) else I18n.t('plugins.ecommerce.table.free_shipping', default: 'Free Shipping') end end |
#the_code ⇒ Object
return the code of the coupon
5 6 7 |
# File 'app/decorators/plugins/ecommerce/coupon_decorator.rb', line 5 def the_code object.slug.to_s.upcase end |
#the_status ⇒ Object
return the html text status of the coupon
23 24 25 26 27 28 29 30 31 32 |
# File 'app/decorators/plugins/ecommerce/coupon_decorator.rb', line 23 def the_status opts = object. if "#{opts[:expirate_date]} 23:59:59".to_datetime.to_i < Time.now.to_i "<span class='label label-danger'>#{I18n.t('plugins.ecommerce.table.expired')} </span>" elsif object.status.to_s.to_bool "<span class='label label-success'>#{I18n.t('plugins.ecommerce.active')} </span>" else "<span class='label label-default'>#{I18n.t('plugins.ecommerce.not_active')} </span>" end end |