本文整理汇总了Java中org.ofbiz.order.shoppingcart.product.ProductPromoWorker.checkCanUsePromoCode方法的典型用法代码示例。如果您正苦于以下问题:Java ProductPromoWorker.checkCanUsePromoCode方法的具体用法?Java ProductPromoWorker.checkCanUsePromoCode怎么用?Java ProductPromoWorker.checkCanUsePromoCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ofbiz.order.shoppingcart.product.ProductPromoWorker
的用法示例。
在下文中一共展示了ProductPromoWorker.checkCanUsePromoCode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleNewUser
import org.ofbiz.order.shoppingcart.product.ProductPromoWorker; //导入方法依赖的package包/类
public void handleNewUser(LocalDispatcher dispatcher) throws CartItemModifyException {
String partyId = this.getPartyId();
if (UtilValidate.isNotEmpty(partyId)) {
// recalculate all prices
for (ShoppingCartItem cartItem : this) {
cartItem.updatePrice(dispatcher, this);
}
// check all promo codes, remove on failed check
Iterator<String> promoCodeIter = this.productPromoCodes.iterator();
while (promoCodeIter.hasNext()) {
String promoCode = promoCodeIter.next();
String checkResult = ProductPromoWorker.checkCanUsePromoCode(promoCode, partyId, this.getDelegator(), locale);
if (checkResult != null) {
promoCodeIter.remove();
Debug.logWarning(UtilProperties.getMessage(resource_error,"OrderOnUserChangePromoCodeWasRemovedBecause", UtilMisc.toMap("checkResult",checkResult), locale), module);
}
}
// rerun promotions
ProductPromoWorker.doPromotions(this, dispatcher);
}
}
示例2: addProductPromoCode
import org.ofbiz.order.shoppingcart.product.ProductPromoWorker; //导入方法依赖的package包/类
/** Adds a promotion code to the cart, checking if it is valid. If it is valid this will return null, otherwise it will return a message stating why it was not valid
* @param productPromoCodeId The promotion code to check and add
* @return String that is null if valid, and added to cart, or an error message of the code was not valid and not added to the cart.
*/
public String addProductPromoCode(String productPromoCodeId, LocalDispatcher dispatcher) {
if (this.productPromoCodes.contains(productPromoCodeId)) {
return UtilProperties.getMessage(resource_error, "productpromoworker.promotion_code_already_been_entered", UtilMisc.toMap("productPromoCodeId", productPromoCodeId), locale);
}
if (!this.getDoPromotions()) {
this.productPromoCodes.add(productPromoCodeId);
return null;
}
// if the promo code requires it make sure the code is valid
String checkResult = ProductPromoWorker.checkCanUsePromoCode(productPromoCodeId, this.getPartyId(), this.getDelegator(), this, locale);
if (checkResult == null) {
this.productPromoCodes.add(productPromoCodeId);
// new promo code, re-evaluate promos
ProductPromoWorker.doPromotions(this, dispatcher);
return null;
} else {
return checkResult;
}
}
示例3: handleNewUser
import org.ofbiz.order.shoppingcart.product.ProductPromoWorker; //导入方法依赖的package包/类
public void handleNewUser(LocalDispatcher dispatcher) throws CartItemModifyException {
String partyId = this.getPartyId();
if (UtilValidate.isNotEmpty(partyId)) {
// recalculate all prices
for(ShoppingCartItem cartItem : this) {
cartItem.updatePrice(dispatcher, this);
}
// check all promo codes, remove on failed check
Iterator<String> promoCodeIter = this.productPromoCodes.iterator();
while (promoCodeIter.hasNext()) {
String promoCode = promoCodeIter.next();
String checkResult = ProductPromoWorker.checkCanUsePromoCode(promoCode, partyId, this.getDelegator(), locale);
if (checkResult != null) {
promoCodeIter.remove();
Debug.logWarning(UtilProperties.getMessage(resource_error,"OrderOnUserChangePromoCodeWasRemovedBecause", UtilMisc.toMap("checkResult",checkResult), locale), module);
}
}
// rerun promotions
ProductPromoWorker.doPromotions(this, dispatcher);
}
}