hello, i've been trying to skip some checkout ste...
# general
o
hello, i've been trying to skip some checkout steps but have had little success with 👉 https://guides.solidus.io/cookbook/redefining-checkout-steps from guides anyone who can help on a way forward??
g
What exactly is the issue you're having? Are the steps not getting skipped? Are you able to skip them and there's something unexpected happening?
o
am not able to skip any step with the specified method
n
can you share the code you wrote?
o
on app/model/spree/order_decorator.rb
Copy code
on app/model/spree/order_decorator.rb Spree::Order.class_eval do
    checkout_flow do
      #go_to_state :address
      #go_to_state :delivery
      #go_to_state :payment
      go_to_state :confirm, 
      
    end
end   i commented out the steps i don't want since the address i update it from the backend  and want the following states to the select only the default values
g
I thought you said you followed the guide, that code doesn't look like anything in the guide. Did you follow a different guide?
o
yes i did at first then changed after reading the solidus core order.rb model. I did as the guide stated but there was no change.
g
I'm not removing any checkout steps, but I am adding one. My file is
/app/decorators/embold/spree/order_decorator.rb
and it starts with
Copy code
module Embold::OrderDecorator
  def self.prepended(base)
    base.insert_checkout_step :verify_address, {
      before: :delivery
    }
I wonder if your decorator is in the wrong spot. The guide points to a spot similar to what I'm using.
o
following your example, this is what i have on
/app/decorators/malimali/spree/order_decorator.rb
Copy code
module Malimali::OrderDecorator
    def self.prepended(base)
        base.remove_checkout_step :address
    end

    ::Spree::Order.prepend self
end
for context i'm using solidus starter frontend. still it doesn't skip checkout step address.
g
At this point I'm not sure, I would have to start doing some general debugging to see if the decorator is even getting included. I usually add something like
Copy code
<http://Rails.logger.info|Rails.logger.info> "some message here that I can search development.log for"
o
good idea, i think that is the problem. i'll try to solve this, i hope when i come back you'll bear with my ignorance. Thank you for now.
g
No worries, we're here to help each other. Good luck! 🙂
n
hey Omari, any luck solving the issue?
o
no, still struggling
n
@Omari Mubutu finally had the chance to test it myself and the issue is that you need to tell Rails to load your decorators. You can achieve that by adding the following code:
Copy code
# config/application.rb

module SampleSolidusStore
  class Application < Rails::Application
    config.to_prepare do
      # Load application's model / class decorators
      Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
        Rails.configuration.cache_classes ? require(c) : load(c)
      end
    end

    # ...
  end
end
o
have been away; and this works now. thank you 👍
👍 1