use of org.broadleafcommerce.core.order.domain.OrderItem in project BroadleafCommerce by BroadleafCommerce.
the class FulfillmentGroupItemStrategyImpl method onItemRemoved.
@Override
public CartOperationRequest onItemRemoved(CartOperationRequest request) {
Order order = request.getOrder();
OrderItem orderItem = request.getOrderItem();
if (orderItem instanceof BundleOrderItem) {
List<OrderItem> itemsToRemove = new ArrayList<OrderItem>(((BundleOrderItem) orderItem).getDiscreteOrderItems());
for (OrderItem oi : itemsToRemove) {
request.getFgisToDelete().addAll(fulfillmentGroupService.getFulfillmentGroupItemsForOrderItem(order, oi));
}
} else {
request.getFgisToDelete().addAll(fulfillmentGroupService.getFulfillmentGroupItemsForOrderItem(order, orderItem));
}
return request;
}
use of org.broadleafcommerce.core.order.domain.OrderItem in project BroadleafCommerce by BroadleafCommerce.
the class AddOrderItemActivity method execute.
@Override
public ProcessContext<CartOperationRequest> execute(ProcessContext<CartOperationRequest> context) throws Exception {
CartOperationRequest request = context.getSeedData();
OrderItemRequestDTO orderItemRequestDTO = request.getItemRequest();
// Order has been verified in a previous activity -- the values in the request can be trusted
Order order = request.getOrder();
// Build the order item
OrderItem item = orderItemService.buildOrderItemFromDTO(order, orderItemRequestDTO);
// Check for special pricing
orderItemService.priceOrderItem(item);
order.getOrderItems().add(item);
request.setOrderItem(item);
genericEntityDao.persist(item);
return context;
}
use of org.broadleafcommerce.core.order.domain.OrderItem in project BroadleafCommerce by BroadleafCommerce.
the class RemoveOrderItemActivity method execute.
@Override
public ProcessContext<CartOperationRequest> execute(ProcessContext<CartOperationRequest> context) throws Exception {
CartOperationRequest request = context.getSeedData();
OrderItem orderItem = request.getOrderItem();
removeItemAndChildren(request.getOisToDelete(), orderItem);
return context;
}
use of org.broadleafcommerce.core.order.domain.OrderItem in project BroadleafCommerce by BroadleafCommerce.
the class RemoveOrderMultishipOptionActivity method execute.
@Override
public ProcessContext<CartOperationRequest> execute(ProcessContext<CartOperationRequest> context) throws Exception {
CartOperationRequest request = context.getSeedData();
Long orderItemId = request.getItemRequest().getOrderItemId();
OrderItem orderItem = request.getOrderItem();
if (orderItem instanceof BundleOrderItem) {
for (OrderItem discrete : ((BundleOrderItem) orderItem).getDiscreteOrderItems()) {
request.getMultishipOptionsToDelete().add(new Long[] { discrete.getId(), null });
}
} else {
request.getMultishipOptionsToDelete().add(new Long[] { orderItemId, null });
}
return context;
}
use of org.broadleafcommerce.core.order.domain.OrderItem in project BroadleafCommerce by BroadleafCommerce.
the class ValidateRemoveRequestActivity method execute.
@Override
public ProcessContext<CartOperationRequest> execute(ProcessContext<CartOperationRequest> context) throws Exception {
CartOperationRequest request = context.getSeedData();
OrderItemRequestDTO orderItemRequestDTO = request.getItemRequest();
// Throw an exception if the user did not specify an orderItemId
if (orderItemRequestDTO.getOrderItemId() == null) {
throw new IllegalArgumentException("OrderItemId must be specified when removing from order");
}
// Throw an exception if the user did not specify an order to add the item to
if (request.getOrder() == null) {
throw new IllegalArgumentException("Order is required when updating item quantities");
}
// Throw an exception if the user is trying to remove an order item that is part of a bundle
OrderItem orderItem = null;
for (OrderItem oi : request.getOrder().getOrderItems()) {
if (oi.getId().equals(orderItemRequestDTO.getOrderItemId())) {
orderItem = oi;
}
}
if (orderItem == null) {
throw new IllegalArgumentException("Could not find order item to remove");
}
if (orderItem != null && orderItem instanceof DiscreteOrderItem) {
DiscreteOrderItem doi = (DiscreteOrderItem) orderItem;
if (doi.getBundleOrderItem() != null) {
throw new IllegalArgumentException("Cannot remove an item that is part of a bundle");
}
}
request.setOrderItem(orderItem);
return context;
}
Aggregations