Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Order#current_order extension #2207

Closed
HugsDaniel opened this issue Apr 11, 2018 · 1 comment
Closed

Refactor Order#current_order extension #2207

HugsDaniel opened this issue Apr 11, 2018 · 1 comment
Labels

Comments

@HugsDaniel
Copy link
Contributor

Description

In Spree 2.0, Order#current_order takes a hash as argument.

Current status

In lib/spree/core/controller_helpers/order_decorator.rb we extend Spree's current_order like this :

def current_order_with_scoped_variants(create_order_if_necessary = false)
    order = current_order_without_scoped_variants(create_order_if_necessary)

    if order
      scoper = OpenFoodNetwork::ScopeVariantToHub.new(order.distributor)
      order.line_items.each do |li|
        scoper.scope(li.variant)
      end
    end

  order
end

And in Spree :

def current_order(create_order_if_necessary = false)
  ....
end

How does it look in Spree 2.0 ?

In Spree 2.0, Order#current_order now takes a hash of options :

def current_order(options = {})
   options[:create_order_if_necessary] ||= false
   options[:lock] ||= false
    ....
end

So we need to change the params we send in our extension.

@HugsDaniel
Copy link
Contributor Author

HugsDaniel commented Apr 13, 2018

Solved by #2209

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants