WCS OOB cannot evaluate order level promotions, without adding them to cart. This can be achieved using a workaround.
For catentry level promotions, OOB PromotionalPriceDataBean can be used.
The below are the 2 objects that the promotion engine acts upon.
The below are the 2 objects that the promotion engine acts upon.
- com.ibm.commerce.marketing.promotion.integration.dependency.WCSOrder
- com.ibm.commerce.marketing.promotion.integration.dependency.WCSOrderItem
WCSOrder order = null;
WCSOrderItem orderItem = null;
List orderItemList = null;
//Populate the OrderItemId, store, catentry information to the WCSOrderItem Object
orderItem.setKey(new OrderItemKey(new Long("1"));
orderItem.setStore(sKey);
orderItem.setCatalogEntry(catKey);
orderItem.setBaseCurrency(getCommandContext().getCurrency());
orderItem.setCurrency(getCommandContext().getCurrency());
orderItem.setStandardPrice(100);
orderItem.setPrice(itemPrice);
orderItem.setQuantity(new BigDecimal(1));
orderItem.setShippingCharge(new BigDecimal(10));
orderItem.setShippingCarrier("UPS");
orderItem.setShippingCode("Ground");
orderItemList.add(orderItem);
// Populate the WCSOrder Object with order related data
order.setKey(new OrderKey(new Long(this.ucOrderDataBean.getWCSorderId())));
order.setStoreId(this.storeId);
order.setCurrency(getCommandContext().getCurrency());
order.setOwner(getCommandContext().getUserId());
order.setLastUpdate(getCommandContext().getTimestamp());
order.setTotal(new BigDecimal(110);
order.setTotalShippingCharge(new BigDecimal(10));
// Populate the order Items information to the wcsOrder
OrderItem[] orderItems = new WCSOrderItem[this.orderItemList.size()];
orderItems = (WCSOrderItem[])this.orderItemList.toArray(orderItems);
order.setItems(orderItems);
DefaultAdvancedPromotionEngine defaultPromotionEngine = null;
//Get the default promotion engine
PromotionEngine promotionEngine = PromotionEngineHome.getDefaultEngine();
if(promotionEngine instanceof DefaultAdvancedPromotionEngine){
defaultPromotionEngine = (DefaultAdvancedPromotionEngine)promotionEngine;
}
PromotionContext promotionContext = defaultPromotionEngine.createPromotionContext(this.order, getCommandContext(), "All Promotions", null, false);
promotionContext.getAgenda().setShippingChargePresent(true);
//Invoke the promotion context to apply the promotions to the order
defaultPromotionEngine.invoke(promotionContext);
//Get the promotion Arugement, which has the applied promotion details
this.promotionArgument = promotionContext.getArgument();
// Iterate over the list of promotion execution records returned by the promotion engine
Iterator aIterator = promoResult.getPromotionExecutionRecords();
while (aIterator.hasNext()) {
PromotionExecutionRecord aPromotionExecutionRecord = (PromotionExecutionRecord)aIterator.next();
if (16 == aPromotionExecutionRecord.getState()) {
BigDecimal currentDiscount = aPromotionExecutionRecord.getMonetaryAdjustmentForOrder(1);
LineItemSet[] lineItemSets = aPromotionExecutionRecord.getAffectedItems();
for(int i=0; i<lineItemSets.length; i++) {
LineItemSet lineItemSet = lineItemSets[i];
AssociatedOrderItem[] associatedOrderItems = lineItemSet.getAssociatedOrderItems();
for(int j=0; j<associatedOrderItems.length; j++) {
//AssociatedOrderItem has the list of all order items and the promotions against them
AssociatedOrderItem associatedOrderItem = associatedOrderItems[j];
}
}
}
}
Such an excellent blog.I learned a lot information here,share more updates.
ReplyDeleteAir Hostess Training Institute in chennai
Air hostess Training Institute in Bangalore
Air hostess Training Fees in Mumbai
Air Hostess Training in Chennai
Aviation courses in Bangalore
Air Hostess Training in Chennai
Air Hostess Training Institute in chennai
Aviation Courses in Chennai
Aviation Institute in Bangalore
Air Hostess Course in Chennai
This blog remains the best among all the blogs I have read still now; Great style of writing and way of content delivery. Kindly do share more updates.
ReplyDeleteSpoken English Classes in Chennai
Best Spoken English Classes in Chennai
IELTS Coaching in Chennai
IELTS Coaching Centre in Chennai
English Speaking Classes in Mumbai
English Speaking Course in Mumbai
IELTS Classes in Mumbai
IELTS Coaching in Mumbai
IELTS Coaching in Anna Nagar
Spoken English Class in Anna Nagar