Class: Stall::ProductList

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/stall/product_list.rb

Direct Known Subclasses

Cart

Instance Method Summary collapse

Instance Method Details

#reset_state!Object



20
21
22
# File 'app/models/stall/product_list.rb', line 20

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

#stateObject



16
17
18
# File 'app/models/stall/product_list.rb', line 16

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

#to_paramObject



24
25
26
# File 'app/models/stall/product_list.rb', line 24

def to_param
  token
end

#total_eot_priceObject



32
33
34
# File 'app/models/stall/product_list.rb', line 32

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

#total_priceObject



28
29
30
# File 'app/models/stall/product_list.rb', line 28

def total_price
  line_items.map(&:price).sum
end

#total_quantityObject



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

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

#total_vatObject



36
37
38
# File 'app/models/stall/product_list.rb', line 36

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

#wizardObject



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/models/stall/product_list.rb', line 44

def wizard
  @wizard ||= begin
    wizard_name = Stall.config.default_checkout_wizard

    if (wizard = Stall::Utils.try_load_constant(wizard_name))
      wizard
    else
      raise Stall::Checkout::WizardNotFoundError.new,
        "The checkout wizard #{ wizard_name } was not found. You must generate it " +
        "with `rails g stall:wizard #{ wizard_name.underscore.gsub('_checkout_wizard', '') }`"
    end
  end
end