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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Expose pre_tax_item_amount and display_pre_tax_item_amount in API v2 Cart endpoint
Damian Legawiec2eb0db996527
diff --git a/api/app/serializers/spree/v2/storefront/cart_serializer.rb b/api/app/serializers/spree/v2/storefront/cart_serializer.rbindex 2ef2c59dd9..51b11aa5b6 100644--- a/api/app/serializers/spree/v2/storefront/cart_serializer.rb+++ b/api/app/serializers/spree/v2/storefront/cart_serializer.rb@@ -8,7 +8,8 @@ module Spree:updated_at, :completed_at, :included_tax_total, :additional_tax_total, :display_additional_tax_total,: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+ :promo_total, :display_promo_total, :item_count, :special_instructions, :display_total,+ :pre_tax_item_amount, :display_pre_tax_item_amounthas_many :line_itemshas_many :variantsdiff --git a/api/docs/v2/storefront/index.yaml b/api/docs/v2/storefront/index.yamlindex 700cd21cea..27343e7530 100644--- a/api/docs/v2/storefront/index.yaml+++ b/api/docs/v2/storefront/index.yaml@@ -1459,6 +1459,12 @@ components:display_tax_total:type: stringexample: '$10.00'+ pre_tax_item_amount:+ type: string+ example: '17.00'+ display_pre_tax_item_amount:+ type: string+ example: '$17.00'item_count:type: numberexample: 2diff --git a/api/lib/spree/api/testing_support/v2/current_order.rb b/api/lib/spree/api/testing_support/v2/current_order.rbindex b1fd2da853..1f7adcba40 100644--- a/api/lib/spree/api/testing_support/v2/current_order.rb+++ b/api/lib/spree/api/testing_support/v2/current_order.rb@@ -48,6 +48,8 @@ shared_examples 'returns valid cart JSON' doexpect(json_response['data']).to have_attribute(:promo_total).with_value(order.promo_total.to_s)expect(json_response['data']).to have_attribute(:display_promo_total).with_value(order.display_promo_total.to_s)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_relationships(:user, :line_items, :variants, :billing_address, :shipping_address, :payments, :shipments, :promotions)endend