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.

Fix Policy page builder links (#13014)

Damian Legawiec17fed085883e
diff --git a/core/app/helpers/spree/base_helper.rb b/core/app/helpers/spree/base_helper.rb
index 7dd685d1a2..e97d9dc6e2 100644
--- a/core/app/helpers/spree/base_helper.rb
+++ b/core/app/helpers/spree/base_helper.rb
@@ -203,7 +203,7 @@ module Spree
"#{base_url + localize}/posts/#{resource.slug}#{preview_id}"
elsif resource.is_a?(Spree::Taxon)
"#{base_url + localize}/t/#{resource.permalink}"
- elsif resource.is_a?(Spree::Page) || resource.is_a?(ActionText::RichText)
+ elsif resource.is_a?(Spree::Page) || resource.is_a?(Spree::Policy)
"#{base_url + localize}#{resource.page_builder_url}"
elsif resource.is_a?(Spree::PageLink)
resource.linkable_url
diff --git a/core/app/models/action_text/rich_text_decorator.rb b/core/app/models/action_text/rich_text_decorator.rb
deleted file mode 100644
index 28586a9a5a..0000000000
--- a/core/app/models/action_text/rich_text_decorator.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-module ActionText
- module RichTextDecorator
- def page_builder_url
- return unless Spree::Core::Engine.routes.url_helpers.respond_to?(:policy_path)
-
- Spree::Core::Engine.routes.url_helpers.policy_path(name.gsub(/customer_/, ''))
- end
- end
-
- ActionText::RichText.include(RichTextDecorator)
-end
diff --git a/core/app/models/spree/policy.rb b/core/app/models/spree/policy.rb
index fd70925954..c8d370d7fc 100644
--- a/core/app/models/spree/policy.rb
+++ b/core/app/models/spree/policy.rb
@@ -43,5 +43,11 @@ module Spree
# Ransack
#
self.whitelisted_ransackable_attributes = %w[name show_in_checkout_footer]
+
+ def page_builder_url
+ return unless Spree::Core::Engine.routes.url_helpers.respond_to?(:policy_path)
+
+ Spree::Core::Engine.routes.url_helpers.policy_path(self)
+ end
end
end