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
Deprecate some methods in Ordeer
Damian Legawiece2170fef442d
diff --git a/spree/core/app/models/spree/checkout/default_requirements.rb b/spree/core/app/models/spree/checkout/default_requirements.rbindex 310577ad93..729ad42686 100644--- a/spree/core/app/models/spree/checkout/default_requirements.rb+++ b/spree/core/app/models/spree/checkout/default_requirements.rb@@ -43,9 +43,12 @@ module Spreeerrorsend+ # Discontinuation is checked at both levels: a product can stay active+ # while an individual variant hit its discontinue_on date after it+ # entered the cart.def stock_errors@cart.line_items.includes(variant: :product).filter_map do |line_item|- if line_item.variant.product.discontinued?+ if line_item.variant.nil? || line_item.variant.discontinued? || line_item.variant.product.discontinued?req('cart', 'line_items', Spree.t('cart_line_item.discontinued', li_name: line_item.name), code: 'discontinued')elsif !line_item.sufficient_stock?req('cart', 'line_items', Spree.t('cart_line_item.out_of_stock', li_name: line_item.name), code: 'out_of_stock')diff --git a/spree/core/app/models/spree/order.rb b/spree/core/app/models/spree/order.rbindex 6f463d41b2..7a91031793 100644--- a/spree/core/app/models/spree/order.rb+++ b/spree/core/app/models/spree/order.rb@@ -679,7 +679,11 @@ module Spree### Check to see if any line item variants are discontinued.# If so add error and restart checkout.+ # @deprecated Completion validation lives in+ # {Spree::Checkout::DefaultRequirements} (the +discontinued+ stock+ # error). Removed in 6.1.def ensure_line_item_variants_are_not_discontinued+ Spree::Deprecation.warn('Spree::Order#ensure_line_item_variants_are_not_discontinued is deprecated and will be removed in Spree 6.1. Completion validation lives in Spree::Checkout::Requirements.')if line_items.any? { |li| !li.variant || li.variant.discontinued? }errors.add(:base, Spree.t(:discontinued_variants_present))false@@ -688,7 +692,11 @@ module Spreeendend+ # @deprecated Completion validation lives in+ # {Spree::Checkout::DefaultRequirements} (the +out_of_stock+ stock+ # error). Removed in 6.1.def ensure_line_items_are_in_stock+ Spree::Deprecation.warn('Spree::Order#ensure_line_items_are_in_stock is deprecated and will be removed in Spree 6.1. Completion validation lives in Spree::Checkout::Requirements.')if insufficient_stock_lines.present?errors.add(:base, Spree.t(:insufficient_stock_lines_present))false@@ -698,10 +706,12 @@ module Spreeenddef use_all_coupon_codes+ Spree::Deprecation.warn('Spree::Order#use_all_coupon_codes is deprecated and will be removed in Spree 6.1. Use Spree::CouponCodes::CouponCodesHandler instead.')Spree::CouponCodes::CouponCodesHandler.new(order: self).use_all_codesenddef log_state_changes(state_name:, old_state:, new_state:)+ Spree::Deprecation.warn('Spree::Order#log_state_changes is deprecated and will be removed in Spree 6.1.')state_changes.create(previous_state: old_state,next_state: new_state,@@ -720,6 +730,7 @@ module Spreeenddef can_add_coupon?+ Spree::Deprecation.warn('Spree::Order#can_add_coupon? is deprecated and will be removed in Spree 6.1. Use Spree::Promotion.order_activatable? instead.')Spree::Promotion.order_activatable?(self)enddiff --git a/spree/core/spec/workflows/spree/carts/complete_spec.rb b/spree/core/spec/workflows/spree/carts/complete_spec.rbindex a6c4e45547..85f7e59e93 100644--- a/spree/core/spec/workflows/spree/carts/complete_spec.rb+++ b/spree/core/spec/workflows/spree/carts/complete_spec.rb@@ -81,6 +81,16 @@ module Spreeexpect(result.error.value[:code]).to eq('validation_failed')expect(result.error.value[:errors]).to be_presentend++ it 'rejects a variant discontinued after it entered the cart' do+ ready_cart.line_items.first.variant.update_columns(discontinue_on: 1.minute.ago)++ result = described_class.call(cart: ready_cart)++ expect(result).to be_failure+ expect(result.error.value[:code]).to eq('validation_failed')+ expect(result.error.value[:errors].map { |error| error[:code] }).to include('discontinued')+ endenddescribe 'guest checkout policy' do