Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Organize the migrated code in Spree::LineItem into logical place.
Matthew Kennedy1feab95014a2
diff --git a/core/app/models/spree/line_item.rb b/core/app/models/spree/line_item.rbindex 6b25e3b77b..e063eadc9b 100644--- a/core/app/models/spree/line_item.rb+++ b/core/app/models/spree/line_item.rb@@ -8,14 +8,11 @@ module Spreeendbelongs_to :tax_category, class_name: 'Spree::TaxCategory'- has_many :digital_links, dependent: :destroy- after_save :create_digital_links, if: :digital?- delegate :digital?, to: :variant-has_one :product, through: :varianthas_many :adjustments, as: :adjustable, dependent: :destroyhas_many :inventory_units, inverse_of: :line_item+ has_many :digital_links, dependent: :destroybefore_validation :copy_pricebefore_validation :copy_tax_category@@ -40,12 +37,14 @@ module Spreeafter_save :update_inventoryafter_save :update_adjustments+ after_save :create_digital_links, if: :digital?after_create :update_tax_chargedelegate :name, :description, :sku, :should_track_inventory?, :product, :options_text, :slug, :product_id, to: :variantdelegate :brand, :category, to: :productdelegate :tax_zone, to: :order+ delegate :digital?, to: :variantattr_accessor :target_shipment@@ -121,7 +120,7 @@ module Spreeassign_attributes optsend- private+ protected# TODO: there is no reason to create the digital links until the order is complete# TODO: PMG - Shouldn't we only do this if the quantity changed?@@ -143,6 +142,8 @@ module Spreeendend+ private+def ensure_valid_quantityself.quantity = 0 if quantity.nil? || quantity < 0end