Hook Interfaces and Strategies in Hybris

Customizing ordering processes could not be easier. Those were days when we used to override facades, services and strategies to inject a line of code just before or after a specific event in an ordering process. E.g. Before and After:

  • payment Authorization
  • adding product to cart
  • cart calculation lifecycle
  • cloning a saved cart
  • flagging a cart for deletion
  • Placing order
  • saving a cart
  • restoring a cart
  • updating cart entry

  Since version 5.4 onward (if I am not wrong) SAP Hybris has introduced a number of hook interfaces which can be implemented to inject your code at a specific time without hassle of overriding a chain of classes. Below is a list of few of them:

  • AuthorizePaymentMethodHook
  • CommerceAddToCartMethodHook
  • CommerceCartCalculationMethodHook
  • CommerceCloneSavedCartMethodHook
  • CommerceFlagForDeletionMethodHook
  • CommercePlaceOrderMethodHook
  • CommerceSaveCartMethodHook
  • CommerceSaveCartRestorationMethodHook
  • CommerceUpdateCartEntryHook

Usage: Implement required interface and corresponding method. And define below bean and add entry in directive: <bean id=yourCustomAddToCartMethodHook class=”xx.yy.zz”/> <bean id=“commerceAddToCartMethodHooksListMergeDirective” depends-on=“commerceAddToCartMethodHooks” parent=“listMergeDirective”> <property name=“add” ref=yourCustomAddToCartMethodHook /> </bean>    

4 thoughts on “Hook Interfaces and Strategies in Hybris

  1. Hello, I think your website might be having browser compatibility
    issues. When I look at your blog site in Chrome,
    it looks fine but when opening in Internet Explorer,
    it has some overlapping. I just wanted to give you a quick heads
    up! Other then that, awesome blog!


What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s