Davi Silva
Davi Silva

Reputation: 40

Spartacus Selective Cart

We are getting some calls to the Selective Cart endpoint, even though this feature is disabled. The problem happens when we access the cart page and the user is logged in.

Trying to figure this out, we have found a piece of code that can explain what might be causing this issue. It's in the SelectiveCartService (https://github.com/SAP/spartacus/blob/develop/projects/core/src/cart/facade/selective-cart.service.ts):

combineLatest([
  this.userService.get(),
  this.baseSiteService.getActive(),
]).subscribe(([user, activeBaseSite]) => {
  if (user && user.customerId && activeBaseSite) {
    this.customerId = user.customerId;
    this.cartId$.next(`selectivecart${activeBaseSite}${this.customerId}`);
  } else if (user && !user.customerId) {
    this.cartId$.next(undefined);
  }
});

We don't know if we have overridden something that we shouldn't or if this is indeed an issue that must be addressed. Can anyone help?

Upvotes: 0

Views: 518

Answers (1)

Paweł Fraś
Paweł Fraś

Reputation: 136

The selectiveCart.enabled flag is only responsible for handling the “Save for later” button. However, there is one more component that uses SelectiveCartService to call the API and is rendered regardless of the flag value - CMS-driven SaveForLaterComponent. To completely disable the “Save for later” functionality, remove this component from the Sample Data.

Upvotes: 3

Related Questions