From 0fabb5bc2fb57bf1d26e2714f13a8f8e7d67ebed Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Tue, 11 May 2021 01:45:54 +0100 Subject: [PATCH] Don't pluck variant_ids multiple times (once for each line item) --- app/models/spree/shipment.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/spree/shipment.rb b/app/models/spree/shipment.rb index ac88f43974..1a750dc207 100644 --- a/app/models/spree/shipment.rb +++ b/app/models/spree/shipment.rb @@ -185,7 +185,8 @@ module Spree def line_items if order.complete? - order.line_items.select { |li| inventory_units.pluck(:variant_id).include?(li.variant_id) } + inventory_unit_ids = inventory_units.pluck(:variant_id) + order.line_items.select { |li| inventory_unit_ids.include?(li.variant_id) } else order.line_items end