mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Convert state_id and country_id in serializer
This commit is contained in:
@@ -4,8 +4,8 @@ Darkswarm.factory 'Cart', (CurrentOrder, Variants, $timeout, $http, $modal, $roo
|
||||
dirty: false
|
||||
update_running: false
|
||||
update_enqueued: false
|
||||
order: CurrentOrder.getOrder()
|
||||
line_items: CurrentOrder.getOrder()?.line_items || []
|
||||
order: CurrentOrder.order
|
||||
line_items: CurrentOrder.order?.line_items || []
|
||||
|
||||
constructor: ->
|
||||
for line_item in @line_items
|
||||
|
||||
@@ -2,7 +2,7 @@ Darkswarm.factory 'Checkout', (CurrentOrder, ShippingMethods, PaymentMethods, $h
|
||||
new class Checkout
|
||||
errors: {}
|
||||
secrets: {}
|
||||
order: CurrentOrder.getOrder()
|
||||
order: CurrentOrder.order
|
||||
ship_address_same_as_billing: 'YES'
|
||||
default_bill_address: 'NO'
|
||||
default_ship_address: 'NO'
|
||||
|
||||
@@ -1,16 +1,4 @@
|
||||
Darkswarm.factory 'CurrentOrder', (currentOrder) ->
|
||||
# Populate Currentorder.order from json in page. This is probably redundant now.
|
||||
new class CurrentOrder
|
||||
# order: currentOrder
|
||||
|
||||
getOrder: ->
|
||||
if currentOrder && currentOrder.bill_address
|
||||
currentOrder.bill_address.state_id = currentOrder.bill_address.state_id + ''
|
||||
currentOrder.bill_address.country_id = currentOrder.bill_address.country_id + ''
|
||||
|
||||
if currentOrder && currentOrder.ship_address
|
||||
currentOrder.ship_address.state_id = currentOrder.ship_address.state_id + ''
|
||||
currentOrder.ship_address.country_id = currentOrder.ship_address.country_id + ''
|
||||
|
||||
currentOrder
|
||||
|
||||
order: currentOrder
|
||||
|
||||
@@ -9,4 +9,12 @@ class Api::AddressSerializer < ActiveModel::Serializer
|
||||
def state_name
|
||||
object.state.andand.abbr
|
||||
end
|
||||
|
||||
def state_id
|
||||
object.state_id.andand.to_s
|
||||
end
|
||||
|
||||
def country_id
|
||||
object.country_id.andand.to_s
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user