use of com.salesmanager.core.model.shipping.ShippingProduct in project shopizer by shopizer-ecommerce.
the class PackingBox method getItemPackagesDetails.
@Override
public List<PackageDetails> getItemPackagesDetails(List<ShippingProduct> products, MerchantStore store) throws ServiceException {
List<PackageDetails> packages = new ArrayList<PackageDetails>();
for (ShippingProduct shippingProduct : products) {
Product product = shippingProduct.getProduct();
if (product.isProductVirtual()) {
continue;
}
// BigDecimal weight = product.getProductWeight();
Set<ProductAttribute> attributes = product.getAttributes();
// set attributes values
BigDecimal w = product.getProductWeight();
BigDecimal h = product.getProductHeight();
BigDecimal l = product.getProductLength();
BigDecimal wd = product.getProductWidth();
if (w == null) {
w = new BigDecimal(defaultWeight);
}
if (h == null) {
h = new BigDecimal(defaultHeight);
}
if (l == null) {
l = new BigDecimal(defaultLength);
}
if (wd == null) {
wd = new BigDecimal(defaultWidth);
}
if (attributes != null && attributes.size() > 0) {
for (ProductAttribute attribute : attributes) {
if (attribute.getAttributeAdditionalWeight() != null && attribute.getProductAttributeWeight() != null) {
w = w.add(attribute.getProductAttributeWeight());
}
}
}
if (shippingProduct.getQuantity() == 1) {
PackageDetails detail = new PackageDetails();
detail.setShippingHeight(h.doubleValue());
detail.setShippingLength(l.doubleValue());
detail.setShippingWeight(w.doubleValue());
detail.setShippingWidth(wd.doubleValue());
detail.setShippingQuantity(shippingProduct.getQuantity());
String description = "item";
if (product.getDescriptions().size() > 0) {
description = product.getDescriptions().iterator().next().getName();
}
detail.setItemName(description);
packages.add(detail);
} else if (shippingProduct.getQuantity() > 1) {
for (int i = 0; i < shippingProduct.getQuantity(); i++) {
PackageDetails detail = new PackageDetails();
detail.setShippingHeight(h.doubleValue());
detail.setShippingLength(l.doubleValue());
detail.setShippingWeight(w.doubleValue());
detail.setShippingWidth(wd.doubleValue());
// issue seperate shipping
detail.setShippingQuantity(1);
String description = "item";
if (product.getDescriptions().size() > 0) {
description = product.getDescriptions().iterator().next().getName();
}
detail.setItemName(description);
packages.add(detail);
}
}
}
return packages;
}
use of com.salesmanager.core.model.shipping.ShippingProduct in project shopizer by shopizer-ecommerce.
the class OrderFacadeImpl method getShippingQuote.
@Override
public ShippingQuote getShippingQuote(Customer customer, ShoppingCart cart, com.salesmanager.shop.model.order.v0.PersistableOrder order, MerchantStore store, Language language) throws Exception {
// create shipping products
List<ShippingProduct> shippingProducts = shoppingCartService.createShippingProduct(cart);
if (CollectionUtils.isEmpty(shippingProducts)) {
// products are virtual
return null;
}
Delivery delivery = new Delivery();
// adjust shipping and billing
if (order.isShipToBillingAdress()) {
Billing billing = customer.getBilling();
delivery.setAddress(billing.getAddress());
delivery.setCity(billing.getCity());
delivery.setCompany(billing.getCompany());
delivery.setPostalCode(billing.getPostalCode());
delivery.setState(billing.getState());
delivery.setCountry(billing.getCountry());
delivery.setZone(billing.getZone());
} else {
delivery = customer.getDelivery();
}
ShippingQuote quote = shippingService.getShippingQuote(cart.getId(), store, delivery, shippingProducts, language);
return quote;
}
use of com.salesmanager.core.model.shipping.ShippingProduct in project shopizer by shopizer-ecommerce.
the class ShoppingCartServiceImpl method createShippingProduct.
@Override
public List<ShippingProduct> createShippingProduct(final ShoppingCart cart) throws ServiceException {
/**
* Determines if products are virtual
*/
Set<ShoppingCartItem> items = cart.getLineItems();
List<ShippingProduct> shippingProducts = null;
for (ShoppingCartItem item : items) {
Product product = item.getProduct();
if (!product.isProductVirtual() && product.isProductShipeable()) {
if (shippingProducts == null) {
shippingProducts = new ArrayList<ShippingProduct>();
}
ShippingProduct shippingProduct = new ShippingProduct(product);
shippingProduct.setQuantity(item.getQuantity());
shippingProduct.setFinalPrice(item.getFinalPrice());
shippingProducts.add(shippingProduct);
}
}
return shippingProducts;
}
Aggregations