mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Add Bugsnag call for "variant with no stock item" case
This commit is contained in:
@@ -44,6 +44,15 @@ module VariantStock
|
||||
# This provides a default value for variant.on_demand using Spree::StockLocation.backorderable_default
|
||||
return Spree::StockLocation.first.backorderable_default if new_record? || deleted?
|
||||
|
||||
# This can be removed unless we have seen this error in Bugsnag recently
|
||||
if stock_item.nil?
|
||||
Bugsnag.notify(
|
||||
RuntimeError.new("Variant #stock_item called, but the stock_item does not exist!"),
|
||||
object: as_json
|
||||
)
|
||||
return Spree::StockLocation.first.backorderable_default
|
||||
end
|
||||
|
||||
stock_item.backorderable?
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user