Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing type definitions in currentCart from @wix/ecom #556

Open
sanam2405 opened this issue Sep 27, 2024 · 0 comments
Open

Missing type definitions in currentCart from @wix/ecom #556

sanam2405 opened this issue Sep 27, 2024 · 0 comments

Comments

@sanam2405
Copy link

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 .

Screenshot 2024-09-27 at 1 17 27 PM

The below is the API response upon calling currentCart.Cart.

Screenshot 2024-09-27 at 1 06 46 PM

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant