Variant can be "not available": next and don't update its estimate price

This commit is contained in:
Jean-Baptiste Bellet
2023-03-03 15:07:10 +01:00
parent 440e776e3a
commit 131772f7b2

View File

@@ -104,6 +104,9 @@ module Admin
subscription.subscription_line_items.nil_price_estimate.each do |line_item|
variant = OrderManagement::Subscriptions::
VariantsList.eligible_variants(shop).find_by(id: line_item.variant_id)
# If the variant is not available in the shop, the price estimate will be nil
next if variant.nil?
price = variant.price + fee_calculator.indexed_fees_for(variant)
line_item.update_column(:price_estimate, price)
end