Skip to content

armgit / spree

Public Imported from GitHub
0

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.

Migrate logic for Spree::Order

Matthew Kennedya98d9d411526
diff --git a/core/app/models/spree/order.rb b/core/app/models/spree/order.rb
index eb363198f3..bafea95595 100644
--- a/core/app/models/spree/order.rb
+++ b/core/app/models/spree/order.rb
@@ -663,6 +663,27 @@ module Spree
spree_promotion_actions: { type: 'Spree::Promotion::Actions::FreeShipping' }).exists?
end
+ # all products are digital
+ def digital?
+ line_items.all?(&:digital?)
+ end
+
+ def some_digital?
+ line_items.any?(&:digital?)
+ end
+
+ def digital_line_items
+ line_items.select(&:digital?)
+ end
+
+ def digital_links
+ digital_line_items.map(&:digital_links).flatten
+ end
+
+ def reset_digital_links!
+ digital_links.each(&:reset!)
+ end
+
private
def link_by_email