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.

Expose Order#pre_tax_total and Order#display_pre_tax_total in Cart API v2

Damian Legawiec57cdefd2542c
diff --git a/api/app/serializers/spree/v2/storefront/cart_serializer.rb b/api/app/serializers/spree/v2/storefront/cart_serializer.rb
index 51b11aa5b6..3c33f81ec0 100644
--- a/api/app/serializers/spree/v2/storefront/cart_serializer.rb
+++ b/api/app/serializers/spree/v2/storefront/cart_serializer.rb
@@ -9,7 +9,7 @@ module Spree
:display_included_tax_total, :tax_total, :currency, :state, :token, :email,
:display_item_total, :display_ship_total, :display_adjustment_total, :display_tax_total,
:promo_total, :display_promo_total, :item_count, :special_instructions, :display_total,
- :pre_tax_item_amount, :display_pre_tax_item_amount
+ :pre_tax_item_amount, :display_pre_tax_item_amount, :pre_tax_total, :display_pre_tax_total
has_many :line_items
has_many :variants
diff --git a/api/docs/v2/storefront/index.yaml b/api/docs/v2/storefront/index.yaml
index 27343e7530..259a7b7aed 100644
--- a/api/docs/v2/storefront/index.yaml
+++ b/api/docs/v2/storefront/index.yaml
@@ -1465,6 +1465,12 @@ components:
display_pre_tax_item_amount:
type: string
example: '$17.00'
+ pre_tax_total:
+ type: string
+ example: '20.00'
+ display_pre_tax_total:
+ type: string
+ example: '$20.00'
item_count:
type: number
example: 2
diff --git a/api/lib/spree/api/testing_support/v2/current_order.rb b/api/lib/spree/api/testing_support/v2/current_order.rb
index 1f7adcba40..94a79f6dc9 100644
--- a/api/lib/spree/api/testing_support/v2/current_order.rb
+++ b/api/lib/spree/api/testing_support/v2/current_order.rb
@@ -50,6 +50,8 @@ shared_examples 'returns valid cart JSON' do
expect(json_response['data']).to have_attribute(:display_total).with_value(order.display_total.to_s)
expect(json_response['data']).to have_attribute(:pre_tax_item_amount).with_value(order.pre_tax_item_amount.to_s)
expect(json_response['data']).to have_attribute(:display_pre_tax_item_amount).with_value(order.display_pre_tax_item_amount.to_s)
+ expect(json_response['data']).to have_attribute(:pre_tax_total).with_value(order.pre_tax_total.to_s)
+ expect(json_response['data']).to have_attribute(:display_pre_tax_total).with_value(order.display_pre_tax_total.to_s)
expect(json_response['data']).to have_relationships(:user, :line_items, :variants, :billing_address, :shipping_address, :payments, :shipments, :promotions)
end
end