Perform variant override scoping on product/variant by external class. Centralise this so we can load everything in one go.

This commit is contained in:
Rohan Mitchell
2015-06-18 13:11:11 +10:00
parent 6ed9a2620c
commit 7cc2bc4fde
11 changed files with 67 additions and 57 deletions

View File

@@ -3,8 +3,9 @@ Spree::Core::ControllerHelpers::Order.class_eval do
order = current_order_without_scoped_variants(create_order_if_necessary)
if order
scoper = OpenFoodNetwork::ScopeVariantToHub.new(order.distributor)
order.line_items.each do |li|
li.variant.scope_to_hub order.distributor
scoper.scope(li.variant)
end
end