diff --git a/core/app/models/spree/line_item.rb b/core/app/models/spree/line_item.rb index 97f46fd33e2..91642862f9e 100644 --- a/core/app/models/spree/line_item.rb +++ b/core/app/models/spree/line_item.rb @@ -97,7 +97,7 @@ def stock_availability end def quantity_no_less_than_shipped - already_shipped = order.shipments.reduce(0) { |acc,s| acc + s.inventory_units.where(:variant_id => variant.id).count } + already_shipped = order.shipments.reduce(0) { |acc,s| acc + s.inventory_units.select { |i| i.variant == variant }.count } unless quantity >= already_shipped errors.add(:quantity, I18n.t('validation.cannot_be_less_than_shipped_units')) end