From 6afda87baf9fd9b63e303e3f787d026648c08609 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Tue, 5 May 2020 12:19:05 +0200 Subject: [PATCH] Add explanatory comment on soft-deleted variant stock logic --- app/models/spree/stock/quantifier.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/spree/stock/quantifier.rb b/app/models/spree/stock/quantifier.rb index 037f5295fd..21f1750ca0 100644 --- a/app/models/spree/stock/quantifier.rb +++ b/app/models/spree/stock/quantifier.rb @@ -11,6 +11,8 @@ module Spree end def total_on_hand + # Associated stock_items no longer exist if the variant has been soft-deleted. A variant + # may still be in an active cart after it's deleted, so this will mark it as out of stock. return 0 if @variant.deleted? stock_items.sum(&:count_on_hand)