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.

Update to use platform API on admin.

Matthew Kennedyd2be50a70408
diff --git a/api/app/serializers/spree/api/v2/platform/taxon_serializer.rb b/api/app/serializers/spree/api/v2/platform/taxon_serializer.rb
index ac7ff4641f..e71a3e2649 100644
--- a/api/app/serializers/spree/api/v2/platform/taxon_serializer.rb
+++ b/api/app/serializers/spree/api/v2/platform/taxon_serializer.rb
@@ -5,6 +5,20 @@ module Spree
class TaxonSerializer < BaseSerializer
include ::Spree::Api::V2::ResourceSerializerConcern
+ attributes :pretty_name, :seo_title
+
+ attribute :is_root do |taxon|
+ taxon.root?
+ end
+
+ attribute :is_child do |taxon|
+ taxon.child?
+ end
+
+ attribute :is_leaf do |taxon|
+ taxon.leaf?
+ end
+
belongs_to :parent, record_type: :taxon, serializer: :taxon
belongs_to :taxonomy, record_type: :taxonomy
diff --git a/backend/app/assets/javascripts/spree/backend.js b/backend/app/assets/javascripts/spree/backend.js
index a3bb76b0ba..cd294125ba 100644
--- a/backend/app/assets/javascripts/spree/backend.js
+++ b/backend/app/assets/javascripts/spree/backend.js
@@ -96,12 +96,8 @@ Spree.routes.products_api_v2 = Spree.pathFor('/api/v2/platform/products')
Spree.routes.users_api_v2 = Spree.pathFor('api/v2/platform/users')
// TODO:
-// Update this from storefont to platform.
-
-// Using storefront due to issues with
-// taxon platform api not returning the attribute :pretty_name
-// and also returning all taxons, even when filtered by name.
-Spree.routes.taxons_api_v2 = Spree.pathFor('/api/v2/storefront/taxons')
+// taxon returning all taxons, even when filtered by name.
+Spree.routes.taxons_api_v2 = Spree.pathFor('/api/v2/platform/taxons')
Spree.apiV2Authentication = function() {
return {
diff --git a/backend/app/assets/javascripts/spree/backend/global/select2_autocomplete.es6 b/backend/app/assets/javascripts/spree/backend/global/select2_autocomplete.es6
index fa799af4b9..f258ff4baf 100644
--- a/backend/app/assets/javascripts/spree/backend/global/select2_autocomplete.es6
+++ b/backend/app/assets/javascripts/spree/backend/global/select2_autocomplete.es6
@@ -1,5 +1,5 @@
// Allows you to use one autocomplete for sevral use cases with sensible defaults.
-// Requires two params passing to work, the api V1 URI, and the data attribute -> data_attrbute_name: 'products'
+// Requires two params passing to work, the api URI, and the data attribute -> data_attrbute_name: 'products'
$.fn.select2Autocomplete = function(params) {
// Required params
const apiUrl = params.apiUrl