Search code examples
angularspartacus-storefront

How to inject OrderEntry context inside outlet CartOutlets.ITEM_DETAILS in Spartacus


A question found in a different channel:

Is there any way to access orderEntry when using

<ng-template [cxOutlet]="CartOutlets.ITEM_DETAILS"> </ng-template>

placeholder from cart-item component? It seems that when there is no [cxOutletContext]="{ entry: item }" it is not possible, and we have to overwrite / copy entire cart component (cart-details, cart-item-list, cart-item) to display some additional information?


Solution

  • In Spartacus 4.3.x:

    You should be able to inject the special token CartItemContext like in this example component.

    And you might be interested especially in reading the CartItemContext.item$, which has type Observable<OrderEntry>.

    Note: As of version 4.3.x, he CartItemContext token is provided only inside the default component CartItemComponent.