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)


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

def active?
  true
end

#checkoutable?Boolean

Returns:

  • (Boolean)


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

def checkoutable?
  line_items.length > 0
end

#eot_subtotalObject



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

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

#reset_state!Object



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

def reset_state!
  self.state = wizard.steps.first
  save(validate: false) if persisted?
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



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

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

#to_paramObject



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

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

#total_eot_priceObject



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

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

#total_priceObject



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

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

#total_quantityObject



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

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

#total_vatObject



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

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

#wizardObject



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

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