Class: Spree::Order

Inherits:
Object
  • Object
show all
Defined in:
app/models/spree/order_decorator.rb

Instance Method Summary collapse

Instance Method Details

#after_cancelObject

cancel order handler



17
18
19
20
21
22
# File 'app/models/spree/order_decorator.rb', line 17

def after_cancel
  exactor_connector = SpreeExactorConnector::SpreeExactorConnector.new
  exactor_connector.do_cancel!(self)
  update_column(:exactor_order_hash_sum, nil)
  super_after_cancel
end

#after_resumeObject

when order was resumed handler



25
26
27
28
29
30
# File 'app/models/spree/order_decorator.rb', line 25

def after_resume
  update_adjustments
  exactor_connector = SpreeExactorConnector::SpreeExactorConnector.new
  exactor_connector.do_checkout!(self)
  super_after_resume
end

#create_tax_charge!Object



52
53
54
55
56
57
58
59
60
# File 'app/models/spree/order_decorator.rb', line 52

def create_tax_charge!
  # destroy any previous adjustments (everything is recalculated from scratch)
  price_adjustments.each(&:destroy)
  if (adjustments.tax.reload.size!=1)
    adjustments.tax.each(&:destroy)
    TaxRate.match(self).each { |rate| rate.adjust(self) }
  end

end

#edit_orderObject



32
33
34
35
36
37
38
39
40
# File 'app/models/spree/order_decorator.rb', line 32

def edit_order
  exactor_connector = SpreeExactorConnector::SpreeExactorConnector.new
  if (!exactor_invoice_transaction.nil?)
    if (!exactor_commit_transaction.nil?)
      exactor_connector.do_cancel!(self)
    end
    exactor_connector.do_checkout!(self)
  end
end

#finalize!Object

check out handler



8
9
10
11
12
13
14
# File 'app/models/spree/order_decorator.rb', line 8

def finalize!
  exactor_connector = SpreeExactorConnector::SpreeExactorConnector.new
  #we can accidentally commit order with an old invoice id
  this_order = Spree::Order.find(self.id)
  exactor_connector.do_checkout!(this_order)
  super_finalize!
end

#super_after_cancelObject



4
# File 'app/models/spree/order_decorator.rb', line 4

alias :super_after_cancel :after_cancel

#super_after_resumeObject



5
# File 'app/models/spree/order_decorator.rb', line 5

alias :super_after_resume :after_resume

#super_finalize!Object



3
# File 'app/models/spree/order_decorator.rb', line 3

alias :super_finalize! :finalize!

#update_adjustmentsObject

this method is intended to add adjustment to old transactions which was created without our plugin REMARK: this method moved to OrderUpdater class in Spree 2.0.0



64
65
66
# File 'app/models/spree/order_decorator.rb', line 64

def update_adjustments
  self.updater.update_adjustments
end

#update_payment_stateObject

REMARK: this method moved to OrderUpdater class in Spree 2.0.0



43
44
45
# File 'app/models/spree/order_decorator.rb', line 43

def update_payment_state
  self.updater.update_payment_state
end

#update_shipment_stateObject

REMARK: this method moved to OrderUpdater class in Spree 2.0.0



48
49
50
# File 'app/models/spree/order_decorator.rb', line 48

def update_shipment_state
  self.updater.update_shipment_state
end