Add reading of promo use and promo code from the database into the

shopping cart.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@941109 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Adam Heath
2010-05-04 23:44:35 +00:00
parent 667a49572e
commit ca984e8550
2 changed files with 32 additions and 0 deletions
@@ -2198,6 +2198,29 @@ public class OrderReadHelper {
return EntityUtil.filterByCondition(getOrderItems(), entityCondition);
}
public Set<String> getProductPromoCodesEntered() {
Delegator delegator = orderHeader.getDelegator();
Set<String> productPromoCodesEntered = FastSet.newInstance();
try {
for (GenericValue orderProductPromoCode: delegator.findByAndCache("OrderProductPromoCode", UtilMisc.toMap("orderId", orderHeader.get("orderId")))) {
productPromoCodesEntered.add(orderProductPromoCode.getString("productPromoCodeId"));
}
} catch (GenericEntityException e) {
Debug.logError(e, module);
}
return productPromoCodesEntered;
}
public List<GenericValue> getProductPromoUse() {
Delegator delegator = orderHeader.getDelegator();
try {
return delegator.findByAndCache("ProductPromoUse", UtilMisc.toMap("orderId", orderHeader.get("orderId")));
} catch (GenericEntityException e) {
Debug.logError(e, module);
}
return FastList.newInstance();
}
/**
* Checks to see if this user has read permission on this order
* @param userLogin The UserLogin value object to check
@@ -581,6 +581,15 @@ public class ShoppingCartServices {
}
}
if (includePromoItems) {
for (String productPromoCode: orh.getProductPromoCodesEntered()) {
cart.addProductPromoCode(productPromoCode, dispatcher);
}
for (GenericValue productPromoUse: orh.getProductPromoUse()) {
cart.addProductPromoUse(productPromoUse.getString("productPromoId"), productPromoUse.getString("productPromoCodeId"), productPromoUse.getBigDecimal("totalDiscountAmount"), productPromoUse.getBigDecimal("quantityLeftInActions"));
}
}
List adjustments = orh.getOrderHeaderAdjustments();
// If applyQuoteAdjustments is set to false then standard cart adjustments are used.
if (!adjustments.isEmpty()) {