Sha256: 7ba579c165df6a33577b2596d32c6781295fef580f70e7426cfc0c766994b46c

Contents?: true

Size: 1.13 KB

Versions: 31

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

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 = [
          "#{t('spree.shipment')} ##{shipment.number}",
          shipment.display_cost
        ]
        safe_join(parts, "<br>".html_safe)
      end

      def display_order(_order)
        t('spree.order')
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
solidus_backend-4.4.2 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-4.4.1 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-4.4.0 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-4.3.4 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-4.2.4 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-4.1.5 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-4.3.3 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-4.3.2 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-4.1.4 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-4.3.1 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-4.3.0 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-4.2.3 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-4.1.3 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-4.0.4 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-3.4.6 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-4.0.3 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-4.1.2 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-4.2.2 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-3.4.5 app/helpers/spree/admin/adjustments_helper.rb
solidus_backend-4.2.1 app/helpers/spree/admin/adjustments_helper.rb