Module: Stall::Models::ProductList

Extended by:
ActiveSupport::Concern
Included in:
ProductList
Defined in:
app/models/stall/models/product_list.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


88
89
90
# File 'app/models/stall/models/product_list.rb', line 88

def active?
  true
end

#checkoutable?Boolean

Returns:

  • (Boolean)


84
85
86
# File 'app/models/stall/models/product_list.rb', line 84

def checkoutable?
  line_items.length > 0
end

#eot_subtotalObject



58
59
60
# File 'app/models/stall/models/product_list.rb', line 58

def eot_subtotal
  line_items.map(&:eot_price).sum
end

#reset_state!Object



44
45
46
# File 'app/models/stall/models/product_list.rb', line 44

def reset_state!
  update_column(:state, wizard.steps.first)
end

#stateObject



40
41
42
# File 'app/models/stall/models/product_list.rb', line 40

def state
  read_attribute(:state).try(:to_sym)
end

#subtotalObject



52
53
54
55
56
# File 'app/models/stall/models/product_list.rb', line 52

def subtotal
  price = line_items.map(&:price).sum
  price = Money.new(price, currency) unless Money === price
  price
end

#to_paramObject



48
49
50
# File 'app/models/stall/models/product_list.rb', line 48

def to_param
  persisted? ? token : 'empty-cart'
end

#total_eot_priceObject



68
69
70
# File 'app/models/stall/models/product_list.rb', line 68

def total_eot_price
  items.map(&:eot_price).sum
end

#total_priceObject



62
63
64
65
66
# File 'app/models/stall/models/product_list.rb', line 62

def total_price
  price = items.map(&:price).sum
  price = Money.new(price, currency) unless Money === price
  price
end

#total_quantityObject



76
77
78
# File 'app/models/stall/models/product_list.rb', line 76

def total_quantity
  line_items.map(&:quantity).sum
end

#total_vatObject



72
73
74
# File 'app/models/stall/models/product_list.rb', line 72

def total_vat
  items.map(&:vat).sum
end

#wizardObject



80
81
82
# File 'app/models/stall/models/product_list.rb', line 80

def wizard
  @wizard ||= self.class.wizard
end