Sha256: 5871ed0102c2e25ec266c49f7765ec4ca3386024640b176e76349313c30eeb9c

Contents?: true

Size: 1.03 KB

Versions: 10

Compression:

Stored size: 1.03 KB

Contents

module Spree
  module Admin
    module AdjustmentsHelper
      def adjustment_state(adjustment)
        icon = adjustment.finalized? ? 'lock' : 'unlock'
        content_tag(:span, '', class: "fa fa-#{icon}")
      end

      def display_adjustable(adjustable)
        case adjustable
          when Spree::LineItem
            display_line_item(adjustable)
          when Spree::Shipment
            display_shipment(adjustable)
          when Spree::Order
            display_order(adjustable)
        end

      end

      private

      def display_line_item(line_item)
        variant = line_item.variant
        parts = []
        parts << variant.product.name
        parts << "(#{variant.options_text})" if variant.options_text.present?
        parts << line_item.display_total
        parts.join("<br>").html_safe
      end

      def display_shipment(shipment)
        "#{Spree.t(:shipment)} ##{shipment.number}<br>#{shipment.display_cost}".html_safe
      end

      def display_order(order)
        Spree.t(:order)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
solidus_backend-1.2.0 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-1.2.0.rc2 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-1.1.2 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-1.2.0.rc1 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-1.2.0.beta1 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-1.1.1 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-1.1.0 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-1.1.0.pre2 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-1.1.0.pre1 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-1.1.0.beta1 app/helpers/spree/admin/adjustments_helper.rb