Class: Workarea::Storefront::LegacyOrderItemViewModel

Inherits:
ApplicationViewModel
  • Object
show all
Defined in:
app/view_models/workarea/storefront/legacy_order_item_view_model.rb

Instance Method Summary collapse

Instance Method Details

#has_options?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'app/view_models/workarea/storefront/legacy_order_item_view_model.rb', line 12

def has_options?
  model.details.present?
end

#imageObject



29
30
31
32
33
34
35
# File 'app/view_models/workarea/storefront/legacy_order_item_view_model.rb', line 29

def image
  if product.present?
    product.primary_image
  else
    Catalog::ProductPlaceholderImage.cached
  end
end

#productObject



21
22
23
24
25
26
27
# File 'app/view_models/workarea/storefront/legacy_order_item_view_model.rb', line 21

def product
  return nil if product_id.blank?
  return @product if defined?(@product)

  model = Catalog::Product.find(product_id) rescue nil
  @product = model.present? ? ProductViewModel.wrap(model, sku: sku) : nil
end

#product_nameObject



16
17
18
19
# File 'app/view_models/workarea/storefront/legacy_order_item_view_model.rb', line 16

def product_name
  return sku_name unless product.present?
  product.name
end

#sku_nameObject



4
5
6
# File 'app/view_models/workarea/storefront/legacy_order_item_view_model.rb', line 4

def sku_name
  name
end

#total_priceObject



8
9
10
# File 'app/view_models/workarea/storefront/legacy_order_item_view_model.rb', line 8

def total_price
  price
end