}
return orderHeader;
}
public void mergeOrder(Long orderHeaderId, ContentBean contentBean) throws SecurityException, Exception {
OrderHeader orderHeader = OrderHeaderDAO.load(siteDomain.getSite().getSiteId(), orderHeaderId);
if (orderHeader.getShippingValidUntil() != null) {
this.shippingQuoteLock = true;
this.shippingOrderTotal = orderHeader.getShippingTotal();
this.getShoppingCartItems().clear();
this.getShoppingCartCoupons().clear();
}
for (OrderItemDetail orderItemDetail : orderHeader.getOrderItemDetails()) {
Item item = orderItemDetail.getItem();
// Do not merge order when using external data
if (item == null) {
continue;
}
Vector<ItemAttributeInfo> itemAttributeInfos = new Vector<ItemAttributeInfo>();
for (OrderAttributeDetail orderAttributeDetail : orderItemDetail.getOrderAttributeDetails()) {
ItemAttributeInfo itemAttributeInfo = new ItemAttributeInfo();
itemAttributeInfo.setCustomAttribTypeCode(String.valueOf(orderAttributeDetail.getCustomAttributeDetail().getCustomAttribute().getCustomAttribTypeCode()));
if (orderAttributeDetail.getCustomAttributeDetail() != null) {
if (orderAttributeDetail.getCustomAttributeOption() != null) {
itemAttributeInfo.setCustomAttribOptionId(orderAttributeDetail.getCustomAttributeOption().getCustomAttribOptionId());
}
for (ItemAttributeDetail itemAttributeDetail : item.getItemAttributeDetails()) {
if (itemAttributeDetail.getCustomAttributeDetail().getCustomAttribDetailId().equals(orderAttributeDetail.getCustomAttributeDetail().getCustomAttribDetailId())) {
itemAttributeInfo.setItemAttribDetailId(itemAttributeDetail.getItemAttribDetailId());
itemAttributeInfo.setItemAttribDetailValue(orderAttributeDetail.getOrderAttribValue());
break;
}
}
}
itemAttributeInfos.add(itemAttributeInfo);
}
if (item.getItemTypeCd().equals(Constants.ITEM_TYPE_SKU)) {
for (ItemAttributeDetail itemAttributeDetail : item.getItemAttributeDetails()) {
CustomAttribute customAttribute = itemAttributeDetail.getCustomAttributeDetail().getCustomAttribute();
if (customAttribute.getCustomAttribTypeCode() != Constants.CUSTOM_ATTRIBUTE_TYPE_SKU_MAKEUP) {
continue;
}
ItemAttributeInfo itemAttributeInfo = new ItemAttributeInfo();
itemAttributeInfo.setCustomAttribTypeCode(String.valueOf(customAttribute.getCustomAttribTypeCode()));
itemAttributeInfo.setCustomAttribOptionId(itemAttributeDetail.getCustomAttributeOption().getCustomAttribOptionId());
itemAttributeInfo.setItemAttribDetailId(itemAttributeDetail.getItemAttribDetailId());
itemAttributeInfos.add(itemAttributeInfo);
}
}
if (!isExist(orderItemDetail.getItem())) {
this.setItemQty(orderItemDetail.getItem(), orderItemDetail.getItemOrderQty(), itemAttributeInfos, contentBean, false);
}
}
this.orderNum = orderHeader.getOrderNum();
if (!cashPaymentOrder && paymentEngine == null) {
if (orderHeader.getPaymentGatewayProvider() == null) {
cashPayment = true;
}
else {
this.paymentEngine = PaymentManager.getPaymentEngine(orderHeader.getPaymentGatewayProvider(), orderHeader.getSiteCurrency());
}
}
}