Skip to content

Instantly share code, notes, and snippets.

View sf-thomas-loesche's full-sized avatar

sf-thomas-loesche

View GitHub Profile
@sf-thomas-loesche
sf-thomas-loesche / Readme.md
Last active August 29, 2025 08:42 — forked from shethj/Readme.md
Merge basket utility functions using Script API for SFRA & SiteGenesis storefronts.

Merge Basket Utility Functions Using Script API

Merging shopping baskets is crucial for ensuring a seamless and consistent shopper experience. For example: when a guest shopper, who has added items to their basket, decides to log in or create an account. Without basket merging, the shopper loses their previously selected items, potentially leading to frustration and abandoned baskets.

When merging baskets in Salesforce Commerce Cloud (SFCC), we recommend using the dw.order.mergeBasket hook (added in B2C Commerce version 25.10), which provides a default, out-of-the-box implementation for merging baskets. The script handles specific business requirements for how data should be consolidated during a shopper's journey when transitioning from a guest to a logged-in state, and you can extend or modify the script to introduce bespoke merging logic.

The mergeBasketUtil.js script behaves like the default implementation, making it an ideal starting point for customization.

Implement the Merge Hook