本文整理汇总了Java中org.ofbiz.product.product.ProductWorker.isShippableToAddress方法的典型用法代码示例。如果您正苦于以下问题:Java ProductWorker.isShippableToAddress方法的具体用法?Java ProductWorker.isShippableToAddress怎么用?Java ProductWorker.isShippableToAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ofbiz.product.product.ProductWorker
的用法示例。
在下文中一共展示了ProductWorker.isShippableToAddress方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isShippableToAddress
import org.ofbiz.product.product.ProductWorker; //导入方法依赖的package包/类
private boolean isShippableToAddress(ShoppingCartItem item) {
if ("SALES_ORDER".equals(getOrderTypeId())) {
// Verify if the new address is compatible with the ProductGeos rules of
// the products already in the cart
GenericValue shippingAddress = null;
try {
shippingAddress = item.getDelegator().findOne("PostalAddress", UtilMisc.toMap("contactMechId", this.internalContactMechId), false);
} catch (GenericEntityException gee) {
Debug.logError(gee, "Error retrieving the shipping address for contactMechId [" + this.internalContactMechId + "].", module);
}
if (shippingAddress != null) {
GenericValue product = item.getProduct();
if (UtilValidate.isNotEmpty(product)) {
return ProductWorker.isShippableToAddress(product, shippingAddress);
}
}
}
return true;
}
示例2: setShippingContactMechId
import org.ofbiz.product.product.ProductWorker; //导入方法依赖的package包/类
/** Sets the shipping contact mech id. */
public void setShippingContactMechId(int idx, String shippingContactMechId) {
CartShipInfo csi = this.getShipInfo(idx);
if (isSalesOrder() && UtilValidate.isNotEmpty(shippingContactMechId)) {
// Verify if the new address is compatible with the ProductGeos rules of
// the products already in the cart
GenericValue shippingAddress = null;
try {
shippingAddress = this.getDelegator().findOne("PostalAddress", UtilMisc.toMap("contactMechId", shippingContactMechId), false);
} catch (GenericEntityException gee) {
Debug.logError(gee, "Error retrieving the shipping address for contactMechId [" + shippingContactMechId + "].", module);
}
if (shippingAddress != null) {
Set<ShoppingCartItem> shipItems = csi.getShipItems();
if (UtilValidate.isNotEmpty(shipItems)) {
for (ShoppingCartItem cartItem : shipItems) {
GenericValue product = cartItem.getProduct();
if (UtilValidate.isNotEmpty(product)) {
if (!ProductWorker.isShippableToAddress(product, shippingAddress)) {
throw new IllegalArgumentException("The shipping address is not compatible with ProductGeos rules.");
}
}
}
}
}
}
csi.setContactMechId(shippingContactMechId);
}
示例3: setShippingContactMechId
import org.ofbiz.product.product.ProductWorker; //导入方法依赖的package包/类
/** Sets the shipping contact mech id. */
public void setShippingContactMechId(int idx, String shippingContactMechId) {
CartShipInfo csi = this.getShipInfo(idx);
if (isSalesOrder() && UtilValidate.isNotEmpty(shippingContactMechId)) {
// Verify if the new address is compatible with the ProductGeos rules of
// the products already in the cart
GenericValue shippingAddress = null;
try {
shippingAddress = this.getDelegator().findOne("PostalAddress", UtilMisc.toMap("contactMechId", shippingContactMechId), false);
} catch (GenericEntityException gee) {
Debug.logError(gee, "Error retrieving the shipping address for contactMechId [" + shippingContactMechId + "].", module);
}
if (shippingAddress != null) {
Set<ShoppingCartItem> shipItems = csi.getShipItems();
if (UtilValidate.isNotEmpty(shipItems)) {
for(ShoppingCartItem cartItem : shipItems) {
GenericValue product = cartItem.getProduct();
if (UtilValidate.isNotEmpty(product)) {
if (!ProductWorker.isShippableToAddress(product, shippingAddress)) {
throw new IllegalArgumentException("The shipping address is not compatible with ProductGeos rules.");
}
}
}
}
}
}
csi.setContactMechId(shippingContactMechId);
}