Open
Description
I was using the wix eCommerce API. In particular, I was using the currentCart
API. However, I found out there are missing type definitions in currentCart.Cart
.

The below is the API response upon calling currentCart.Cart
.
You can see, there is a field called subtotal
. However, there seems to be no type definitions for the field subtotal in the CurrentCart.Cart
present inside ecom-v1-cart-current-cart.public
of node modules.
As a temporary fix, I did the below
import { currentCart } from "@wix/ecom";
import { WixClient } from "@/context/wixContext";
// structure of the subtotal field
type Subtotal = {
amount?: string;
convertedAmount?: string;
formattedAmount?: string;
formattedConvertedAmount?: string;
};
// extend currentCart.Cart to include the subtotal field
type ExtendedCart = currentCart.Cart & {
subtotal?: Subtotal;
};
type CartState = {
cart: ExtendedCart;
isLoading: boolean;
counter: number;
getCart: (wixClient: WixClient) => void;
addItem: (
wixClient: WixClient,
productId: string,
variantId: string,
quantity: number,
) => void;
removeItem: (wixClient: WixClient, itemId: string) => void;
};
Raising this issue to get the type definitions of the { currentCart } from "@wix/ecom"
fixed.
Metadata
Assignees
Labels
No labels