Search in sources :

Example 1 with RebatesOrderTotalVariation

use of com.salesmanager.core.model.order.RebatesOrderTotalVariation in project shopizer by shopizer-ecommerce.

the class OrderTotalServiceImpl method findOrderTotalVariation.

@Override
public OrderTotalVariation findOrderTotalVariation(OrderSummary summary, Customer customer, MerchantStore store, Language language) throws Exception {
    RebatesOrderTotalVariation variation = new RebatesOrderTotalVariation();
    List<OrderTotal> totals = null;
    if (orderTotalPostProcessors != null) {
        for (OrderTotalPostProcessorModule module : orderTotalPostProcessors) {
            // TODO check if the module is enabled from the Admin
            List<ShoppingCartItem> items = summary.getProducts();
            for (ShoppingCartItem item : items) {
                Long productId = item.getProductId();
                Product product = productService.getProductForLocale(productId, language, languageService.toLocale(language, store));
                OrderTotal orderTotal = module.caculateProductPiceVariation(summary, item, product, customer, store);
                if (orderTotal == null) {
                    continue;
                }
                if (totals == null) {
                    totals = new ArrayList<OrderTotal>();
                    variation.setVariations(totals);
                }
                // if product is null it will be catched when invoking the module
                orderTotal.setText(StringUtils.isNoneBlank(orderTotal.getText()) ? orderTotal.getText() : product.getProductDescription().getName());
                variation.getVariations().add(orderTotal);
            }
        }
    }
    return variation;
}
Also used : OrderTotalPostProcessorModule(com.salesmanager.core.modules.order.total.OrderTotalPostProcessorModule) Product(com.salesmanager.core.model.catalog.product.Product) ShoppingCartItem(com.salesmanager.core.model.shoppingcart.ShoppingCartItem) OrderTotal(com.salesmanager.core.model.order.OrderTotal) RebatesOrderTotalVariation(com.salesmanager.core.model.order.RebatesOrderTotalVariation)

Aggregations

Product (com.salesmanager.core.model.catalog.product.Product)1 OrderTotal (com.salesmanager.core.model.order.OrderTotal)1 RebatesOrderTotalVariation (com.salesmanager.core.model.order.RebatesOrderTotalVariation)1 ShoppingCartItem (com.salesmanager.core.model.shoppingcart.ShoppingCartItem)1 OrderTotalPostProcessorModule (com.salesmanager.core.modules.order.total.OrderTotalPostProcessorModule)1