Class CartStateRefresher

java.lang.Object
org.broadleafcommerce.core.web.order.CartStateRefresher
All Implemented Interfaces:
EventListener, org.springframework.context.ApplicationListener<org.broadleafcommerce.core.order.domain.OrderPersistedEvent>

@Component("blCartStateRefresher") public class CartStateRefresher extends Object implements org.springframework.context.ApplicationListener<org.broadleafcommerce.core.order.domain.OrderPersistedEvent>
ApplicationListener responsible for updating CartState with a new version that was persisted.
Author:
Phillip Verheyden (phillipuniverse)
  • Constructor Details

    • CartStateRefresher

      public CartStateRefresher()
  • Method Details

    • onApplicationEvent

      public void onApplicationEvent(org.broadleafcommerce.core.order.domain.OrderPersistedEvent event)

      Resets CartState with the newly persisted Order. If CartState was empty, this will only update it if the Order that has been persisted is the OrderStatus.IN_PROCESS Order for the active Customer (as determined by CustomerState.getCustomer(). If CartState was not empty, then it will be replaced only if this newly persisted Order has the same id.

      This ensures that whatever is returned from CartState.getCart() will always be the most up-to-date database version (meaning, safe to write to the DB).

      Specified by:
      onApplicationEvent in interface org.springframework.context.ApplicationListener<org.broadleafcommerce.core.order.domain.OrderPersistedEvent>