Skip to content

selectOrderDetails$(orderId: number): Promise<Observable<UserOrderDetails | null>>

The selectOrderDetails$ method provides reactive access to detailed order information. It returns an Observable that emits the order detail whenever it changes in the store.

Parameters

orderId: number

The ID of the order to observe.

Returned value

A returned value has a type of Promise<Observable<UserOrderDetails | null>> where UserOrderDetails represents the UserOrderDetails model.

Example

In this example we subscribe to order detail changes and react to updates.

    useStorefront(async (storefront) => {
        const userApi = await storefront.getApi('UserApi');

        const orderDetail$ = await userApi.selectOrderDetails$(12345);

        orderDetail$.subscribe((orderDetail) => {
            if(orderDetail) {
                const orderedProducts = orderDetail.products;
                console.log('ordered products list:', orderedProducts)
            }
        });
    });

Caching

The method fetches the order detail from the API if it's not already in the store. Once fetched, the data is cached and subsequent subscriptions receive the cached data. The Observable continues to emit if the order detail is updated in the store.

User API methods reference

Models reference