How to check if a subscription product is being checked out?

Question:

We want to enforce the user to create an account if he is checking out a Subscription product.

If we check the currentCart this is always empty for subscription products, as I see the checkout process is different for subscription . I couldn’t find any reference in the JS API how to check this.

        import { cart } from "wix-stores-frontend";
        const myCart = await currentCart.getCurrentCart();
        console.log("myCart", myCart, myCart.lineItems);

I tried also using currentCart from wix-ecom-backend same thing.

import { currentCart } from "wix-ecom-backend";

So, how to check on the checkout page if a subscription product is being checked out?

Thanks in advance

We solved it by reading the checkout object:


import wixLocationFrontend from "wix-location-frontend";
import { checkout } from "wix-ecom-backend";

    const appSectionParams = wixLocationFrontend.query.appSectionParams;

    if (appSectionParams) {
        const decodedParams = JSON.parse(decodeURIComponent(appSectionParams));
        if (decodedParams.checkoutId) {
            const myCheckout = await checkout.getCheckout(decodedParams.checkoutId);
            // check here for subscription products in myCheckout.lineItems
        }
    }