Module: Spree::Stores::Setup

Extended by:
ActiveSupport::Concern
Included in:
Spree::Store
Defined in:
app/models/concerns/spree/stores/setup.rb

Instance Method Summary collapse

Instance Method Details

#payment_method_setup?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'app/models/concerns/spree/stores/setup.rb', line 47

def payment_method_setup?
  payment_methods.active.where.not(type: Spree::PaymentMethod::StoreCredit.to_s).any?
end

#setup_completed?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'app/models/concerns/spree/stores/setup.rb', line 39

def setup_completed?
  @setup_completed ||= setup_tasks_done == setup_tasks_total
end

#setup_percentageObject



43
44
45
# File 'app/models/concerns/spree/stores/setup.rb', line 43

def setup_percentage
  @setup_percentage ||= (setup_tasks_done / setup_tasks_total.to_f * 100).to_i
end

#setup_task_done?(task) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/models/concerns/spree/stores/setup.rb', line 6

def setup_task_done?(task)
  case task
  when :setup_payment_method
    payment_method_setup?
  when :setup_taxes_collection
    Spree::TaxRate.any?
  when :add_products
    products.any?
  when :set_customer_support_email
    customer_support_email.present?
  end
end

#setup_tasks_doneObject



35
36
37
# File 'app/models/concerns/spree/stores/setup.rb', line 35

def setup_tasks_done
  @setup_tasks_done = setup_tasks_list.select { |task| setup_task_done?(task) }.count
end

#setup_tasks_listObject



23
24
25
26
27
28
29
30
31
32
33
# File 'app/models/concerns/spree/stores/setup.rb', line 23

def setup_tasks_list
  return [] if deleted?

  @setup_tasks_list = []
  @setup_tasks_list << :setup_payment_method
  @setup_tasks_list << :add_products
  @setup_tasks_list << :set_customer_support_email
  @setup_tasks_list << :setup_taxes_collection

  @setup_tasks_list
end

#setup_tasks_totalObject



19
20
21
# File 'app/models/concerns/spree/stores/setup.rb', line 19

def setup_tasks_total
  @setup_tasks_total = setup_tasks_list.count
end