Technical Changes in Spartacus 3.0
Note: Spartacus 3.x is no longer maintained. Please upgrade to the latest version.
Note: Spartacus 3.x was tested with SAP Commerce Cloud versions 1905 to 2105. Spartacus 3.x has not been verified to work with (and is not guaranteed to work with) SAP Commerce Cloud 2211 or later releases.
Table of Contents
- Breaking Changes Introduced in 3.0
- Translations (i18n) changed
- Default router options changed
- Page Layout
- Static CMS structure config changes
- OCC prefix
- Storefront config
- JSON-LD schemas
- ContentPageMetaResolver
- LoginFormComponent
- HttpClientModule is not imported in feature libraries
- SSR engine optimizations
- Store finder functionality was moved to a new library
- StockNotificationComponent
- CmsComponentsService
- Config cmsComponents
- PageMetaService lazy-loading related changes
- ConverterService lazy-loading related changes
- Payload for constructor of PlaceOrder class from Checkout actions requires an additional property
- PlaceOrderComponent
- Property renamed in SearchConfig interface
- Changes in CheckoutStepsState interface
- Changes in CheckoutState interface
- OutletRefDirective unregisters template on destroy
- CartItemComponent lost members
- CartItemListComponent
- AddToCartComponent
- Auth module refactor
- KymaModule
- ASM module refactor
- CDC library
- OrderDetailHeadlineComponent
- OrderDetailShippingComponent
- OrderConfirmationOverviewComponent
- BaseSiteService
- ConfigInitializerService constructor
- CmsComponentsService constructor
- CheckoutProgressMobileBottomComponent
- CheckoutProgressMobileTopComponent
- CheckoutProgressComponent
- DeliveryModeComponent
- PaymentMethodComponent
- ShippingAddressComponent
- CheckoutAuthGuard
- CheckoutConfigService
- The placeOrder method for CheckoutAdapter, OccCheckoutAdapter and CheckoutConnector
- BreakpointService
- ProtectedRoutesGuard
- ItemCounterComponent
- ViewComponent
- UpdateEmailComponent
- StorefrontComponent
- StarRatingComponent
- CartNotEmptyGuard
- NotCheckoutAuthGuard
- ProductVariantGuard
- LogoutGuard
- CurrentProductService
- MultiCartStatePersistenceService
- ProductReferenceService
- LanguageService
- CurrencyService
- OccCmsComponentAdapter
- UserState
- CloseAccountModalComponent
- BaseSiteState
- UserService
- UserOrderService
- Checkout selectors
- ProductListComponentService
- ProductCarouselService
- CheckoutService
- AnonymousConsentTemplatesAdapter
- AnonymousConsentTemplatesConnector
- SplitViewComponent
- Error payload of LOAD FAIL actions has changed in
@spartacus/core
- Automated Migrations for Version 3.0
Breaking Changes Introduced in 3.0
Translations (i18n) changed
- fixed the typo in the key
user.register.managementInMyAccount(previously …managmentInMyAccount) - key
checkout.checkoutReview.editShippingMethodwas removed - key
checkout.checkoutReview.editPaymentMethodwas removed
Default router options changed
The Angular router can be initialized with so-called ExtraOptions in the forRoot method of the RouterModule. For more information, see https://angular.io/api/router/ExtraOptions.
The default ExtraOptions have changed with 3.0. Before 3.0, Spartacus set the anchorScrolling and scrollPositionRestoration options. In Spartacus 3.0, the scrollPositionRestoration was removed, and the relativeLinkResolution and initialNavigation have been added. See the following table for the actual values and reasoning:
| Option | < 3.0 | ≥ 3.0 |
|---|---|---|
anchorScrolling |
'enabled' |
'enabled' |
scrollPositionRestoration |
'enabled' |
(removed) |
relativeLinkResolution |
n/a | 'corrected' |
initialNavigation |
n/a | 'enabled' |
The enabled scrollPositionRestoration was causing a bad experience in most cases, as it would scroll the page to the top on each route change. This is unexpected in a single page experience.
The corrected relativeLinkResolution is used to opt-in to a fix that was added in Angular. This will become the default from Angular 11 onwards.
The enabled initialNavigation provides a better experience with server-side rendering, which starts initial navigation before the root component is created and blocks bootstrap until the initial navigation is complete. For more information, see the Angular documentation.
The RouterModule.forRoot() method can actually be called only once in an Angular application. This makes the default options rather opinionated, which is why the default configurations are carefully selected in Spartacus. The options that have been added or removed can be provided in your custom application with the Angular ROUTER_CONFIGURATION injection token. The following is an example:
providers: [
{
provide: ROUTER_CONFIGURATION,
useValue: {
scrollPositionRestoration: 'enabled',
},
},
];
There is no automation (schematics) planned for this change.
Page Layout
With version 2.1, we started to add the page layout-based style class to the root element of the application (cx-storefront). This was done in addition to the style class being added by the PageLayoutComponent. The style class on the PageLayoutComponent was considered to be too limited, as it would not affect selectors outside the page template component.
The implementation of the page layout-based style class has moved from the PageLayoutComponent to the PageTemplateDirective. This results in a cleaner PageLayoutComponent with a constructor that no longer requires the lower level Renderer2 service and ElementRef. The constructor reduces to the following signature:
constructor(protected pageLayoutService: PageLayoutService) {}
We’ve also made the PageLayoutService a protected argument, so that it is extensible.
There is no automation (schematics) planned to migrate constructors automatically.
Static CMS structure config changes
The default-header-config and default-cms-content-config have been removed. To create CMS content, use the defaultCmsContentProviders instead.
OCC prefix
The default value for the backend.occ.prefix configuration option was changed from /rest/v2/ to /occ/v2/.
Storefront config
The new config SeoConfig is imported.
JSON-LD schemas
To continue using JSON-LD schemas in Spartacus, or to start using JSON-LD schemas in Spartacus, you need to import the JsonLdBuilderModule to your application.
ContentPageMetaResolver
The ContentPageMetaResolver has a new required constructor dependency RoutingPageMetaResolver.
LoginFormComponent
It is no longer the responsibility of the LoginFormComponent to redirect to the anticipated page (it no longer calls the method AuthRedirectService.redirect). Now the redirecting logic is placed inside the core AuthService to support more OAuth flows.
The LoginFormComponent no longer has the loginAsGuest and sub properties, and the ngOnDestroy method was removed as well.
HttpClientModule is not imported in feature libraries
In most cases, the HttpClientModule should only be imported in the root app module, because importing it in lazy-loaded modules can
cause unexpected side effects regarding the visibility of HTTP_INTERCEPTORS, and so on. To fix this, we removed all HttpClientModule imports from all of our feature libraries and moved them to recipes.
There is no automation (schematics) planned for this change.
SSR engine optimizations
The NgExpressEngineDecorator now adds SSR optimization logic on top of the universal engine by default.
The NgExpressEngineDecorator was moved from @spartacus/core to @spartacus/setup/ssr. Also, the NgExpressEngineDecorator.get() method now accepts an additional second parameter to fine-tune SSR optimizations. Passing null there will turn off optimizations by removing the optimization layer completely (which brings back default 2.x behavior).
Store finder functionality was moved to a new library
The store finder logic from @spartacus/core and the store finder components from @spartacus/storefront were moved to respective entry points in the @spartacus/storefinder library. Store finder translations (storeFinderTranslations) and translation chunks (storeFinderTranslationChunksConfig) were moved to @spartacus/storefinder/assets.
Store finder functionality is now also lazy-loadable out of the box.
StockNotificationComponent
The StockNotificationComponent has a new required UserIdService dependency, but no longer depends on AuthService.
CmsComponentsService
The return type for the CmsComponentsService.getChildRoutes method has changed from Route[] to CmsComponentChildRoutesConfig.
Config cmsComponents
The childRoutes property of the cmsComponents config changed type from Route[] to Route[] | CmsComponentChildRoutesConfig.
PageMetaService lazy-loading related changes
- The return type for the
PageMetaService.getMetamethod changed fromObservable<PageMeta>toObservable<PageMeta | null>so it can take into account page meta resolvers from lazy-loaded features. - The return type for the
PageMetaService.getMetaResolverprotected method changed fromPageMateResolvertoObservable<PageMetaResolver>so it can take into account page meta resolvers from lazy-loaded features. - The constructor for
PageMetaServicenow uses theUnifiedInjectorinstead of injecting thePageMetaResolvertoken directly.
ConverterService lazy-loading related changes
The constructor for ConverterService now uses the UnifiedInjector instead of the standard Injector.
Payload for constructor of PlaceOrder class from Checkout actions requires an additional property
The Checkout.action constructor payload now needs an additional termsChecked property.
PlaceOrderComponent
- The
placeOrderSubscriptionproperty was removed. There is no replacement. - The component has the following new, required constructor dependencies:
CheckoutReplenishmentFormService,LaunchDialogServiceandViewContainerRef.
Property renamed in SearchConfig interface
The sortCode property in the SearchConfig interface was renamed to sort.
Changes in CheckoutStepsState interface
- The
CheckoutStepsStateinterface has a new, required property:poNumber: { po: string; costCenter: string; }; - The type for the
orderDetailsproperty was changed fromOrdertoOrder | ReplenishmentOrder
Changes in CheckoutState interface
The CheckoutState interface has the following new, required properties:
paymentTypes: PaymentTypesState;orderType: OrderTypesState;
OutletRefDirective unregisters template on destroy
The directive’s template in unregistered from the outlet on directive destroy.
Before v3.0, when an instance of OutletRefDirective was destroyed (removed from the DOM), its template remained registered for the outlet, which could cause the same template to be rendered multiple times if the same [cxOutletRef] was created again later on. This has now been fixed.
CartItemComponent lost members
The @Output() view and viewItem() members of the CartItemComponent have been removed. Use the [cxModal] directive instead to close modals on link click.
CartItemListComponent
There can be more than one cart entry with the same product code. So now they are referenced by the entryNumber property instead of the product code in the CartItemListComponent.
AddToCartComponent
The AddToCartComponent lost the following members:
increment- use the newnumberOfEntriesBeforeAddinsteadcartEntry$- useactiveCartService.getLastEntry(productCode)instead
Auth module refactor
The @spartacus/core library has a new dependency on the angular-oauth2-oidc library. It is used to handle OAuth login and logout flows in Spartacus.
Store
AuthSelectorswere removed. Selectors related to the client token were moved underClientAuthSelectors. The user token is no longer stored in NgRx Store. To get the token, use theAuthStorageService.getTokenmethod.StateWithAuthwas removed. The state related to the client token was moved toStateWithClientAuth. Data related to the user token are stored inAuthStorageServiceandUserIdService.AuthStatewas removed. The state related to the client token was moved toClientAuthState. Data related to the user token are stored inAuthStorageServiceandUserIdService.UserTokenStatewas removed. Data related to the user token are no longer stored in NgRx Store. The user token is stored inAuthStorageServiceand the user id is stored inUserIdService.AUTH_FEATUREwas removed. The client token state is under the key from theCLIENT_AUTH_FEATUREvariable.- The value of the
CLIENT_TOKEN_DATAvariable changed to[Client auth] Client Token Data. Previously, it was[Auth] Client Token Data. AuthActionsnow only containsLoginandLogoutaction classes andLOGINandLOGOUTvariables with action type. Actions related to the client token (LoadClientToken...) are now available underClientAuthActionsexport. TheLOGOUT_CUSTOMER_SUPPORT_AGENTconstant is available inAsmActionsexport. Actions related to the user token were removed (LOAD_USER_TOKEN,LOAD_USER_TOKEN_FAIL,LOAD_USER_TOKEN_SUCCESS,REFRESH_USER_TOKEN,REFRESH_USER_TOKEN_FAIL,REFRESH_USER_TOKEN_SUCCESS,REVOKE_USER_TOKEN,REVOKE_USER_TOKEN_FAIL,REVOKE_USER_TOKEN_SUCCESS,LoadUserToken,LoadUserTokenFail,LoadUserTokenSuccess,RefreshUserToken,RefreshUserTokenSuccess,RefreshUserTokenFail,RevokeUserToken,RevokeUserTokenSuccessandRevokeUserTokenFail). Instead, initialize the user token load, and refresh or revoke with methods exposed inAuthServiceandOAuthLibWrapperService.
Models
- The
UserTokeninterface was replaced with theAuthTokeninterface. The new interface contains different properties from the previous interface in order to match the requirements of theangular-oauth2-oidclibrary. - The
AuthenticationTokeninterface was removed. UseAuthTokenorClientTokendirectly. - The
Occ.UserGroupListinterface was removed. - The
Occ.UserSignUpinterface was removed.
Guards
NotAuthGuardnow returnsObservable<UrlTree>as the homepage for logged-in users, instead of invoking a redirect. The constructor also changed for this guard. TheRoutingServiceis no longer needed, butSemanticPathServiceandRouterare now required.AuthGuardnow returnsObservable<UrlTree>as the login page for anonymous users, instead of invoking a redirect. The constructor also changed for this guard. TheRoutingServiceis no longer needed, butSemanticPathServiceis now required.
Services
AuthRedirectServicenow requiresAuthRedirectStorageService. Please ensure to provide it. It is a replacement for theredirectUrlprivate variable.AuthServicenow requiresUserIdService,OAuthLibWrapperService,AuthStorageService,AuthRedirectServiceandRoutingService.AuthService.authorizewas renamed tologinWithCredentials. It returns a Promise that resolves after the login procedure completes. Instead of dispatching an action, the method now invokes the login method from the OAuth library and sets the correct userId, dispatches theLoginaction, and redirects to the previously-visited page.AuthService.getOccUserIdwas removed fromAuthService. Use theUserIdService.getUserIdmethod instead. It is the direct replacement.AuthService.invokeWithUserIdwas moved toUserIdService. It is available under the same name.AuthService.getUserTokenwas removed. To check if a user is logged in, useisUserLoggedIn, and to get the user id, useUserIdService.getUserId. If you need access to tokens, useAuthStorageService.getToken.AuthService.refreshUserTokenwas moved and renamed toOAuthLibWrapperService.refreshToken. The behavior changed as well. It not only dispatches actions, but performs a complete token refresh procedure from the OAuth library.AuthService.authorizeWithTokenwas removed. Instead, you can create an object of the shapeAuthTokenand pass it toAuthStorageService.setToken.- The
AuthService.logoutmethod changed behavior to redirect to thelogoutpage. Then the methodAuthService.coreLogoutis dispatched and performs operations previously done by thelogoutmethod (Logout action dispatch, clearing local state, revoking tokens). AuthService.getClientToken,AuthService.refreshClientTokenandAuthService.isClientTokenLoadedwere moved toClientTokenService.
Config
AuthConfigno longer extendsOccConfig.- The
loginandrevokeendpoints were removed fromOccConfig. Theloginendpoint is now available under thetokenEndpointproperty inAuthConfig. Therevokeendpoint is available under therevokeEndpointproperty inAuthConfig. - The
storageSyncconfiguration for theauthbranch in NgRx Store was removed. The state of the token and userId is now synchronized withAuthStatePersistenceService. Override this service if you want to sync more properties tolocalStorage(for example,refresh_token). - The
storageSyncconfiguration for theanonymous-consentsbranch in NgRx Store was removed. The state is now synchronized withAnonymousConsentsStatePersistenceService. Override this service if you want to sync more or less properties tolocalStorage.
KymaModule
The KymaModule was removed with all its code. We expose the same functionality through configuration of auth.
To fetch the OpenId token along with the access token in Resource Owner Password Flow, you have to use following configuration:
authentication: {
client_id: 'client4kyma',
client_secret: 'secret',
OAuthLibConfig: {
responseType: 'id_token',
scope: 'openid',
customTokenParameters: ['token_type', 'id_token'],
}
}
Then you can access the OpenId token with the OAuthLibWrapperService.getIdToken method. For more options related to the OpenId token, look into the angular-oauth2-oidc library documentation.
ASM module refactor
getCustomerSupportAgentTokenState,getCustomerSupportAgentTokenandgetCustomerSupportAgentTokenLoadingwere removed fromAsmSelectors. To get a token, useAuthStorageService.getTokenandAsmAuthStorageService.getTokenTargetto check if it belongs to the CS agent.- Effects in
AsmModulenow usenormalizeHttpErrorinstead ofmakeErrorSerializablefor error transformation. - The
storageSyncconfiguration for theasmbranch in NgRx Store was removed. The state of the ASM UI and tokens is now synchronized withAsmStatePersistenceService. - The
CSAGENT_TOKEN_DATAvariable was removed. - The
AsmState.csagentTokenwas removed. The token is now stored inAuthStorageService. CheckAsmAuthStorageService.getTokenTargetto validate if the token belongs to the CS agent. AsmActionsno longer contains actions related to the customer agent token (LoadCustomerSupportAgentToken,LoadCustomerSupportAgentTokenFail,LoadCustomerSupportAgentTokenSuccess). Instead, interact directly withCsAgentAuthService.- The
CustomerSupportAgentTokenInterceptorinterceptor was removed. Token and error handling for CS agent requests are now handled byAuthInterceptorandAsmAuthHttpHeaderService.
AsmAuthService
The AsmAuthService was renamed to CsAgentAuthService. This service is now responsible for making the AuthService aware of ASM, and adjusts it for CS agent support.
AsmAuthService.authorizeCustomerSupportAgentwas moved toCsAgentAuthService. It now performs full login flow for the CS agent and resolves when it completes.AsmAuthService.startCustomerEmulationSessionwas moved toCsAgentAuthService. Behavior has not changed.AsmAuthService.isCustomerEmulationTokenwas removed. To check the token, useAuthStorageService.getToken, and to check if it belongs to the CS agent, useAsmAuthStorageService.getTokenTarget.AsmAuthService.getCustomerSupportAgentTokenwas removed. To check the token, useAuthStorageService.getTokenand to check if it belongs to the CS agent, useAsmAuthStorageService.getTokenTarget.AsmAuthService.getCustomerSupportAgentTokenLoadingwas moved toCsAgentAuthService. Note: It is not implemented there yet.AsmAuthService.logoutCustomerSupportAgentwas moved toCsAgentAuthService. It performs the logout procedure for the CS agent and resolves when it completes.
CDC library
CdcUserTokenEffectsnow usesnormalizeHttpErrorfor error serialization.- The
CdcUserTokenEffects.loadCdcUserToken$effect now callsCdcAuthService.loginWithTokeninstead of dispatchingAuthActions.LoadUserTokenSuccessaction. CdcAuthServiceno longer extendsAuthService.CdcAuthServicehas the following new, required dependencies:AuthStorageService,UserIdService,GlobalMessageServiceandAuthRedirectServiceneed to provided.- The
CdcAuthService.authorizeWithCustomCdcFlowmethod was renamed tologinWithCustomCdcFlow. - The
CdcAuthService.logoutmethod was removed. Now CDC hooks into the logout process by providingCdcLogoutGuardasLogoutGuard. CdcJsServicenow requiresAuthServicebecauseCdcAuthServiceno longer extends it.AuthServiceshould be passed afterCdcAuthService.CdcAuthServiceis available in the service undercdcAuthandAuthServiceis available under theauthproperty. Additionally,GlobalMessageServiceandAuthRedirectServiceare not longer required. Note that we do not provide automatic migration for that constructor change.
OrderDetailHeadlineComponent
The OrderDetailHeadlineComponent was removed.
OrderDetailShippingComponent
The following functions have been removed from the OrderDetailShippingComponent component:
getAddressCardContent()getBillingAddressCardContent()getPaymentCardContent()getShippingMethodCardContent()
You can use the OrderOverviewComponent instead.
OrderConfirmationOverviewComponent
The following functions have been removed from the OrderConfirmationOverviewComponent component:
getAddressCardContent()getDeliveryModeCardContent()getPaymentInfoCardContent()getBillingAddressCardContent()
The return type for order$ was changed from Observable<Order> to Observable<any>.
BaseSiteService
The BaseSiteService type is changed from BaseSiteService implements SiteContext<string> to BaseSiteService implements SiteContext<BaseSite>.
The return type of the getAll() function is changed from getAll(): Observable<string[]> to getAll(): Observable<BaseSite[]>.
The return type of the setActive(baseSite: string) function is changed from setActive(baseSite: string): Subscription to setActive(baseSite: string): void.
ConfigInitializerService constructor
An additional parameter was added to the ConfigInitializerService constructor. Before 3.0, it was the following:
constructor(
@Inject(Config) protected config: any,
@Optional()
@Inject(CONFIG_INITIALIZER_FORROOT_GUARD)
protected initializerGuard
) {}
In Spartacus 3.0, it is the following:
constructor(
@Inject(Config) protected config: any,
@Optional()
@Inject(CONFIG_INITIALIZER_FORROOT_GUARD)
protected initializerGuard,
@Inject(RootConfig) protected rootConfig: any
CmsComponentsService constructor
An additional parameter was added to the CmsComponentsService constructor. Before 3.0, it was the following:
constructor(
protected config: CmsConfig,
@Inject(PLATFORM_ID) protected platformId: Object
) {}
In Spartacus 3.0, it is the following:
constructor(
protected config: CmsConfig,
@Inject(PLATFORM_ID) protected platformId: Object,
protected featureModules?: FeatureModulesService
) {}
The configurationFactory was removed
The configuration merging logic now uses separate tokens for the default configuration and the user configuration.
CheckoutProgressMobileBottomComponent
- The
routerState$property was removed. This logic is now handled bycheckoutStepService. - The
activeStepUrlproperty was removed. This logic is now handled bycheckoutStepService. - The
stepsproperty was removed. Usesteps$instead.
CheckoutProgressMobileTopComponent
- The
routerState$property was removed. This logic is now handled bycheckoutStepService. - The
activeStepUrlproperty was removed. This logic is now handled bycheckoutStepService. - The
stepsproperty was removed. Usesteps$instead.
CheckoutProgressComponent
- The
routerState$property was removed. This logic is now handled bycheckoutStepService. - The
activeStepUrlproperty was removed. This logic is now handled bycheckoutStepService. - The
stepsproperty was removed. Usesteps$instead.
DeliveryModeComponent
- The
checkoutStepUrlNextproperty was removed. This logic is now handled bycheckoutStepService. - The
checkoutStepUrlPreviousproperty was removed. This logic is now handled bycheckoutStepService. - The
currentDeliveryModeIdproperty was removed. The current delivery mode selection is stored in a form called “mode” in the “deliveryModeId” input field. Also, you can useCheckoutDeliveryService.getSelectedDeliveryMode()to access the selected delivery mode in the checkout state. - The
supportedDeliveryModes$property was modified. This observable will now only emit when the data in the list of supported delivery modes changes. - The
next()function does not update the delivery mode on the cart because the delivery mode is already updated on the cart when the component initializes, and when a choice is made in the delivery mode form.
PaymentMethodComponent
- The
checkoutStepUrlNextproperty was removed. This logic is now handled bycheckoutStepService. - The
checkoutStepUrlPreviousproperty was removed. This logic is now handled bycheckoutStepService. - The
goNextmethod was renamed tonext. - The
goPreviousmethod was renamed toback.
ShippingAddressComponent
- The
existingAddresses$property was removed. - The
newAddressFormManuallyOpenedproperty was renamed toaddressFormOpened. - The
goNextmethod was renamed tonext. - The
goPreviousmethod was renamed toback. - The
ShippingAddressComponentnow implementsOnDestroy.
CheckoutAuthGuard
The canActivate method now returns the type Observable<boolean | UrlTree.
CheckoutConfigService
- The
stepsproperty was removed. UsecheckoutStepServiceinstead. - The
checkoutStepServicemethod was removed. Use thecheckoutStepRoutemethod incheckoutStepServiceinstead. - The
getFirstCheckoutStepRoutemethod was removed. Use thegetFirstCheckoutStepRoutemethod incheckoutStepServiceinstead. - The
getFirstCheckoutStepRoutemethod was removed. Use thegetFirstCheckoutStepRoutemethod incheckoutStepServiceinstead. - The
getNextCheckoutStepUrlmethod was removed. Use thegetNextCheckoutStepUrlmethod incheckoutStepServiceinstead. - The
getPreviousCheckoutStepUrlmethod was removed. Use thegetPreviousCheckoutStepUrlmethod incheckoutStepServiceinstead. - The
getCurrentStepIndexmethod was removed. Use thegetCurrentStepIndexmethod incheckoutStepServiceinstead. - The
CheckoutConfigServiceno longer usesRoutingConfigService.
The placeOrder method for CheckoutAdapter, OccCheckoutAdapter and CheckoutConnector
The placeOrder method for CheckoutAdapter, OccCheckoutAdapter and CheckoutConnector now has a new, third, required argument: termsChecked: boolean.
BreakpointService
- The public
window()getter method was removed. Instead, you can directly reference thewindowRef. - The protected
getClosestmethod was removed. Instead, use thegetBreakpointmethod. - The
_breakpointsproperty was removed. - The public
breakpoint$getter was removed. Instead, use thebreakpoint$property. - The
BreakpointServicehas a new, requiredplatformdependency.
ProtectedRoutesGuard
The return type of the ProtectedRoutesGuard.canActivate method changed from Observable<boolean> to Observable<boolean | UrlTree>.
ItemCounterComponent
The ItemCounterComponent component now implements OnInit and OnDestroy.
ViewComponent
The protected splitViewCount getter method was removed.
UpdateEmailComponent
The return type of the onSuccess method was changed from void to Promise<void> in order to wait for the logout to complete before updating the email.
StorefrontComponent
The param type of the collapseMenuIfClickOutside method was changed from MouseEvent to any. The behavior has also been modified to only trigger when the header element is passed to the function.
StarRatingComponent
- The
StarRatingComponentusesHostBindingto bind to CSS custom properties (available since angular 9), which is why we no longer need theElementRefandRenderer2in the constructor. There is an automated constructor migration added for the 3.0 release. ngOnInitis no longer used.- The
setRateno longer requires a second argument (force). - The
setRateOnEvent()method is replaced by reusing thesetRate()(which also fixes a bug). We now bindkeydown.spacedirectly from the view. The more generickeydownoutput binding was removed.
CartNotEmptyGuard
- The return type of the
canActivatemethod was changed fromObservable<boolean>toObservable<boolean | UrlTree>to support OAuth flows. SemanticPathServiceis a new, required constructor dependency.Routeris new, required constructor dependency.CartNotEmptyGuardno longer usesRoutingService. The use of this service was replaced with the corresponding methods fromRouterandSemanticPathService.
NotCheckoutAuthGuard
The return type of the canActivate method was changed from Observable<boolean> to Observable<boolean | UrlTree> to support OAuth flows.
ProductVariantGuard
- The
canActivatemethod now requires a parameter of typeActivatedRouteSnapshot.
LogoutGuard
- The return type of the
canActivatemethod was changed fromObservable<boolean>toObservable<boolean | UrlTree>to support OAuth flows. - The return type of the
logoutmethod was changed fromvoidtoPromise<any>to support OAuth flows. - The
redirectmethod was removed. UsegetRedirectUrlinstead.
CurrentProductService
The getProduct method now only emits distinct products.
MultiCartStatePersistenceService
The sync method was renamed to initSync.
ProductReferenceService
The get method was removed. Use the getProductReferences and loadProductReferences methods instead.
LanguageService
The return type of the setActive method was changed from Subscription to void.
CurrencyService
The return type of the setActive method was changed from Subscription to void.
OccCmsComponentAdapter
The OCC CMS component API in SAP Commerce Cloud before version 1905 was using a POST method. This was changed in 1905 to use a GET method instead. Spartacus has supported both version from version 1.0 by using a legacy flag to distinguish this back end API behavior. With the release of Spartacus 3.0, we maintain the support for the pre-1905 CMS component API, but the implementation was moved to a separate adapter (LegacyOccCmsComponentAdapter). With that change, we are also dropping the legacy flag in the OCC configuration.
UserState
The interface for the UserState NgRx state now has the following new, required properties: replenishmentOrders, replenishmentOrder and costCenters.
CloseAccountModalComponent
The userToken$ property of the CloseAccountModalComponent was replaced with isLoggedIn$ of type Observable<boolean>.
BaseSiteState
The BaseSiteState interface has now a new, required entities: BaseSiteEntities property.
UserService
The loadOrderList method of the UserService also loads replenishment orders when the URL contains a replenishment code.
UserOrderService
The getTitles method of the UserOrderService will load titles when it is empty.
Checkout selectors
The MemoizedSelector return type of the getCheckoutOrderDetails selector was changed from Order to Order | ReplenishmentOrder.
ProductListComponentService
- The
subproperty was removed fromProductListComponentService. It is no longer used. - The
setQuerymethod was removed fromProductListComponentService. It is no longer used. - The
viewPagemethod was removed fromProductListComponentService. It is no longer used.
ProductCarouselService
The getProductReferences() function was removed.
CheckoutService
- The
placeOrdermethod of theCheckoutServicenow requires atermsCheckedparameter. - The return type of the
getOrderDetailsmethod was changed fromObservable<Order>toObservable<Order | ReplenishmentOrder>.
AnonymousConsentTemplatesAdapter
The loadAnonymousConsents method of AnonymousConsentTemplatesAdapter is no longer optional.
AnonymousConsentTemplatesConnector
The return type of the loadAnonymousConsents method of the AnonymousConsentTemplatesConnector was changed from Observable<AnonymousConsent[] | null> to Observable<AnonymousConsent[]>.
SplitViewComponent
The subscription property of the SplitViewComponent is no longer protected. It is private now.
Error payload of LOAD FAIL actions has changed in @spartacus/core
It now has a consistent shape of HttpErrorModel or is undefined.
Automated Migrations for Version 3.0
CheckoutProgressMobileBottomComponentno longer usesCheckoutConfig,RoutingServiceandRoutingConfigService. The use of these services was replaced with the corresponding methods from theCheckoutStepService. This service needs to be provided to theCheckoutProgressMobileBottomComponent.CheckoutAuthGuardno longer usesRoutingService. The use of this service was replaced with the corresponding methods fromRouterandSemanticPathService. The additionalUserServiceandGlobalMessageServiceservices also need to be provided toCheckoutAuthGuard.CheckoutProgressMobileTopComponentno longer usesCheckoutConfig,RoutingServiceandRoutingConfigService. The use of these services was replaced with the corresponding methods fromCheckoutStepService. This service needs to be provided toCheckoutProgressMobileTopComponent.CheckoutProgressComponentno longer usesCheckoutConfig,RoutingServiceandRoutingConfigService. The use of these services was replaced with the corresponding methods fromCheckoutStepService. This service needs to be provided toCheckoutProgressComponent.DeliveryModeSetGuardno longer usesCheckoutConfigService. The use of this service was replaced with the corresponding methods fromCheckoutStepService. This service needs to be provided toDeliveryModeSetGuard.DeliveryModeComponentno longer usesRoutingService. The use of this service was replaced with the corresponding methods fromCheckoutStepService. This service needs to be provided toDeliveryModeComponent.LoginFormComponentno longer usesActivatedRoute,CheckoutConfigServiceandAuthRedirectService. The logic that used these services was moved to a different component.OrderDetailShippingComponentno longer usesTranslationService. The logic that used this service was moved toOrderDetailShippingComponent.PaymentDetailsSetGuardno longer usesCheckoutConfigService. The use of this service was replaced with the corresponding methods fromCheckoutStepService. This service needs to be provided toPaymentDetailsSetGuard.PaymentMethodComponentno longer usesCheckoutConfigServiceandRoutingService. The use of these services was replaced with the corresponding methods fromCheckoutStepService. This service needs to be provided toPaymentMethodComponent.ReviewSubmitComponentno longer usesCheckoutConfigService. The use of this service was replaced with the corresponding methods fromCheckoutStepService. In addition,PaymentTypeService,CheckoutCostCenterServiceandUserCostCenterServiceneed to be provided toReviewSubmitComponent.ShippingAddressSetGuardno longer usesCheckoutConfigService. The use of this service was replaced with the corresponding methods fromCheckoutStepService. This service needs to be provided toShippingAddressSetGuard.ShippingAddressComponentno longer usesCheckoutConfigServiceandRoutingService. The use of these services was replaced with the corresponding methods fromCheckoutStepService. This service needs to be provided toShippingAddressComponent.MultiCartServicenow requires the additional providerUserIdService.PageSlotComponentno longer usesCmsComponentsService. The use of this service was replaced with thePageSlotService.ForbiddenHandlernow usesGlobalMessageService,AuthService, andOccEndpointsService.CheckoutPaymentServiceno longer usesAuthService. The use of this service was replaced with the corresponding methods fromUserIdService.CheckoutServiceno longer usesAuthService. The use of this service was replaced with the corresponding methods fromUserIdService.CustomerCouponServiceno longer usesAuthService. The use of this service was replaced with the corresponding methods fromUserIdService.OrderReturnRequestServiceno longer usesAuthService. The use of this service was replaced with the corresponding methods fromUserIdService.UserAddressServiceno longer usesAuthService. The use of this service was replaced with the corresponding methods fromUserIdService.UserConsentServicenow also requiresUserIdService.UserInterestsServiceno longer usesAuthService. The use of this service was replaced with the corresponding methods fromUserIdService.UserNotificationPreferenceServiceno longer usesAuthService. The use of this service was replaced with the corresponding methods fromUserIdService.UserOrderServiceno longer usesAuthService. The use of this service was replaced with the corresponding methods fromUserIdService. It now also requiresRoutingService.UserPaymentServiceno longer usesAuthService. The use of this service was replaced with the corresponding methods fromUserIdService.UserServiceno longer usesAuthService. The use of this service was replaced with the corresponding methods fromUserIdService.ActiveCartServiceno longer usesAuthService. The use of this service was replaced with theUserIdService.CartVoucherServiceno longer usesAuthService. The use of this service was replaced with theUserIdService.SelectiveCartServiceno longer usesAuthService. The use of this service was replaced with theUserIdService.WishListServiceno longer usesAuthService. The use of this service was replaced with theUserIdService.CheckoutDeliveryServiceno longer usesAuthService. The use of this service was replaced with theUserIdService.UnauthorizedErrorHandlerwas removed.StarRatingComponentno longer usesElementRefandRenderer2.ProductCarouselServiceno longer usesProductReferenceService.NotCheckoutAuthGuardno longer usesRoutingService. The use of this service was replaced with the corresponding methods fromSemanticPathServiceandRouter.StoreFinderSearchConfigwas removed.SearchConfigshould be used instead.ForgotPasswordComponentnow also requiresAuthConfigService.OrderHistoryComponentnow also requiresUserReplenishmentOrderService.OrderReturnGuardno longer usesRoutingService. The use of this service was replaced with the corresponding methods fromRouterandSemanticPathService.OrderCancellationGuardno longer usesRoutingService. The use of this service was replaced with the corresponding methods fromRouterandSemanticPathService.OutletRefDirectiveno longer usesFeatureConfigService.OutletServiceno longer usesFeatureConfigService.RoutingServicenow also requiresRoutingParamsService.TOKEN_REVOCATION_HEADERwas removed.JsonLdScriptFactorynow also requiresSeoConfig.LogoutGuardno longer usesRoutingService. The use of this service was replaced with the corresponding methods fromRouter.ProductVariantGuardno longer usesRoutingService. The use of this service was replaced with the corresponding methods fromRouterandSemanticPathService.FeatureModulesServiceno longer has thegetInjectorsmethod.CmsComponentsServiceno longer has thegetInjectorsmethod.ViewComponentnow also requiresChangeDetectorRef.SplitViewDeactivateGuardwas removed.FeatureModulesServiceno longer usesCompiler. The newly-addedgetModulemethod does not need it anymore.FeatureModulesServiceno longer usesInjector. The newly-addedgetModulemethod does not need it anymore.FeatureModulesServicenow usesLazyModulesService.JsonLdProductReviewBuildernow usesSeoConfig.RegisterComponentnow usesAuthConfigService.SplitViewComponentnow also requiresBreakpointServiceandElementRef.CheckoutGuardnow also requiresCheckoutStepService.OrderConfirmationOverviewComponentno longer usesTranslationService. The logic using this service was moved to theOrderOverviewComponent.