mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge pull request #3158 from luisramos0/2-0-vos-scoping
[Spree Upgrade] Scopes variants on order completion and on changes to completed orders
This commit is contained in:
@@ -127,6 +127,12 @@ Spree::LineItem.class_eval do
|
||||
|
||||
private
|
||||
|
||||
def update_inventory_with_scoping
|
||||
scoper.scope(variant)
|
||||
update_inventory_without_scoping
|
||||
end
|
||||
alias_method_chain :update_inventory, :scoping
|
||||
|
||||
# Override of Spree validation method
|
||||
# Added check for in-memory :skip_stock_check attribute
|
||||
def stock_availability
|
||||
@@ -135,8 +141,7 @@ Spree::LineItem.class_eval do
|
||||
end
|
||||
|
||||
def scoper
|
||||
return @scoper unless @scoper.nil?
|
||||
@scoper = OpenFoodNetwork::ScopeVariantToHub.new(order.distributor)
|
||||
@scoper ||= OpenFoodNetwork::ScopeVariantToHub.new(order.distributor)
|
||||
end
|
||||
|
||||
def calculate_final_weight_volume
|
||||
|
||||
@@ -15,6 +15,18 @@ module Spree
|
||||
end
|
||||
end
|
||||
|
||||
# The shipment manifest is built by loading inventory units and variants from the DB
|
||||
# These variants come unscoped
|
||||
# So, we need to scope the variants just after the manifest is built
|
||||
def manifest_with_scoping
|
||||
manifest_without_scoping.each { |item| scoper.scope(item.variant) }
|
||||
end
|
||||
alias_method_chain :manifest, :scoping
|
||||
|
||||
def scoper
|
||||
@scoper ||= OpenFoodNetwork::ScopeVariantToHub.new(order.distributor)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# NOTE: This is an override of spree's method, needed to allow orders
|
||||
|
||||
Reference in New Issue
Block a user