@Override public ShoppingCart populateAddressAndShippingFields( final ShoppingCart shoppingCart, final CartOrder cartOrder) { Address billingAddress = getBillingAddress(cartOrder); shoppingCart.setBillingAddress(billingAddress); Address shippingAddress = getShippingAddress(cartOrder); shoppingCart.setShippingAddress(shippingAddress); Store store = shoppingCart.getStore(); List<ShippingServiceLevel> shippingServiceLevels = shippingServiceLevelService.retrieveShippingServiceLevel(store.getCode(), shippingAddress); if (CollectionUtils.isNotEmpty(shippingServiceLevels)) { String shippingServiceLevelGuidFromCartOrder = cartOrder.getShippingServiceLevelGuid(); ShippingServiceLevel matchingShippingServiceLevel = getShippingServiceLevelMatchingGuid( shippingServiceLevels, shippingServiceLevelGuidFromCartOrder); if (matchingShippingServiceLevel != null) { shoppingCart.setShippingServiceLevelList(shippingServiceLevels); shoppingCart.setSelectedShippingServiceLevelUid(matchingShippingServiceLevel.getUidPk()); } } return shoppingCart; }
/** * Using a language String finds the afferent locale. * * @param localeString * @return */ private Locale getLocaleByLanguageStr(final String localeString) { Store store = requestHelper.getStoreConfig().getStore(); for (Locale locale : store.getSupportedLocales()) { if (locale.toString().equals(localeString)) { return locale; } } return store.getDefaultLocale(); }
/** * Create shopping cart promotion rule. * * @param promotionName the promotion name * @param storeCode the store code * @param code promo code (not a coupon code) * @return configured rule instance */ public Rule createShoppingCartPromotion( final String promotionName, final String storeCode, final String code) { final Rule promotionRule = createPromotion( promotionName, code, ruleSetService.findByScenarioId(RuleScenarios.CART_SCENARIO), false); final Store store = storeService.findStoreWithCode(storeCode); if (store == null) { throw new TestApplicationException("Store with code " + storeCode + " doesn't exists in DB."); } promotionRule.setStore(store); promotionRule.setCatalog(store.getCatalog()); return promotionRule; }
private Set<Pair<String, String>> getStoreNameSupportedCurrencySet( final List<Long> storeUidPks, final String currencyCode) { final Set<Pair<String, String>> storeNameCurrencySet = new HashSet<Pair<String, String>>(); final List<Store> stores = getPersistenceEngine() .retrieveByNamedQueryWithList("STORE_WITH_UIDS", PLACEHOLDER_FOR_LIST, storeUidPks); for (Store store : stores) { for (Currency currency : store.getSupportedCurrencies()) { if (currencyCode == null) { storeNameCurrencySet.add( new Pair<String, String>(store.getName(), currency.getCurrencyCode())); } else { if (currency.getCurrencyCode().equalsIgnoreCase(currencyCode)) { storeNameCurrencySet.add( new Pair<String, String>(store.getName(), currency.getCurrencyCode())); } } } } return storeNameCurrencySet; }
/** * Retrieves {@link GiftCertificate} given the gift certificate code. If that gift certificate is * not within the given store, returns <code>null</code>. * * @param giftCertificateCode Gift Certificate Code to compare with * @param store the store to search * @return a {@link GiftCertificate} */ public GiftCertificate findByGiftCertificateCode( final String giftCertificateCode, final Store store) { if (giftCertificateCode == null) { throw new IllegalArgumentException( "Gift certificate code (" + giftCertificateCode + ") and store (" + store + ") can not be null"); } String code = giftCertificateCode.trim(); GiftCertificate giftCertificate = getSingleResultFromNamedQuery( "GIFT_CERTIFICATE_FIND_BY_CODE_AND_STORE", code, store.getUidPk()); return giftCertificate; }
/** * Creates simple store. * * @param country The store country. * @param name The store name. * @param storeType The StoreType value. * @param subCountry The province or state. * @param url The store URL. * @param timeZone The store time zone. * @param code The unique store code. * @param emailSenderName The email sender name. * @param emailSenderAddress The email sender address. * @param storeAdminEmailAddress The admin email address. * @param catalog The store default catalog. * @param defaultLocale The default locale. * @param defaultCurrency The default currency of the store. * @return The newly persisted store. */ public Store createStore( final String country, final String name, final StoreType storeType, final String subCountry, final String url, final TimeZone timeZone, final String code, final String emailSenderName, final String emailSenderAddress, final String storeAdminEmailAddress, final Catalog catalog, final Locale defaultLocale, final Currency defaultCurrency) { final Store store = getBeanFactory().getBean(ContextIdNames.STORE); store.setCountry(country); store.setName(name); store.setStoreType(storeType); store.setSubCountry(subCountry); store.setUrl(url); store.setTimeZone(timeZone); store.setCode(Utils.uniqueCode(code)); store.setEmailSenderName(emailSenderName); store.setEmailSenderAddress(emailSenderAddress); store.setStoreAdminEmailAddress(storeAdminEmailAddress); store.setCatalog(catalog); store.setDefaultLocale(defaultLocale); store.setDefaultCurrency(defaultCurrency); return store; }