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.

Added `Spree::IntegrationsConcern` (#12684)

Damian Legawiec7b805fdabe29
diff --git a/core/app/models/concerns/spree/integrations_concern.rb b/core/app/models/concerns/spree/integrations_concern.rb
new file mode 100644
index 0000000000..10212591e4
--- /dev/null
+++ b/core/app/models/concerns/spree/integrations_concern.rb
@@ -0,0 +1,11 @@
+module Spree
+ module IntegrationsConcern
+ def store_integrations
+ @store_integrations ||= Spree::Store.current.integrations.active.to_a
+ end
+
+ def store_integration(name)
+ store_integrations.find { |integration| integration.type.to_s.demodulize.underscore == name }
+ end
+ end
+end
diff --git a/core/app/models/spree/base.rb b/core/app/models/spree/base.rb
index 9ddd705155..391351cfc4 100644
--- a/core/app/models/spree/base.rb
+++ b/core/app/models/spree/base.rb
@@ -2,6 +2,7 @@ class Spree::Base < ApplicationRecord
include Spree::Preferences::Preferable
include Spree::RansackableAttributes
include Spree::TranslatableResourceScopes
+ include Spree::IntegrationsConcern
after_initialize do
if has_attribute?(:preferences) && !preferences.nil?
diff --git a/core/app/models/spree/shipment_handler.rb b/core/app/models/spree/shipment_handler.rb
index 8486ebc5c1..5776f13c1e 100644
--- a/core/app/models/spree/shipment_handler.rb
+++ b/core/app/models/spree/shipment_handler.rb
@@ -1,6 +1,7 @@
module Spree
class ShipmentHandler
include Spree::Shipment::Emails
+ include Spree::IntegrationsConcern
class << self
def factory(shipment)