Skip to content

Commit

Permalink
added shipping info to updateOrder
Browse files Browse the repository at this point in the history
  • Loading branch information
erikrakuscek committed Mar 6, 2024
1 parent a3ae20d commit 59eb9ff
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions packages/commerce/service/impls/standalone/orders/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const getDBInstance = (name: string): Firestore => {
interface SavedOrder {
email: string
paymentMethod: string
// TODO: add shippingInfo type
shippingInfo?: any
status: string
timestamp: FieldValue
items: ActualLineItemSnapshot[]
Expand Down Expand Up @@ -69,6 +71,8 @@ const updateOrder = async (
orderId: string,
email: string,
paymentMethod: string,
// TODO: add shippingInfo type
shippingInfo: any,
items: ActualLineItemSnapshot[],
options: {
dbName: string
Expand All @@ -86,6 +90,7 @@ const updateOrder = async (
await setDoc(doc(ordersRef, orderId), {
email,
paymentMethod,
shippingInfo,
status: 'open',
timestamp: serverTimestamp(),
items,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ class StandaloneService
return order.id
}

async updateOrder(orderId: string, email: string, paymentMethod: string): Promise<void> {
// TODO: add shippingInfo type
async updateOrder(orderId: string, email: string, paymentMethod: string, shippingInfo: any): Promise<void> {
const snapshot = this.takeSnapshot()
updateOrderHelper(orderId, email, paymentMethod, snapshot.items, this._options) // didn't want to have two levels of 'items'
updateOrderHelper(orderId, email, paymentMethod, shippingInfo, snapshot.items, this._options) // didn't want to have two levels of 'items'
}

takeSnapshot = (): StandaloneServiceSnapshot => ({
Expand Down
3 changes: 2 additions & 1 deletion packages/commerce/types/commerce-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ interface CommerceService extends ObsLineItemRef {
getCartCategorySubtotal(categoryId: string): number

createOrder(email: string, paymentMethod: string): Promise<string | undefined>
updateOrder(orderId: string, email: string, paymentMethod: string): Promise<void>
// TODO: add shippingInfo type
updateOrder(orderId: string, email: string, paymentMethod: string, shippingInfo: any): Promise<void>

/**
* Sets the tokens at each level supplied.
Expand Down

0 comments on commit 59eb9ff

Please sign in to comment.