Sha256: 5246245ab250734778381912fcbcacd7b8cd6cce502909bd0e3bc2148ac6bcea

Contents?: true

Size: 1.1 KB

Versions: 20

Compression:

Stored size: 1.1 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_amount
        safe_join(parts, "<br />".html_safe)
      end

      def display_shipment(shipment)
        parts = [
          "#{Spree.t(:shipment)} ##{shipment.number}",
          shipment.display_cost
        ]
        safe_join(parts, "<br />".html_safe)
      end

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
solidus_backend-2.4.2 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-2.4.1 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-2.3.1 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-2.2.2 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-2.1.1 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-2.4.0 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-2.4.0.rc1 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-2.4.0.beta1 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-2.3.0 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-2.3.0.rc3 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-2.3.0.rc2 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-2.3.0.rc1 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-2.3.0.beta1 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-2.2.1 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-2.2.0 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-2.2.0.rc1 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-2.2.0.beta1 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-2.1.0 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-2.1.0.rc1 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-2.1.0.beta1 app/helpers/spree/admin/adjustments_helper.rb