=begin Camaleon CMS is a content management system Copyright (C) 2015 by Owen Peredo Diaz Email: owenperedo@gmail.com This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License (GPLv3) for more details. =end class Plugins::Ecommerce::OrderDecorator < CamaleonCms::TermTaxonomyDecorator delegate_all # Define presentation-specific methods here. Helpers are accessed through # `helpers` (aka `h`). You can override attributes, for example: # # def created_at # helpers.content_tag :span, class: 'time' do # object.created_at.strftime("%a %m/%d/%y") # end # end def the_status case self.status when 'unpaid' "#{I18n.t('plugin.ecommerce.select.unpaid')}" when 'accepted' "#{I18n.t('plugin.ecommerce.select.accepted')}" when 'shipped' "#{I18n.t('plugin.ecommerce.select.shipped')}" when 'closed' "#{I18n.t('plugin.ecommerce.select.closed')}" when 'canceled' "#{I18n.t('plugin.ecommerce.select.canceled')}" else "#{I18n.t('plugin.ecommerce.select.received')}" end end def the_pay_status if object.paid? "#{I18n.t('plugin.ecommerce.select.received')}" elsif object.canceled? "#{I18n.t('plugin.ecommerce.select.canceled')}" elsif object.get_meta("payment", {})[:coupon].to_s.parameterize == 'free' "Free" else "#{I18n.t('plugin.ecommerce.select.unpaid')}" end end def the_url_tracking consignment_number = object.get_meta("payment")[:consignment_number] rescue 'none' object.shipping_method.options[:url_tracking].gsub("{{consignment_number}}", consignment_number) rescue "#{I18n.t('plugin.ecommerce.message.not_shipped')}" end end