Sha256: 09d6de0f40187f8a2749ac80f64ba66f5e8b644fda3ce36762db4b3e7f13a08b

Contents?: true

Size: 951 Bytes

Versions: 28

Compression:

Stored size: 951 Bytes

Contents

module Workarea
  module Storefront
    class InventoryStatusViewModel < ApplicationViewModel
      def message
        return '' if model.nil?

        if inventory.available?
          ::I18n.t('workarea.storefront.products.in_stock')
        elsif inventory.low_inventory?
          ::I18n.t(
            'workarea.storefront.products.few_left',
            quantity: available_to_sell
          )
        elsif inventory.backordered? && backordered_until.present?
          ::I18n.t(
            'workarea.storefront.products.ships_on',
            date: backordered_until.to_date.to_s(:short)
          )
        elsif inventory.backordered?
          ::I18n.t('workarea.storefront.products.backordered')
        elsif inventory.out_of_stock?
          ::I18n.t('workarea.storefront.products.out_of_stock')
        end
      end

      def inventory
        @inventory ||= Inventory::Collection.new(model.id, [model])
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
workarea-storefront-3.5.27 app/view_models/workarea/storefront/inventory_status_view_model.rb
workarea-storefront-3.5.26 app/view_models/workarea/storefront/inventory_status_view_model.rb
workarea-storefront-3.5.25 app/view_models/workarea/storefront/inventory_status_view_model.rb
workarea-storefront-3.5.23 app/view_models/workarea/storefront/inventory_status_view_model.rb
workarea-storefront-3.5.22 app/view_models/workarea/storefront/inventory_status_view_model.rb
workarea-storefront-3.5.21 app/view_models/workarea/storefront/inventory_status_view_model.rb
workarea-storefront-3.5.20 app/view_models/workarea/storefront/inventory_status_view_model.rb
workarea-storefront-3.5.19 app/view_models/workarea/storefront/inventory_status_view_model.rb
workarea-storefront-3.5.18 app/view_models/workarea/storefront/inventory_status_view_model.rb
workarea-storefront-3.5.17 app/view_models/workarea/storefront/inventory_status_view_model.rb
workarea-storefront-3.5.16 app/view_models/workarea/storefront/inventory_status_view_model.rb
workarea-storefront-3.5.15 app/view_models/workarea/storefront/inventory_status_view_model.rb
workarea-storefront-3.5.14 app/view_models/workarea/storefront/inventory_status_view_model.rb
workarea-storefront-3.5.13 app/view_models/workarea/storefront/inventory_status_view_model.rb
workarea-storefront-3.5.12 app/view_models/workarea/storefront/inventory_status_view_model.rb
workarea-storefront-3.5.11 app/view_models/workarea/storefront/inventory_status_view_model.rb
workarea-storefront-3.5.10 app/view_models/workarea/storefront/inventory_status_view_model.rb
workarea-storefront-3.5.9 app/view_models/workarea/storefront/inventory_status_view_model.rb
workarea-storefront-3.5.8 app/view_models/workarea/storefront/inventory_status_view_model.rb
workarea-storefront-3.5.7 app/view_models/workarea/storefront/inventory_status_view_model.rb