DAFF_CART_IN_MEMORY_EXTRA_ATTRIBUTES_HOOK

Allows an app dev to generate extra fields in the in-memory backend. This enables the in-memory drivers to return responses similar to what the frontend would expect from the production platform.

The value returned by the hook function will be set to the returned cart's extra_attributes field for driver calls that return a cart.

The following example demonstrates adding the numberOfCartItems field to extra_attributes:

(reqInfo: RequestInfo, cart: DaffCart) => ({
  numberOfCartItems: cart.items.length
})

Note that this and any extra_attributes features are for advanced users and should be used with care.

Graycore, LLC © 2018 - 2024. Code licensed under an MIT-style License. Documentation licensed under CC BY 4.0.