@Override
public int doStartTag() throws JspException {
WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(pageContext.getServletContext());
Customer customer = CustomerState.getCustomer((HttpServletRequest) pageContext.getRequest());
LegacyCartService cartService = (LegacyCartService) applicationContext.getBean("blOrderService");
Order order = null;
if (orderName != null && orderId != null) {
throw new IllegalArgumentException("Only orderName or orderId attribute may be specified on orderLookup tag");
} else if (orderId != null) {
order = cartService.findOrderById(orderId);
} else if (orderName != null) {
order = cartService.findNamedOrderForCustomer(orderName, customer);
} else if (customer != null){
order = cartService.findCartForCustomer(customer);
}
if (orderVar != null) {
pageContext.setAttribute(orderVar, order);
}
if (totalQuantityVar != null) {
int orderItemsCount = 0;
if (order != null && order.getOrderItems() != null) {
for (OrderItem orderItem : order.getOrderItems()) {
orderItemsCount += orderItem.getQuantity();
}
}
pageContext.setAttribute(totalQuantityVar, orderItemsCount);
} else if (totalQuantityVar != null) {