Skip to content

Commit

Permalink
Adds an ability to use different Order serializer for Account Orders …
Browse files Browse the repository at this point in the history
…endpoint

By default it will fallback to cart serializer, not changing the current behaviour in any way
  • Loading branch information
damianlegawiec committed Oct 27, 2020
1 parent 8e2c7b2 commit a4efe63
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Expand Up @@ -35,11 +35,11 @@ def resource
end

def collection_serializer
Spree::Api::Dependencies.storefront_cart_serializer.constantize
Spree::Api::Dependencies.storefront_order_serializer.constantize
end

def resource_serializer
Spree::Api::Dependencies.storefront_cart_serializer.constantize
Spree::Api::Dependencies.storefront_order_serializer.constantize
end

def collection_finder
Expand Down
3 changes: 2 additions & 1 deletion api/app/models/spree/api_dependencies.rb
Expand Up @@ -14,7 +14,7 @@ class ApiDependencies
:storefront_collection_paginator, :storefront_user_serializer, :storefront_products_sorter, :storefront_products_finder,
:storefront_product_serializer, :storefront_taxon_serializer, :storefront_taxon_finder, :storefront_find_by_variant_finder,
:storefront_cart_update_service, :storefront_cart_estimate_shipping_rates_service, :storefront_estimated_shipment_serializer,
:storefront_store_serializer, :storefront_address_serializer,
:storefront_store_serializer, :storefront_address_serializer, :storefront_order_serializer,
:storefront_account_create_address_service, :storefront_account_update_address_service, :storefront_address_finder
].freeze

Expand Down Expand Up @@ -66,6 +66,7 @@ def set_storefront_defaults
@storefront_product_serializer = 'Spree::V2::Storefront::ProductSerializer'
@storefront_estimated_shipment_serializer = 'Spree::V2::Storefront::EstimatedShippingRateSerializer'
@storefront_store_serializer = 'Spree::V2::Storefront::StoreSerializer'
@storefront_order_serializer = 'Spree::V2::Storefront::CartSerializer'

# sorters
@storefront_order_sorter = Spree::Dependencies.order_sorter
Expand Down

0 comments on commit a4efe63

Please sign in to comment.