use of com.salesmanager.core.model.reference.zone.Zone in project shopizer by shopizer-ecommerce.
the class ShoppingOrderController method displayCheckout.
@SuppressWarnings("unused")
@RequestMapping("/checkout.html")
public String displayCheckout(@CookieValue("cart") String cookie, Model model, HttpServletRequest request, HttpServletResponse response, Locale locale) throws Exception {
Language language = (Language) request.getAttribute("LANGUAGE");
MerchantStore store = (MerchantStore) request.getAttribute(Constants.MERCHANT_STORE);
Customer customer = (Customer) request.getSession().getAttribute(Constants.CUSTOMER);
model.addAttribute("googleMapsKey", googleMapsKey);
/**
* Shopping cart
*
* ShoppingCart should be in the HttpSession
* Otherwise the cart id is in the cookie
* Otherwise the customer is in the session and a cart exist in the DB
* Else -> Nothing to display
*/
// check if an existing order exist
ShopOrder order = null;
order = super.getSessionAttribute(Constants.ORDER, request);
// Get the cart from the DB
String shoppingCartCode = (String) request.getSession().getAttribute(Constants.SHOPPING_CART);
com.salesmanager.core.model.shoppingcart.ShoppingCart cart = null;
if (StringUtils.isBlank(shoppingCartCode)) {
if (cookie == null) {
// session expired and cookie null, nothing to do
return "redirect:/shop/cart/shoppingCart.html";
}
String[] merchantCookie = cookie.split("_");
String merchantStoreCode = merchantCookie[0];
if (!merchantStoreCode.equals(store.getCode())) {
return "redirect:/shop/cart/shoppingCart.html";
}
shoppingCartCode = merchantCookie[1];
}
cart = shoppingCartFacade.getShoppingCartModel(shoppingCartCode, store);
if (cart == null && customer != null) {
cart = shoppingCartFacade.getShoppingCartModel(customer, store);
}
boolean allAvailables = true;
boolean requiresShipping = false;
boolean freeShoppingCart = true;
// Filter items, delete unavailable
Set<com.salesmanager.core.model.shoppingcart.ShoppingCartItem> availables = new HashSet<ShoppingCartItem>();
if (cart == null) {
return "redirect:/shop/cart/shoppingCart.html";
}
// Take out items no more available
Set<com.salesmanager.core.model.shoppingcart.ShoppingCartItem> items = cart.getLineItems();
for (com.salesmanager.core.model.shoppingcart.ShoppingCartItem item : items) {
Long id = item.getProduct().getId();
Product p = productService.getById(id);
if (p.isAvailable()) {
availables.add(item);
} else {
allAvailables = false;
}
FinalPrice finalPrice = pricingService.calculateProductPrice(p);
if (finalPrice.getFinalPrice().longValue() > 0) {
freeShoppingCart = false;
}
if (p.isProductShipeable()) {
requiresShipping = true;
}
}
cart.setLineItems(availables);
if (!allAvailables) {
shoppingCartFacade.saveOrUpdateShoppingCart(cart);
}
super.setSessionAttribute(Constants.SHOPPING_CART, cart.getShoppingCartCode(), request);
if (shoppingCartCode == null && cart == null) {
// error
return "redirect:/shop/cart/shoppingCart.html";
}
if (customer != null) {
if (cart.getCustomerId() != customer.getId().longValue()) {
return "redirect:/shop/shoppingCart.html";
}
} else {
customer = orderFacade.initEmptyCustomer(store);
AnonymousCustomer anonymousCustomer = (AnonymousCustomer) request.getAttribute(Constants.ANONYMOUS_CUSTOMER);
if (anonymousCustomer != null && anonymousCustomer.getBilling() != null) {
Billing billing = customer.getBilling();
billing.setCity(anonymousCustomer.getBilling().getCity());
Map<String, Country> countriesMap = countryService.getCountriesMap(language);
Country anonymousCountry = countriesMap.get(anonymousCustomer.getBilling().getCountry());
if (anonymousCountry != null) {
billing.setCountry(anonymousCountry);
}
Map<String, Zone> zonesMap = zoneService.getZones(language);
Zone anonymousZone = zonesMap.get(anonymousCustomer.getBilling().getZone());
if (anonymousZone != null) {
billing.setZone(anonymousZone);
}
if (anonymousCustomer.getBilling().getPostalCode() != null) {
billing.setPostalCode(anonymousCustomer.getBilling().getPostalCode());
}
customer.setBilling(billing);
}
}
if (CollectionUtils.isEmpty(items)) {
return "redirect:/shop/shoppingCart.html";
}
if (order == null) {
// TODO
order = orderFacade.initializeOrder(store, customer, cart, language);
}
/**
* hook for displaying or not delivery address configuration
*/
ShippingMetaData shippingMetaData = shippingService.getShippingMetaData(store);
model.addAttribute("shippingMetaData", shippingMetaData);
/**
* shipping *
*/
ShippingQuote quote = null;
if (requiresShipping) {
// System.out.println("** Berfore default shipping quote **");
// Get all applicable shipping quotes
quote = orderFacade.getShippingQuote(customer, cart, order, store, language);
model.addAttribute("shippingQuote", quote);
}
if (quote != null) {
String shippingReturnCode = quote.getShippingReturnCode();
if (StringUtils.isBlank(shippingReturnCode) || shippingReturnCode.equals(ShippingQuote.NO_POSTAL_CODE)) {
if (order.getShippingSummary() == null) {
ShippingSummary summary = orderFacade.getShippingSummary(quote, store, language);
order.setShippingSummary(summary);
// TODO DTO
request.getSession().setAttribute(Constants.SHIPPING_SUMMARY, summary);
}
if (order.getSelectedShippingOption() == null) {
order.setSelectedShippingOption(quote.getSelectedShippingOption());
}
// save quotes in HttpSession
List<ShippingOption> options = quote.getShippingOptions();
// TODO DTO
request.getSession().setAttribute(Constants.SHIPPING_OPTIONS, options);
if (!CollectionUtils.isEmpty(options)) {
for (ShippingOption shipOption : options) {
StringBuilder moduleName = new StringBuilder();
moduleName.append("module.shipping.").append(shipOption.getShippingModuleCode());
String carrier = messages.getMessage(moduleName.toString(), locale);
String note = messages.getMessage(moduleName.append(".note").toString(), locale, "");
shipOption.setDescription(carrier);
shipOption.setNote(note);
// option name
if (!StringUtils.isBlank(shipOption.getOptionCode())) {
// try to get the translate
StringBuilder optionCodeBuilder = new StringBuilder();
try {
optionCodeBuilder.append("module.shipping.").append(shipOption.getShippingModuleCode());
String optionName = messages.getMessage(optionCodeBuilder.toString(), locale);
shipOption.setOptionName(optionName);
} catch (Exception e) {
// label not found
LOGGER.warn("displayCheckout No shipping code found for " + optionCodeBuilder.toString());
}
}
}
}
}
if (quote.getDeliveryAddress() != null) {
ReadableCustomerDeliveryAddressPopulator addressPopulator = new ReadableCustomerDeliveryAddressPopulator();
addressPopulator.setCountryService(countryService);
addressPopulator.setZoneService(zoneService);
ReadableDelivery deliveryAddress = new ReadableDelivery();
addressPopulator.populate(quote.getDeliveryAddress(), deliveryAddress, store, language);
model.addAttribute("deliveryAddress", deliveryAddress);
super.setSessionAttribute(Constants.KEY_SESSION_ADDRESS, deliveryAddress, request);
}
// get shipping countries
List<Country> shippingCountriesList = orderFacade.getShipToCountry(store, language);
model.addAttribute("countries", shippingCountriesList);
} else {
// get all countries
List<Country> countries = countryService.getCountries(language);
model.addAttribute("countries", countries);
}
if (quote != null && quote.getShippingReturnCode() != null && quote.getShippingReturnCode().equals(ShippingQuote.NO_SHIPPING_MODULE_CONFIGURED)) {
LOGGER.error("Shipping quote error " + quote.getShippingReturnCode());
model.addAttribute("errorMessages", messages.getMessage(quote.getShippingReturnCode(), locale, quote.getShippingReturnCode()));
}
if (quote != null && !StringUtils.isBlank(quote.getQuoteError())) {
LOGGER.error("Shipping quote error " + quote.getQuoteError());
model.addAttribute("errorMessages", quote.getQuoteError());
}
if (quote != null && quote.getShippingReturnCode() != null && quote.getShippingReturnCode().equals(ShippingQuote.NO_SHIPPING_TO_SELECTED_COUNTRY)) {
LOGGER.error("Shipping quote error " + quote.getShippingReturnCode());
model.addAttribute("errorMessages", quote.getShippingReturnCode());
}
/**
* end shipping *
*/
// get payment methods
List<PaymentMethod> paymentMethods = paymentService.getAcceptedPaymentMethods(store);
// not free and no payment methods
if (CollectionUtils.isEmpty(paymentMethods) && !freeShoppingCart) {
LOGGER.error("No payment method configured");
model.addAttribute("errorMessages", messages.getMessage("payment.not.configured", locale, "No payments configured"));
}
if (!CollectionUtils.isEmpty(paymentMethods)) {
// select default payment method
PaymentMethod defaultPaymentSelected = null;
for (PaymentMethod paymentMethod : paymentMethods) {
if (paymentMethod.isDefaultSelected()) {
defaultPaymentSelected = paymentMethod;
break;
}
}
if (defaultPaymentSelected == null) {
// forced default selection
defaultPaymentSelected = paymentMethods.get(0);
defaultPaymentSelected.setDefaultSelected(true);
}
order.setDefaultPaymentMethodCode(defaultPaymentSelected.getPaymentMethodCode());
}
// readable shopping cart items for order summary box
ShoppingCartData shoppingCart = shoppingCartFacade.getShoppingCartData(cart, language);
model.addAttribute("cart", shoppingCart);
order.setCartCode(shoppingCart.getCode());
// order total
OrderTotalSummary orderTotalSummary = orderFacade.calculateOrderTotal(store, order, language);
order.setOrderTotalSummary(orderTotalSummary);
// if order summary has to be re-used
super.setSessionAttribute(Constants.ORDER_SUMMARY, orderTotalSummary, request);
// display hacks
if (!StringUtils.isBlank(googleMapsKey)) {
model.addAttribute("fieldDisabled", "true");
model.addAttribute("cssClass", "");
} else {
model.addAttribute("fieldDisabled", "false");
model.addAttribute("cssClass", "required");
}
model.addAttribute("order", order);
model.addAttribute("paymentMethods", paymentMethods);
/**
* template *
*/
StringBuilder template = new StringBuilder().append(ControllerConstants.Tiles.Checkout.checkout).append(".").append(store.getStoreTemplate());
return template.toString();
}
use of com.salesmanager.core.model.reference.zone.Zone in project shopizer by shopizer-ecommerce.
the class ShippingMethodDecisionTest method validateShippingMethod.
@Test
@Ignore
public void validateShippingMethod() throws Exception {
ShippingQuote quote = new ShippingQuote();
PackageDetails pDetail = new PackageDetails();
pDetail.setShippingHeight(20);
pDetail.setShippingLength(10);
pDetail.setShippingWeight(70);
pDetail.setShippingWidth(78);
List<PackageDetails> details = new ArrayList<PackageDetails>();
details.add(pDetail);
Delivery delivery = new Delivery();
delivery.setAddress("358 Du Languedoc");
delivery.setCity("Boucherville");
delivery.setPostalCode("J4B 8J9");
Country country = new Country();
country.setIsoCode("CA");
country.setName("Canada");
// country.setIsoCode("US");
// country.setName("United States");
delivery.setCountry(country);
Zone zone = new Zone();
zone.setCode("QC");
zone.setName("Quebec");
// zone.setCode("NY");
// zone.setName("New York");
delivery.setZone(zone);
IntegrationModule currentModule = new IntegrationModule();
currentModule.setCode("canadapost");
quote.setCurrentShippingModule(currentModule);
quote.setShippingModuleCode(currentModule.getCode());
IntegrationModule canadapost = new IntegrationModule();
canadapost.setCode("canadapost");
IntegrationModule ups = new IntegrationModule();
ups.setCode("ups");
IntegrationModule inhouse = new IntegrationModule();
inhouse.setCode("customQuotesRules");
List<IntegrationModule> allModules = new ArrayList<IntegrationModule>();
allModules.add(canadapost);
allModules.add(ups);
allModules.add(inhouse);
shippingMethodDecisionProcess.prePostProcessShippingQuotes(quote, details, null, delivery, null, null, null, currentModule, null, allModules, Locale.CANADA);
System.out.println("Done : " + quote.getCurrentShippingModule() != null ? quote.getCurrentShippingModule().getCode() : currentModule.getCode());
}
use of com.salesmanager.core.model.reference.zone.Zone in project shopizer by shopizer-ecommerce.
the class ShippingQuoteByWeightTest method testGetCustomShippingQuotesByWeight.
@Ignore
public // @Test
void testGetCustomShippingQuotesByWeight() throws ServiceException {
Language en = languageService.getByCode("en");
Country country = countryService.getByCode("CA");
Zone zone = zoneService.getByCode("QC");
MerchantStore store = merchantService.getByCode(MerchantStore.DEFAULT_STORE);
ProductType generalType = productTypeService.getProductType(ProductType.GENERAL_TYPE);
// set valid store postal code
store.setStorepostalcode("J4B-9J9");
Product product = new Product();
product.setProductHeight(new BigDecimal(4));
product.setProductLength(new BigDecimal(3));
product.setProductWidth(new BigDecimal(5));
product.setProductWeight(new BigDecimal(8));
product.setSku("TESTSKU");
product.setType(generalType);
product.setMerchantStore(store);
// Product description
ProductDescription description = new ProductDescription();
description.setName("Product 1");
description.setLanguage(en);
description.setProduct(product);
product.getDescriptions().add(description);
productService.create(product);
// productService.saveOrUpdate(product);
// Availability
ProductAvailability availability = new ProductAvailability();
availability.setProductDateAvailable(new Date());
availability.setProductQuantity(100);
availability.setRegion("*");
// associate with product
availability.setProduct(product);
product.getAvailabilities().add(availability);
productAvailabilityService.create(availability);
ProductPrice dprice = new ProductPrice();
dprice.setDefaultPrice(true);
dprice.setProductPriceAmount(new BigDecimal(29.99));
dprice.setProductAvailability(availability);
ProductPriceDescription dpd = new ProductPriceDescription();
dpd.setName("Base price");
dpd.setProductPrice(dprice);
dpd.setLanguage(en);
dprice.getDescriptions().add(dpd);
availability.getPrices().add(dprice);
productPriceService.create(dprice);
// get product
product = productService.getByCode("TESTSKU", en);
// check the product
Set<ProductAvailability> avails = product.getAvailabilities();
for (ProductAvailability as : avails) {
Set<ProductPrice> availabilityPrices = as.getPrices();
for (ProductPrice ps : availabilityPrices) {
System.out.println(ps.getProductPriceAmount().toString());
}
}
// check availability
Set<ProductPrice> availabilityPrices = availability.getPrices();
for (ProductPrice ps : availabilityPrices) {
System.out.println(ps.getProductPriceAmount().toString());
}
// configure shipping
ShippingConfiguration shippingConfiguration = new ShippingConfiguration();
// based on shipping or billing address
shippingConfiguration.setShippingBasisType(ShippingBasisType.SHIPPING);
shippingConfiguration.setShippingType(ShippingType.INTERNATIONAL);
// individual item pricing or box packaging (see unit test above)
shippingConfiguration.setShippingPackageType(ShippingPackageType.ITEM);
// only if package type is package
shippingConfiguration.setBoxHeight(5);
shippingConfiguration.setBoxLength(5);
shippingConfiguration.setBoxWidth(5);
shippingConfiguration.setBoxWeight(1);
shippingConfiguration.setMaxWeight(10);
List<String> supportedCountries = new ArrayList<String>();
supportedCountries.add("CA");
supportedCountries.add("US");
supportedCountries.add("UK");
supportedCountries.add("FR");
shippingService.setSupportedCountries(store, supportedCountries);
CustomShippingQuotesConfiguration customConfiguration = new CustomShippingQuotesConfiguration();
customConfiguration.setModuleCode("weightBased");
customConfiguration.setActive(true);
CustomShippingQuotesRegion northRegion = new CustomShippingQuotesRegion();
northRegion.setCustomRegionName("NORTH");
List<String> countries = new ArrayList<String>();
countries.add("CA");
countries.add("US");
northRegion.setCountries(countries);
CustomShippingQuoteWeightItem caQuote4 = new CustomShippingQuoteWeightItem();
caQuote4.setMaximumWeight(4);
caQuote4.setPrice(new BigDecimal(20));
CustomShippingQuoteWeightItem caQuote10 = new CustomShippingQuoteWeightItem();
caQuote10.setMaximumWeight(10);
caQuote10.setPrice(new BigDecimal(50));
CustomShippingQuoteWeightItem caQuote100 = new CustomShippingQuoteWeightItem();
caQuote100.setMaximumWeight(100);
caQuote100.setPrice(new BigDecimal(120));
List<CustomShippingQuoteWeightItem> quotes = new ArrayList<CustomShippingQuoteWeightItem>();
quotes.add(caQuote4);
quotes.add(caQuote10);
quotes.add(caQuote100);
northRegion.setQuoteItems(quotes);
customConfiguration.getRegions().add(northRegion);
// create an integration configuration - USPS
IntegrationConfiguration configuration = new IntegrationConfiguration();
configuration.setActive(true);
configuration.setEnvironment(Environment.TEST.name());
configuration.setModuleCode("weightBased");
// configure module
shippingService.saveShippingConfiguration(shippingConfiguration, store);
// create the basic configuration
shippingService.saveShippingQuoteModuleConfiguration(configuration, store);
// and the custom configuration
shippingService.saveCustomShippingConfiguration("weightBased", customConfiguration, store);
// now create ShippingProduct
ShippingProduct shippingProduct1 = new ShippingProduct(product);
FinalPrice price = pricingService.calculateProductPrice(product);
shippingProduct1.setFinalPrice(price);
List<ShippingProduct> shippingProducts = new ArrayList<ShippingProduct>();
shippingProducts.add(shippingProduct1);
Customer customer = new Customer();
customer.setMerchantStore(store);
customer.setEmailAddress("test@test.com");
customer.setGender(CustomerGender.M);
customer.setDefaultLanguage(en);
customer.setAnonymous(true);
customer.setCompany("ifactory");
customer.setDateOfBirth(new Date());
customer.setNick("My nick");
customer.setPassword("123456");
Delivery delivery = new Delivery();
delivery.setAddress("Shipping address");
delivery.setCity("Boucherville");
delivery.setCountry(country);
delivery.setZone(zone);
delivery.setPostalCode("J5C-6J4");
// overwrite delivery to US
/* delivery.setPostalCode("90002");
delivery.setCountry(us);
Zone california = zoneService.getByCode("CA");
delivery.setZone(california);*/
Billing billing = new Billing();
billing.setAddress("Billing address");
billing.setCountry(country);
billing.setZone(zone);
billing.setPostalCode("J4B-8J9");
billing.setFirstName("Carl");
billing.setLastName("Samson");
customer.setBilling(billing);
customer.setDelivery(delivery);
customerService.create(customer);
// for correlation
Long dummyCartId = 0L;
ShippingQuote shippingQuote = shippingService.getShippingQuote(dummyCartId, store, delivery, shippingProducts, en);
Assert.notNull(shippingQuote);
}
use of com.salesmanager.core.model.reference.zone.Zone in project shopizer by shopizer-ecommerce.
the class CustomerTest method createCustomer.
@Test
public void createCustomer() throws ServiceException {
Language en = languageService.getByCode("en");
MerchantStore store = merchantService.getByCode(MerchantStore.DEFAULT_STORE);
Country country = countryService.getByCode("CA");
Zone zone = zoneService.getByCode("QC");
/**
* Core customer attributes *
*/
Customer customer = new Customer();
customer.setMerchantStore(store);
customer.setEmailAddress("test@test.com");
customer.setGender(CustomerGender.M);
customer.setAnonymous(true);
customer.setCompany("ifactory");
customer.setDateOfBirth(new Date());
customer.setNick("My nick");
customer.setPassword("123456");
customer.setDefaultLanguage(store.getDefaultLanguage());
Delivery delivery = new Delivery();
delivery.setAddress("Shipping address");
delivery.setCountry(country);
delivery.setZone(zone);
Billing billing = new Billing();
billing.setFirstName("John");
billing.setLastName("Bossanova");
billing.setAddress("Billing address");
billing.setCountry(country);
billing.setZone(zone);
customer.setBilling(billing);
customer.setDelivery(delivery);
customerService.create(customer);
customer = customerService.getById(customer.getId());
// create an option value
CustomerOptionValue yes = new CustomerOptionValue();
yes.setCode("yes");
yes.setMerchantStore(store);
CustomerOptionValueDescription yesDescription = new CustomerOptionValueDescription();
yesDescription.setLanguage(en);
yesDescription.setCustomerOptionValue(yes);
CustomerOptionValueDescription yes_sir = new CustomerOptionValueDescription();
yes_sir.setCustomerOptionValue(yes);
yes_sir.setDescription("Yes sir!");
yes_sir.setName("Yes sir!");
yes_sir.setLanguage(en);
yes.getDescriptions().add(yes_sir);
// needs to be saved before using it
customerOptionValueService.create(yes);
CustomerOptionValue no = new CustomerOptionValue();
no.setCode("no");
no.setMerchantStore(store);
CustomerOptionValueDescription noDescription = new CustomerOptionValueDescription();
noDescription.setLanguage(en);
noDescription.setCustomerOptionValue(no);
CustomerOptionValueDescription no_sir = new CustomerOptionValueDescription();
no_sir.setCustomerOptionValue(no);
no_sir.setDescription("Nope!");
no_sir.setName("Nope!");
no_sir.setLanguage(en);
no.getDescriptions().add(no_sir);
// needs to be saved before using it
customerOptionValueService.create(no);
// create a customer option to be used
CustomerOption subscribedToMailingList = new CustomerOption();
subscribedToMailingList.setActive(true);
subscribedToMailingList.setPublicOption(true);
subscribedToMailingList.setCode("subscribedToMailingList");
subscribedToMailingList.setMerchantStore(store);
CustomerOptionDescription mailingListDesciption = new CustomerOptionDescription();
mailingListDesciption.setName("Subscribed to mailing list");
mailingListDesciption.setDescription("Subscribed to mailing list");
mailingListDesciption.setLanguage(en);
mailingListDesciption.setCustomerOption(subscribedToMailingList);
Set<CustomerOptionDescription> mailingListDesciptionList = new HashSet<CustomerOptionDescription>();
mailingListDesciptionList.add(mailingListDesciption);
subscribedToMailingList.setDescriptions(mailingListDesciptionList);
customerOptionService.create(subscribedToMailingList);
// create a customer option to be used
CustomerOption hasReturnedItems = new CustomerOption();
hasReturnedItems.setActive(true);
hasReturnedItems.setPublicOption(true);
hasReturnedItems.setCode("hasReturnedItems");
hasReturnedItems.setMerchantStore(store);
CustomerOptionDescription hasReturnedItemsDesciption = new CustomerOptionDescription();
hasReturnedItemsDesciption.setName("Has returned items");
hasReturnedItemsDesciption.setDescription("Has returned items");
hasReturnedItemsDesciption.setLanguage(en);
hasReturnedItemsDesciption.setCustomerOption(hasReturnedItems);
Set<CustomerOptionDescription> hasReturnedItemsList = new HashSet<CustomerOptionDescription>();
hasReturnedItemsList.add(hasReturnedItemsDesciption);
hasReturnedItems.setDescriptions(hasReturnedItemsList);
customerOptionService.create(hasReturnedItems);
subscribedToMailingList.setSortOrder(3);
customerOptionService.update(subscribedToMailingList);
// --
// now create an option set (association of a customer option with possible customer option values)
// --
// possible yes
CustomerOptionSet mailingListSetYes = new CustomerOptionSet();
mailingListSetYes.setSortOrder(0);
mailingListSetYes.setCustomerOption(subscribedToMailingList);
mailingListSetYes.setCustomerOptionValue(yes);
customerOptionSetService.create(mailingListSetYes);
// possible no
CustomerOptionSet mailingListSetNo = new CustomerOptionSet();
// mailingListSetNo.setPk(mailingListSetNoId);
mailingListSetNo.setSortOrder(1);
mailingListSetNo.setCustomerOption(subscribedToMailingList);
mailingListSetNo.setCustomerOptionValue(no);
customerOptionSetService.create(mailingListSetNo);
// possible has returned items
CustomerOptionSet hasReturnedItemsYes = new CustomerOptionSet();
hasReturnedItemsYes.setSortOrder(0);
hasReturnedItemsYes.setCustomerOption(hasReturnedItems);
hasReturnedItemsYes.setCustomerOptionValue(yes);
customerOptionSetService.create(hasReturnedItemsYes);
subscribedToMailingList.setSortOrder(2);
customerOptionService.update(subscribedToMailingList);
CustomerOption option = customerOptionService.getById(subscribedToMailingList.getId());
option.setSortOrder(4);
customerOptionService.update(option);
List<CustomerOptionSet> optionSetList = customerOptionSetService.listByStore(store, en);
// Assert.assertEquals(3, optionSetList.size());
System.out.println("Size of options : " + optionSetList.size());
/**
* Now create a customer option attribute
* A customer attribute is a selected customer option set transformed to an
* attribute for a given customer
*/
CustomerAttribute customerAttributeMailingList = new CustomerAttribute();
customerAttributeMailingList.setCustomer(customer);
customerAttributeMailingList.setCustomerOption(subscribedToMailingList);
customerAttributeMailingList.setCustomerOptionValue(no);
customer.getAttributes().add(customerAttributeMailingList);
customerService.save(customer);
customerService.delete(customer);
}
use of com.salesmanager.core.model.reference.zone.Zone in project shopizer by shopizer-ecommerce.
the class ReferenceController method zoneName.
@RequestMapping(value = "/shop/reference/zoneName")
@ResponseBody
public String zoneName(@RequestParam String zoneCode, HttpServletRequest request, HttpServletResponse response) {
try {
Language language = languageUtils.getRequestLanguage(request, response);
if (language == null) {
return zoneCode;
}
Map<String, Zone> zonesMap = zoneService.getZones(language);
if (zonesMap != null) {
Zone z = zonesMap.get(zoneCode);
if (z != null) {
return z.getName();
}
}
} catch (ServiceException e) {
LOGGER.error("Error while looking up zone " + zoneCode);
}
return SanitizeUtils.getSafeString(zoneCode);
}
Aggregations