我试图删除2个结帐步骤。 我试图按照该网站的文档http://guides.spreecommerce.com/checkout.html ,但仍然没有任何反应。
我使用施普雷1.1.2红宝石1.9.2p318滑轨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