Sha256: b17064f00ca98370b84a2b280c3d1aeabdd73561ccde74b28604859e62ca2476

Contents?: true

Size: 1.01 KB

Versions: 6

Compression:

Stored size: 1.01 KB

Contents

class Plugins::Ecommerce::CouponDecorator < CamaleonCms::TermTaxonomyDecorator
  delegate_all

  # return the code of the coupon
  def the_code
    object.slug.to_s.upcase
  end

  # return humanized the amount/value of the coupon
  def the_amount
    opts = object.options
    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

  # return the html text status of the coupon
  def the_status
    opts = object.options
    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
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
camaleon_ecommerce-2.0.4 app/decorators/plugins/ecommerce/coupon_decorator.rb
camaleon_ecommerce-2.0.3 app/decorators/plugins/ecommerce/coupon_decorator.rb
camaleon_ecommerce-2.0.2 app/decorators/plugins/ecommerce/coupon_decorator.rb
camaleon_ecommerce-2.0.1 app/decorators/plugins/ecommerce/coupon_decorator.rb
camaleon_ecommerce-2.0.0 app/decorators/plugins/ecommerce/coupon_decorator.rb
camaleon_ecommerce-1.2.1 app/decorators/plugins/ecommerce/coupon_decorator.rb