Class: Spina::Shop::ProductItem

Inherits:
ApplicationRecord show all
Defined in:
app/models/spina/shop/product_item.rb

Instance Method Summary collapse

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'app/models/spina/shop/product_item.rb', line 48

def active?
  active?
end

#cache_everythingObject



56
57
58
# File 'app/models/spina/shop/product_item.rb', line 56

def cache_everything
  cache_averages
end

#descriptionObject



32
33
34
# File 'app/models/spina/shop/product_item.rb', line 32

def description
  [product.name, name].compact.join(', ')
end

#in_stock?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'app/models/spina/shop/product_item.rb', line 44

def in_stock?
  stock_level > 0
end

#inactive?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'app/models/spina/shop/product_item.rb', line 52

def inactive?
  !active
end

#price_for_customer(customer) ⇒ Object

Get the price based on the one ordering. Can be different based on customer groups.



22
23
24
# File 'app/models/spina/shop/product_item.rb', line 22

def price_for_customer(customer)
  price
end

#product_imagesObject



36
37
38
# File 'app/models/spina/shop/product_item.rb', line 36

def product_images
  product.product_images
end

#short_descriptionObject

Short description is description and description is the Product’s name and ProductItem’s name combined. Like wtf.



28
29
30
# File 'app/models/spina/shop/product_item.rb', line 28

def short_description
  description
end

#weightObject



40
41
42
# File 'app/models/spina/shop/product_item.rb', line 40

def weight
  read_attribute(:weight) || BigDecimal(0)
end