施普雷结帐 - 删除步骤(Spree Checkout - Remove Step)

2019-07-30 09:05发布

我试图删除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 

Answer 1:

好了,我终于找到了它 -
施普雷推出了一个新的版本#1.2.0与这个确切的问题的主要修复。

施普雷1.2.0发布说明

结帐过程中一直难以大礼包内定制,并已经产生,在过去的投诉。 我们很高兴在狂欢的1.2版本,这已经substaintially容易报表...

因此,解决办法现在戒烟容易 -
只要撤销先前所有的结账作案企图,
通过更新您的宝石文件升级大礼包1.2.0和捆绑安装,
按照他们的文档(我想你有一些)处理你的所有代码分手。
并在应用程序/模型/大礼包创建一个简单的order_decorator.rb /

Spree::Order.class_eval do
  checkout_flow do
    go_to_state :address
    go_to_state :payment, :if => lambda { |order| order.payment_required? }
    go_to_state :confirm, :if => lambda { |order| order.confirmation_required? }
    go_to_state :complete
  end

  # If true, causes the payment step to happen during the checkout process
  def payment_required?
    return false
  end

  # If true, causes the confirmation step to happen during the checkout process
  def confirmation_required?
    return true
  end

end

请享用。



Answer 2:

在热潮> = 2.0.0可以使用以下辅助方法,以除去任何结帐步骤。 按照下面的步骤。

第1步:在应用程序/模型/大礼包/创建名称order_decorator.rb新文件

第2步:复制并粘贴下面的代码它。

Spree::Order.class_eval do
#replace :delivery to any other state 
remove_checkout_step :delivery  
end 

感谢大礼包社区。 http://guides.spreecommerce.com/developer/



Answer 3:

在施普雷默认结帐步骤

  1. 地址
  2. 交货
  3. 付款
  4. 确认

礼包(2.0)允许修改结帐过程中添加,或通过使用相应的助手取出步骤。

insert_checkout_step
remove_checkout_step

需要记住,remove_checkout_step将一次删除只有一个结帐步骤:



Answer 4:

它的工作原理与狂欢的新叉固相线也



文章来源: Spree Checkout - Remove Step