Search in sources :

Example 6 with ShoppingCartDataPopulator

use of com.salesmanager.shop.populator.shoppingCart.ShoppingCartDataPopulator in project shopizer by shopizer-ecommerce.

the class ShoppingCartFacadeImpl method getShoppingCartData.

@Override
public ShoppingCartData getShoppingCartData(final Customer customer, final MerchantStore store, final String shoppingCartId, Language language) throws Exception {
    ShoppingCart cart = null;
    try {
        if (customer != null) {
            LOG.info("Reteriving customer shopping cart...");
            cart = shoppingCartService.getShoppingCart(customer);
        } else {
            if (StringUtils.isNotBlank(shoppingCartId) && cart == null) {
                cart = shoppingCartService.getByCode(shoppingCartId, store);
            }
        }
    } catch (ServiceException ex) {
        LOG.error("Error while retriving cart from customer", ex);
    } catch (NoResultException nre) {
    // nothing
    }
    if (cart == null) {
        return null;
    }
    // if cart has been completed return null
    if (cart.getOrderId() != null && cart.getOrderId().longValue() > 0) {
        if (StringUtils.isNotBlank(shoppingCartId) && !(shoppingCartId.equals(cart.getShoppingCartCode()))) {
            cart = shoppingCartService.getByCode(shoppingCartId, store);
        } else {
            return null;
        }
    }
    LOG.info("Cart model found.");
    ShoppingCartDataPopulator shoppingCartDataPopulator = new ShoppingCartDataPopulator();
    shoppingCartDataPopulator.setShoppingCartCalculationService(shoppingCartCalculationService);
    shoppingCartDataPopulator.setPricingService(pricingService);
    shoppingCartDataPopulator.setimageUtils(imageUtils);
    // Language language = (Language) getKeyValue( Constants.LANGUAGE );
    MerchantStore merchantStore = (MerchantStore) getKeyValue(Constants.MERCHANT_STORE);
    ShoppingCartData shoppingCartData = shoppingCartDataPopulator.populate(cart, merchantStore, language);
    return shoppingCartData;
}
Also used : ShoppingCart(com.salesmanager.core.model.shoppingcart.ShoppingCart) ReadableShoppingCart(com.salesmanager.shop.model.shoppingcart.ReadableShoppingCart) ServiceException(com.salesmanager.core.business.exception.ServiceException) ShoppingCartDataPopulator(com.salesmanager.shop.populator.shoppingCart.ShoppingCartDataPopulator) NoResultException(javax.persistence.NoResultException) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) ShoppingCartData(com.salesmanager.shop.model.shoppingcart.ShoppingCartData)

Example 7 with ShoppingCartDataPopulator

use of com.salesmanager.shop.populator.shoppingCart.ShoppingCartDataPopulator in project shopizer by shopizer-ecommerce.

the class CustomerRegistrationController method populateShoppingCartData.

private ShoppingCartData populateShoppingCartData(final ShoppingCart cartModel, final MerchantStore store, final Language language) {
    ShoppingCartDataPopulator shoppingCartDataPopulator = new ShoppingCartDataPopulator();
    shoppingCartDataPopulator.setShoppingCartCalculationService(shoppingCartCalculationService);
    shoppingCartDataPopulator.setPricingService(pricingService);
    try {
        return shoppingCartDataPopulator.populate(cartModel, store, language);
    } catch (ConversionException ce) {
        LOGGER.error("Error in converting shopping cart to shopping cart data", ce);
    }
    return null;
}
Also used : ConversionException(com.salesmanager.core.business.exception.ConversionException) ShoppingCartDataPopulator(com.salesmanager.shop.populator.shoppingCart.ShoppingCartDataPopulator)

Example 8 with ShoppingCartDataPopulator

use of com.salesmanager.shop.populator.shoppingCart.ShoppingCartDataPopulator in project shopizer by shopizer-ecommerce.

the class CustomerLoginController method populateShoppingCartData.

private ShoppingCartData populateShoppingCartData(final ShoppingCart cartModel, final MerchantStore store, final Language language) {
    ShoppingCartDataPopulator shoppingCartDataPopulator = new ShoppingCartDataPopulator();
    shoppingCartDataPopulator.setShoppingCartCalculationService(shoppingCartCalculationService);
    shoppingCartDataPopulator.setPricingService(pricingService);
    try {
        return shoppingCartDataPopulator.populate(cartModel, store, language);
    } catch (ConversionException ce) {
        LOG.error("Error in converting shopping cart to shopping cart data", ce);
    }
    return null;
}
Also used : ConversionException(com.salesmanager.core.business.exception.ConversionException) ShoppingCartDataPopulator(com.salesmanager.shop.populator.shoppingCart.ShoppingCartDataPopulator)

Aggregations

ShoppingCartDataPopulator (com.salesmanager.shop.populator.shoppingCart.ShoppingCartDataPopulator)8 ShoppingCart (com.salesmanager.core.model.shoppingcart.ShoppingCart)5 ReadableShoppingCart (com.salesmanager.shop.model.shoppingcart.ReadableShoppingCart)5 PersistableShoppingCartItem (com.salesmanager.shop.model.shoppingcart.PersistableShoppingCartItem)3 ShoppingCartItem (com.salesmanager.shop.model.shoppingcart.ShoppingCartItem)3 ConversionException (com.salesmanager.core.business.exception.ConversionException)2 ProductAttribute (com.salesmanager.core.model.catalog.product.attribute.ProductAttribute)2 FinalPrice (com.salesmanager.core.model.catalog.product.price.FinalPrice)2 MerchantStore (com.salesmanager.core.model.merchant.MerchantStore)2 CartModificationException (com.salesmanager.shop.model.shoppingcart.CartModificationException)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 ServiceException (com.salesmanager.core.business.exception.ServiceException)1 ShoppingCartData (com.salesmanager.shop.model.shoppingcart.ShoppingCartData)1 LocalDate (java.time.LocalDate)1 Date (java.util.Date)1 NoResultException (javax.persistence.NoResultException)1