Module: SpreeCmCommissioner::V2::Storefront::CartSerializerDecorator

Defined in:
app/serializers/spree_cm_commissioner/v2/storefront/cart_serializer_decorator.rb

Class Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/serializers/spree_cm_commissioner/v2/storefront/cart_serializer_decorator.rb', line 5

def self.prepended(base)
  # Serialize as :order type to maintain consistency with OrderSerializer.
  # This allows mobile clients to handle both cart and order responses uniformly.
  base.set_type :order

  base.attributes :phone_number, :intel_phone_number, :country_code, :request_state,
                  :term_accepted_at,
                  :channel, :hold_expires_at

  base.attribute :qr_data do |order|
    order.qr_data if order.completed?
  end

  # override to return all payments instead of only valid_payments
  base.has_many :payments, serializer: ::Spree::V2::Storefront::PaymentSerializer
  base.has_many :saved_guests, serializer: ::SpreeCmCommissioner::V2::Storefront::SavedGuestSerializer
end