Module: Comable::Checkout

Extended by:
ActiveSupport::Concern
Included in:
Order
Defined in:
app/models/concerns/comable/checkout.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#allow_cancel?Boolean

Returns:

  • (Boolean)


73
74
75
76
77
# File 'app/models/concerns/comable/checkout.rb', line 73

def allow_cancel?
  # TODO: Implement shipments
  # !shipments.exists?
  true
end

#allow_return?Boolean

Returns:

  • (Boolean)


79
80
81
82
83
# File 'app/models/concerns/comable/checkout.rb', line 79

def allow_return?
  # TODO: Implement shipments
  # shipments.exists?
  false
end

#delivery_required?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'app/models/concerns/comable/checkout.rb', line 61

def delivery_required?
  ship_address.nil? || ship_address.new_record?
end

#orderer_required?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'app/models/concerns/comable/checkout.rb', line 57

def orderer_required?
  bill_address.nil? || bill_address.new_record?
end

#payment_required?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'app/models/concerns/comable/checkout.rb', line 65

def payment_required?
  Comable::PaymentMethod.exists? && payment.nil?
end

#shipment_required?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'app/models/concerns/comable/checkout.rb', line 69

def shipment_required?
  Comable::ShipmentMethod.activated.exists? && shipment.nil?
end

#stated?(target_state) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
54
55
# File 'app/models/concerns/comable/checkout.rb', line 51

def stated?(target_state)
  target_state_index = self.class.state_names.index(target_state.to_sym)
  current_state_index = self.class.state_names.index(state_name)
  target_state_index < current_state_index
end