use of org.broadleafcommerce.core.order.domain.BundleOrderItem in project BroadleafCommerce by BroadleafCommerce.
the class FulfillmentGroupServiceImpl method getFulfillmentGroupItemsForOrderItem.
@Override
public List<FulfillmentGroupItem> getFulfillmentGroupItemsForOrderItem(Order order, OrderItem orderItem) {
List<FulfillmentGroupItem> fgis = new ArrayList<FulfillmentGroupItem>();
List<FulfillmentGroup> fulfillmentGroups = order.getFulfillmentGroups();
for (FulfillmentGroup fulfillmentGroup : fulfillmentGroups) {
for (FulfillmentGroupItem fulfillmentGroupItem : fulfillmentGroup.getFulfillmentGroupItems()) {
if (fulfillmentGroupItem.getOrderItem().equals(orderItem)) {
fgis.add(fulfillmentGroupItem);
} else if (orderItem instanceof BundleOrderItem) {
BundleOrderItem bundleOrderItem = (BundleOrderItem) orderItem;
for (DiscreteOrderItem discreteOrderItem : bundleOrderItem.getDiscreteOrderItems()) {
if (fulfillmentGroupItem.getOrderItem().equals(discreteOrderItem)) {
fgis.add(fulfillmentGroupItem);
break;
}
}
}
}
}
return fgis;
}
use of org.broadleafcommerce.core.order.domain.BundleOrderItem in project BroadleafCommerce by BroadleafCommerce.
the class MergeCartServiceImpl method reconstructCart.
@Override
public ReconstructCartResponse reconstructCart(Customer customer, boolean priceOrder) throws PricingException, RemoveFromCartException {
ReconstructCartResponse reconstructCartResponse = new ReconstructCartResponse();
Order customerCart = orderService.findCartForCustomerWithEnhancements(customer);
if (customerCart != null) {
List<OrderItem> itemsToRemove = new ArrayList<OrderItem>();
for (OrderItem orderItem : customerCart.getOrderItems()) {
if (orderItem instanceof DiscreteOrderItem) {
DiscreteOrderItem doi = (DiscreteOrderItem) orderItem;
if (!checkActive(doi) || !checkInventory(doi) || !checkOtherValidity(orderItem)) {
itemsToRemove.add(orderItem);
}
} else if (orderItem instanceof BundleOrderItem) {
BundleOrderItem bundleOrderItem = (BundleOrderItem) orderItem;
for (DiscreteOrderItem doi : bundleOrderItem.getDiscreteOrderItems()) {
if (!checkActive(doi) || !checkInventory(doi) || !checkOtherValidity(orderItem)) {
itemsToRemove.add(doi.getBundleOrderItem());
}
}
}
}
// Remove any giftwrap items who have one or more wrapped item members that have been removed
for (OrderItem orderItem : customerCart.getOrderItems()) {
if (orderItem instanceof GiftWrapOrderItem) {
for (OrderItem wrappedItem : ((GiftWrapOrderItem) orderItem).getWrappedItems()) {
if (itemsToRemove.contains(wrappedItem)) {
itemsToRemove.add(orderItem);
break;
}
}
}
}
for (OrderItem item : itemsToRemove) {
orderService.removeItem(customerCart.getId(), item.getId(), false);
}
reconstructCartResponse.setRemovedItems(itemsToRemove);
customerCart = orderService.save(customerCart, priceOrder);
}
reconstructCartResponse.setOrder(customerCart);
return reconstructCartResponse;
}
use of org.broadleafcommerce.core.order.domain.BundleOrderItem in project BroadleafCommerce by BroadleafCommerce.
the class OrderItemServiceImpl method createBundleOrderItem.
@Override
public BundleOrderItem createBundleOrderItem(final ProductBundleOrderItemRequest itemRequest, boolean saveItem) {
ProductBundle productBundle = itemRequest.getProductBundle();
BundleOrderItem bundleOrderItem = (BundleOrderItem) orderItemDao.create(OrderItemType.BUNDLE);
bundleOrderItem.setQuantity(itemRequest.getQuantity());
bundleOrderItem.setCategory(itemRequest.getCategory());
bundleOrderItem.setSku(itemRequest.getSku());
bundleOrderItem.setName(itemRequest.getName());
bundleOrderItem.setProductBundle(productBundle);
bundleOrderItem.setOrder(itemRequest.getOrder());
if (itemRequest.getSalePriceOverride() != null) {
bundleOrderItem.setSalePriceOverride(Boolean.TRUE);
bundleOrderItem.setSalePrice(itemRequest.getSalePriceOverride());
bundleOrderItem.setBaseSalePrice(itemRequest.getSalePriceOverride());
}
if (itemRequest.getRetailPriceOverride() != null) {
bundleOrderItem.setRetailPriceOverride(Boolean.TRUE);
bundleOrderItem.setRetailPrice(itemRequest.getRetailPriceOverride());
bundleOrderItem.setBaseRetailPrice(itemRequest.getRetailPriceOverride());
}
for (SkuBundleItem skuBundleItem : productBundle.getSkuBundleItems()) {
Product bundleProduct = skuBundleItem.getBundle();
Sku bundleSku = skuBundleItem.getSku();
Category bundleCategory = null;
if (itemRequest.getCategory() != null) {
bundleCategory = itemRequest.getCategory();
}
if (bundleCategory == null && bundleProduct != null) {
bundleCategory = bundleProduct.getDefaultCategory();
}
DiscreteOrderItemRequest bundleItemRequest = new DiscreteOrderItemRequest();
bundleItemRequest.setCategory(bundleCategory);
bundleItemRequest.setProduct(bundleProduct);
bundleItemRequest.setQuantity(skuBundleItem.getQuantity());
bundleItemRequest.setSku(bundleSku);
bundleItemRequest.setItemAttributes(itemRequest.getItemAttributes());
bundleItemRequest.setSalePriceOverride(skuBundleItem.getSalePrice());
bundleItemRequest.setBundleOrderItem(bundleOrderItem);
DiscreteOrderItem bundleDiscreteItem = createDiscreteOrderItem(bundleItemRequest);
bundleDiscreteItem.setSkuBundleItem(skuBundleItem);
bundleOrderItem.getDiscreteOrderItems().add(bundleDiscreteItem);
}
if (saveItem) {
bundleOrderItem = (BundleOrderItem) saveOrderItem(bundleOrderItem);
}
applyAdditionalOrderItemProperties(bundleOrderItem);
return bundleOrderItem;
}
use of org.broadleafcommerce.core.order.domain.BundleOrderItem in project BroadleafCommerce by BroadleafCommerce.
the class OrderItemServiceImpl method createBundleOrderItem.
@Override
public BundleOrderItem createBundleOrderItem(final BundleOrderItemRequest itemRequest) {
final BundleOrderItem item = (BundleOrderItem) orderItemDao.create(OrderItemType.BUNDLE);
item.setQuantity(itemRequest.getQuantity());
item.setCategory(itemRequest.getCategory());
item.setName(itemRequest.getName());
item.setBundleOrderItemFeePrices(itemRequest.getBundleOrderItemFeePrices());
item.setOrder(itemRequest.getOrder());
if (itemRequest.getSalePriceOverride() != null) {
item.setSalePriceOverride(Boolean.TRUE);
item.setSalePrice(itemRequest.getSalePriceOverride());
item.setBaseSalePrice(itemRequest.getSalePriceOverride());
}
if (itemRequest.getRetailPriceOverride() != null) {
item.setRetailPriceOverride(Boolean.TRUE);
item.setRetailPrice(itemRequest.getRetailPriceOverride());
item.setBaseRetailPrice(itemRequest.getRetailPriceOverride());
}
for (DiscreteOrderItemRequest discreteItemRequest : itemRequest.getDiscreteOrderItems()) {
discreteItemRequest.setBundleOrderItem(item);
DiscreteOrderItem discreteOrderItem;
if (discreteItemRequest instanceof GiftWrapOrderItemRequest) {
discreteOrderItem = createGiftWrapOrderItem((GiftWrapOrderItemRequest) discreteItemRequest);
} else {
discreteOrderItem = createDiscreteOrderItem(discreteItemRequest);
}
item.getDiscreteOrderItems().add(discreteOrderItem);
}
applyAdditionalOrderItemProperties(item);
return item;
}
use of org.broadleafcommerce.core.order.domain.BundleOrderItem in project BroadleafCommerce by BroadleafCommerce.
the class OrderItemServiceImpl method updateDiscreteOrderItem.
@Override
public OrderItem updateDiscreteOrderItem(OrderItem item, final DiscreteOrderItemRequest itemRequest) {
List<ProductOption> productOptions = null;
if (item instanceof DiscreteOrderItem) {
productOptions = ((DiscreteOrderItem) item).getProduct().getProductOptions();
} else if (item instanceof BundleOrderItem) {
productOptions = ((BundleOrderItem) item).getProduct().getProductOptions();
}
List<String> removeKeys = new ArrayList<String>();
if (productOptions != null && itemRequest.getItemAttributes() != null) {
for (String name : itemRequest.getItemAttributes().keySet()) {
// if option.getProductOptionValidationType() is null then it might change the sku, so we dont allow those
for (ProductOption option : productOptions) {
if (option.getAttributeName().equals(name) && option.getProductOptionValidationStrategyType() == null) {
removeKeys.add(name);
break;
}
}
}
}
for (String name : removeKeys) {
itemRequest.getItemAttributes().remove(name);
}
populateProductOptionAttributes(item, itemRequest.getItemAttributes());
applyAdditionalOrderItemProperties(item);
return item;
}
Aggregations