Skip to main content

Hybris redirection to Commerce Layer checkout

Context

We are going to deploy the new Checkout project iteratively by market or groups of markets, starting with Ireland. Users will shop and add to their basket using the Hybris storefront. When a user in Ireland moves from their basket to the checkout we will redirect them to the new Commerce Layer checkout. All other users will remain on the Hybris checkout. At the point at which the user is redirected, a cart (a draft order) will be created for the user in Commerce Layer. When the user completes the checkout in Commerce Layer and their order status is updated to "placed" we need to delete the cart in Hybris.

Decision

We will create Commerce Layer draft order as an anonymous user and redirect the customer to Commerce Layer checkout once the customer clicks on Checkout button in cart page.

Cart checkout button

Design for Hybris redirection to Commerce Layer checkout

  1. Once customer clicks on Checkout button, Hybris MultiStepCheckoutController.enterStep will be invoked.
  2. Check if customer is navigating from Ireland based on IP (Maxmind service).
  3. If customer is navigating from Ireland:
    1. Request Commerce Layer token
    2. Create new draft order in Commerce Layer
    3. Add to draft order Hybris cart items
    4. Redirect customer to Commerce Layer checkout, passing in url parameters the draft order id and token.
  4. If customer is navigating from other country, continue on current Hybris checkout.

Hybris cart code needs to be saved in Commerce Layer draft order hybris_cart_id metadata attribute, to maintain a relation between both systems.

Consequences and limitations

  • This process will keep Hybris cart active, it is needed to clean up it once checkout is successfull: Clear Hybris order.
  • Hybris stock won't be decreased when the order is placed on Commerce Layer.
  • Commerce Layer checkout is performed as anonymous customer.
  • Customer order placed in Commerce Layer won't appear in Hybris order history.
  • As the checkout is going to be anonymous, can handle properly products restricted to user groups (RCC)

Resources