我試圖刪除2個結帳步驟。 我試圖按照網站http://guides.spreecommerce.com/checkout.html 中的文檔,但仍然沒有任何反應。Spree結賬 - 刪除步驟
我使用 施普雷1.1.2 紅寶石1.9.2p318 的Rails 3.2.6 的Ubuntu 12.04(精確)32位
我會告訴你我做了什麼,你會告訴我什麼修理。 我應該更改文件的名稱或位置嗎? 還是應該更換其他文件? 我該如何調試它?
我創建了一個新的文件 「應用程序/模型/大禮包/ order_decorator.rb」(也嘗試過 「應用程序/模型/ order_decorator.rb」 下)
module SpreeCustomExtension
class Engine < Rails::Engine
def self.activate
Spree::Order.class_eval do
StateMachine::Machine.ignore_method_conflicts = true # I HAVE ADDED THOSE 2 LINES LATER, HOPING IT WOULD HELP ME,
Spree::Order.state_machines.clear # IT DIDN'T.
# customize the checkout state machine
Order.state_machines[:state] = StateMachine::Machine.new(Order, :initial => 'cart') do
after_transition :to => 'complete', :do => :complete_order
before_transition :to => 'complete', :do => :process_payment
event :next do
transition :from => 'cart', :to => 'payment'
transition :from => 'payment', :to => 'complete'
end
event :cancel do
transition :to => 'canceled', :if => :allow_cancel?
end
event :return do
transition :to => 'returned', :from => 'awaiting_return'
end
event :resume do
transition :to => 'resumed', :from => 'canceled', :if => :allow_resume?
end
event :authorize_return do
transition :to => 'awaiting_return'
end
before_transition :to => 'complete' do |order|
begin
order.process_payments!
rescue Core::GatewayError
!!Spree::Config[:allow_checkout_on_gateway_error]
end
end
before_transition :to => ['delivery'] do |order|
order.shipments.each { |s| s.destroy unless s.shipping_method.available_to_order?(order) }
end
after_transition :to => 'complete', :do => :finalize!
after_transition :to => 'delivery', :do => :create_tax_charge!
after_transition :to => 'payment', :do => :create_shipment!
after_transition :to => 'resumed', :do => :after_resume
after_transition :to => 'canceled', :do => :after_cancel
end
end
end
end
end
然後我嘗試了不同的代碼相同的文件,仍然沒有動靜
Spree::Order.class_eval do
StateMachine::Machine.ignore_method_conflicts = true
Spree::Order.state_machines.clear
state_machine :initial => 'cart', :use_transactions => false do
event :next do
transition :from => 'cart', :to => 'payment', :if => :payment_required?
transition :from => 'cart', :to => 'complete'
transition :from => 'confirm', :to => 'complete'
# note: some payment methods will not support a confirm step
transition :from => 'payment', :to => 'confirm',
:if => Proc.new { |order| order.payment_method && order.payment_method.payment_profiles_supported? }
transition :from => 'payment', :to => 'complete'
end
event :cancel do
transition :to => 'canceled', :if => :allow_cancel?
end
event :return do
transition :to => 'returned', :from => 'awaiting_return'
end
event :resume do
transition :to => 'resumed', :from => 'canceled', :if => :allow_resume?
end
event :authorize_return do
transition :to => 'awaiting_return'
end
before_transition :to => 'complete' do |order|
begin
order.process_payments!
rescue Core::GatewayError
if Spree::Config[:allow_checkout_on_gateway_error]
true
else
false
end
end
end
before_transition :to => ['delivery'] do |order|
order.shipments.each { |s| s.destroy unless s.shipping_method.available_to_order?(order) }
end
after_transition :to => 'complete', :do => :finalize!
after_transition :to => 'delivery', :do => :create_tax_charge!
after_transition :to => 'payment', :do => :create_shipment!
after_transition :to => 'resumed', :do => :after_resume
after_transition :to => 'canceled', :do => :after_cancel
end
end
我有類似的問題。我發現,當我試圖繼續進程時,步驟實際上被刪除,所以問題出現在另一個地方。在調試時,我發現CheckoutController處理'/ checkout',並且有以下參數:{「state」=>「address」}我不知道參數是如何到達的,但我認爲這是問題所在。 – 2012-07-17 21:49:01
好的...我發現了其他東西...問題是routes.rb中的以下行: match'/ checkout',:to =>'checkout#edit',:state =>'address',: as =>:結賬 – 2012-07-17 21:59:24