Intershop Progressive Web App

repository·develop·Indexed 41 days ago

https://github.com/intershop/intershop-pwa

An Angular-based progressive web application storefront for the Intershop Commerce Platform. Version 12.1.0 includes support for SSR via Docker, Nginx reverse proxy configuration for multi-channel routing, Identity Provider (IdP) patterns for authentication, and Formly-based CAPTCHA integration.

Tokens
100.1K
Snippets
251
Records
532
Agent score
51%

What's inside Intershop PWA

  1. Overview of PayPal Integration in Intershop PWA

    develop

    The Intershop PWA uses the ish-payment-paypal component to dynamically load the PayPal SDK and render payment elements. The component's behavior (which elements are shown) is determined by the configured adapter type and the current page type.

    Supported features include:

    • Buttons: Standard PayPal checkout buttons.
    • Messages: Promotional 'Pay Later' messaging.
    • CardFields: Hosted credit card input fields.
    • GooglePay: Google Pay button and integration.
    • ApplePay: Apple Pay button and integration.
    <ish-payment-paypal></ish-payment-paypal>
  2. What is a Product Context?

    develop

    A Product Context provides simplified, easy access to all data related to a single product. It stores the sku and an optional quantity, then delegates other product information from the application's state management.

    Product contexts are hierarchical and scoped using Angular's ElementInjector. This means they are only available to elements within the document subtree where the context was introduced. This allows for multiple contexts to exist on a single page (e.g., one main context for a product page and additional contexts for recommended or bundled products, or individual contexts for every item in a product listing).

  3. How the Field Library works

    develop

    The FieldLibrary is a central service in the Intershop PWA that enables the reuse of FormlyFieldConfig objects. It acts as a repository where predefined field configurations (singular) and configuration groups (collections of fields) are stored and can be injected into any component that uses Formly. This allows developers to maintain consistent form field behavior and styling across the application.

    To use it, you must inject the FieldLibrary into your component's constructor.

    constructor(private fieldLibrary: FieldLibrary){}
    
    // Retrieve a single field
    this.fields = [
      this.fieldLibrary.getConfiguration('firstName'),
      this.fieldLibrary.getConfiguration('lastName')
    ];
  4. Understand the Intershop PWA versioning scheme

    develop

    The Intershop PWA uses a MAJOR.MINOR.PATCH versioning format to signal the scope and upgrade effort required for a release.

    Unlike standard libraries, the PWA is a blueprint for storefront projects. Upgrading does not involve simply incrementing a dependency version; instead, projects incorporate code changes from higher PWA versions into their own source code.

    Versioning Definitions

    VersionMeaningAllowed ChangesIncludes
    MAJORCan contain breaking changes or be strategically important.Breaking and non-breaking changesFunctionality, improvements, bug fixes, major code convention changes
    MINORMust be backward compatible.Only non-breaking changesFunctionality, improvements, bug fixes
    PATCHNot used in the current release process (always 0).N/AN/A

    Note that PATCH releases are not published because bug fixes can be consumed directly via git cherry-pick or GitHub patch files.

  5. Understand Punchout token lifetime and refresh

    develop

    Authentication tokens have a predefined lifetime. To prevent expiration, the PWA uses a refresh mechanism.

    When 75% of the token's lifetime has passed (this threshold is configurable in the oAuth library), an info event is emitted. This triggers the setupRefreshTokenMechanism$ function within the oAuth configuration service to renew the token. As long as the PWA remains open in the browser, the token will be continuously renewed and will not expire.

  6. Configure CMS view context resource set ID

    develop

    In version 11.0.0, REST requests for CMS view context data append a resourceSetId (the cartridge name) by default to improve performance.

    • The default ID is app_sf_base_cm, defined in CMSService.
    • If your project uses a different resource set ID, you must provide it via the resourceSetId input on the <ish-content-viewcontext> component.
    • Alternatively, you can override the defaultResourceSetId in CMSService to apply a global change.

    Requirement: Using view context REST requests with the added resource set ID requires ICM 12.1.0 or later.

    <ish-content-viewcontext
      resourceSetId="custom_cartridge_name"
      viewContextId="viewcontext.include.product.base.top"
      [callParameters="{ Product: product.sku }"
    />
  7. Understand the Configurable B2C Theme

    develop

    The b2c theme in Intershop PWA is a 'configurable theme', meaning it is designed to be adapted at runtime using CSS custom properties (CSS variables).

    Unlike the b2b theme, which uses variables.scss to assign static values directly to SCSS variables, the b2c theme assigns CSS custom properties to those SCSS variables. This allows you to override branding (colors, logos, fonts) via inline styles on the <html> tag without rebuilding the PWA.

    Key Difference in Implementation:

    • B2B Theme: Uses direct SCSS assignments (e.g., $logo: url('...');).
    • B2C Theme: Uses CSS variable assignments (e.g., $logo: var(--logo);) and defines default values in properties.scss (e.g., --logo: url('...');).

    Important Limitation: SCSS color functions like darken() and lighten() do not work with CSS custom properties because they require real color values at compile time. The standard Intershop PWA styling has been adapted to avoid these functions, but if you use Bootstrap-generated styles that rely on $primary or $secondary, you may need to manually override those styles in your project's global styles.

    <html style="--logo: url(https://example.com/logo.svg); --logo-width: 260px; --corporate-primary: #006b99;" lang="en-US">
  8. Understand PayPal SDK script loading and namespaces

    develop

    The PaypalConfigService dynamically loads the appropriate PayPal SDK based on the selected adapter. To prevent conflicts when multiple SDK instances are required (e.g., different locales or currencies), the service uses unique namespaces.

    Access the PayPal object on the window using the following namespace formats:

    • PPCP_<payment_method_id> for Buttons and CardFields.
    • PPCP_MESSAGES for Pay Later Messages.
    // Accessing the PayPal object via its namespace
    const paypalObject = window['PPCP_FAST_CHECKOUT'];
  9. Configure NGINX cache clearing

    develop

    Cache clearing is enabled by default when the CACHE feature is active (CACHE set to on, 1, true, or yes).

    How it works:

    • The cache_clearer.sh script polls $ICM_BASE_URL/INTERSHOP/wastatistics every 15 seconds (adjustable via CACHE_CLEARER_POLL_INTERVAL).
    • When the ICM page cache is invalidated, the script deletes the corresponding cached files for that channel.
    • If CACHE_ICM_CALLS is configured, the script triggers a PURGE request to the SSR server to clear cached REST calls.

    Prerequisites:

    • ICM_BASE_URL must be set in the intershop-pwa-nginx container.
    • The $ICM_BASE_URL/INTERSHOP/wastatistics endpoint must be reachable from the NGINX container.
    • ICM page caching must be used.
    • MULTI_CHANNEL configuration must use real ICM sites (not default).
    • In Kubernetes, the intershop-pwa-nginx service account needs get permission on the endpoints resource to discover SSR Pods.

    Note: NGINX cache clearing cannot be used simultaneously with the Shared Redis Cache.

  10. Understand the styling and behavior architecture

    develop

    The Intershop Progressive Web App uses Bootstrap 5 for styling and Sass for its implementation. Unlike the older Responsive Starter Store which used Bootstrap 3, this PWA is built on modern Bootstrap standards.

    Key architectural points:

    • Global Styling: Styling is integrated as global styles via style.scss (referenced in angular.json) and is compiled automatically. The project avoids using component-specific styleUrls or styles properties in favor of this global approach.
    • Bootstrap Behavior: The project does not use the standard Bootstrap JavaScript/jQuery implementation, as it is not suitable for Angular. Instead, it relies on ng-bootstrap to provide Bootstrap widgets in an Angular-native way. Note that the HTML structure required for ng-bootstrap components may differ from standard Bootstrap HTML.
    • Theming: Main styling configurations and Bootstrap customizations are located in src/themes/main.scss.