@RequestMapping(value = FoUrls.DELETE_CART_ITEM_AJAX_URL, method = RequestMethod.GET)
@ResponseBody
public FoCheckoutPojo deleteItem(final HttpServletRequest request, final HttpServletResponse response) throws Exception {
final RequestData requestData = requestUtil.getRequestData(request);
final String productSkuCode = request.getParameter(RequestConstants.REQUEST_PARAMETER_CART_ITEM_SKU_CODE);
final FoCheckoutPojo checkout = new FoCheckoutPojo();
try {
webManagementService.deleteCartItem(requestData, productSkuCode);
final Cart cart = requestData.getCart();
if(cart != null
&& cart.getTotalCartItems() == 0){
FoMessagePojo errorMessage = new FoMessagePojo();
errorMessage.setId("warning-empty-cart");
errorMessage.setMessage("Your cart is empty");
checkout.getErrorMessages().add(errorMessage);
}
} catch (Exception e) {
logger.error("", e);
FoMessagePojo errorMessage = new FoMessagePojo();
errorMessage.setId("error-delete-item");
errorMessage.setMessage(e.getMessage());
checkout.getErrorMessages().add(errorMessage);
checkout.setStatuts(false);
return checkout;
}
injectCart(requestData, checkout);
return checkout;
}