Search in sources :

Example 91 with Customer

use of org.broadleafcommerce.profile.core.domain.Customer in project BroadleafCommerce by BroadleafCommerce.

the class BroadleafSocialRegisterController method register.

// Pre-populate portions of the RegisterCustomerForm from ProviderSignInUtils.getConnection();
public String register(RegisterCustomerForm registerCustomerForm, HttpServletRequest request, HttpServletResponse response, Model model) {
    Connection<?> connection = ProviderSignInUtils.getConnection(new ServletWebRequest(request));
    if (connection != null) {
        UserProfile userProfile = connection.fetchUserProfile();
        Customer customer = registerCustomerForm.getCustomer();
        customer.setFirstName(userProfile.getFirstName());
        customer.setLastName(userProfile.getLastName());
        customer.setEmailAddress(userProfile.getEmail());
        if (isUseEmailForLogin()) {
            customer.setUsername(userProfile.getEmail());
        } else {
            customer.setUsername(userProfile.getUsername());
        }
    }
    return super.register(registerCustomerForm, request, response, model);
}
Also used : UserProfile(org.springframework.social.connect.UserProfile) Customer(org.broadleafcommerce.profile.core.domain.Customer) ServletWebRequest(org.springframework.web.context.request.ServletWebRequest)

Example 92 with Customer

use of org.broadleafcommerce.profile.core.domain.Customer in project BroadleafCommerce by BroadleafCommerce.

the class CheckoutFormServiceImpl method prePopulatePaymentInfoForm.

@Override
public PaymentInfoForm prePopulatePaymentInfoForm(PaymentInfoForm paymentInfoForm, ShippingInfoForm shippingInfoForm, Order cart) {
    Customer customer = CustomerState.getCustomer();
    String emailAddress = getKnownEmailAddress(cart, customer);
    paymentInfoForm.setEmailAddress(emailAddress);
    Address billingAddress = getBillingAddress(cart);
    if (billingAddress != null) {
        paymentInfoForm.setAddress(billingAddress);
    }
    CustomerPayment customerPaymentUsedForOrder = getCustomerPaymentUsedForOrder();
    Long customerPaymentId = (customerPaymentUsedForOrder == null) ? null : customerPaymentUsedForOrder.getId();
    paymentInfoForm.setCustomerPaymentId(customerPaymentId);
    boolean shouldUseCustomerPaymentDefaultValue = getShouldUseCustomerPaymentDefaultValue(customerPaymentUsedForOrder);
    paymentInfoForm.setShouldUseCustomerPayment(shouldUseCustomerPaymentDefaultValue);
    boolean shouldUseShippingAddressDefaultValue = getShouldUseShippingAddressDefaultValue(customerPaymentUsedForOrder, paymentInfoForm, shippingInfoForm);
    paymentInfoForm.setShouldUseShippingAddress(shouldUseShippingAddressDefaultValue);
    boolean shouldSaveNewPaymentDefaultValue = getShouldSaveNewPaymentDefaultValue();
    paymentInfoForm.setShouldSaveNewPayment(shouldSaveNewPaymentDefaultValue);
    return paymentInfoForm;
}
Also used : Address(org.broadleafcommerce.profile.core.domain.Address) CustomerAddress(org.broadleafcommerce.profile.core.domain.CustomerAddress) Customer(org.broadleafcommerce.profile.core.domain.Customer) CustomerPayment(org.broadleafcommerce.profile.core.domain.CustomerPayment)

Example 93 with Customer

use of org.broadleafcommerce.profile.core.domain.Customer in project BroadleafCommerce by BroadleafCommerce.

the class CheckoutFormServiceImpl method determineIfSavedAddressIsSelected.

@Override
public void determineIfSavedAddressIsSelected(Model model, ShippingInfoForm shippingInfoForm, PaymentInfoForm paymentInfoForm) {
    Customer customer = CustomerState.getCustomer();
    boolean isSavedShippingAddress = false;
    boolean isSavedBillingAddress = false;
    for (CustomerAddress customerAddress : customer.getCustomerAddresses()) {
        if (addressesContentsAreEqual(shippingInfoForm.getAddress(), customerAddress.getAddress())) {
            isSavedShippingAddress = true;
            break;
        }
    }
    for (CustomerAddress customerAddress : customer.getCustomerAddresses()) {
        if (addressesContentsAreEqual(paymentInfoForm.getAddress(), customerAddress.getAddress())) {
            isSavedBillingAddress = true;
            break;
        }
    }
    model.addAttribute("isSavedShippingAddress", isSavedShippingAddress);
    model.addAttribute("isSavedBillingAddress", isSavedBillingAddress);
}
Also used : Customer(org.broadleafcommerce.profile.core.domain.Customer) CustomerAddress(org.broadleafcommerce.profile.core.domain.CustomerAddress)

Example 94 with Customer

use of org.broadleafcommerce.profile.core.domain.Customer in project BroadleafCommerce by BroadleafCommerce.

the class NamedOrderProcessor method populateModelVariables.

@Override
public Map<String, Object> populateModelVariables(String tagName, Map<String, String> tagAttributes, BroadleafTemplateContext context) {
    Customer customer = CustomerState.getCustomer();
    String orderVar = tagAttributes.get("orderVar");
    String orderName = tagAttributes.get("orderName");
    Order order = orderService.findNamedOrderForCustomer(orderName, customer);
    Map<String, Object> newModelVars = new HashMap<>();
    if (order != null) {
        newModelVars.put(orderVar, order);
    } else {
        newModelVars.put(orderVar, new NullOrderImpl());
    }
    return newModelVars;
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) Customer(org.broadleafcommerce.profile.core.domain.Customer) HashMap(java.util.HashMap) NullOrderImpl(org.broadleafcommerce.core.order.domain.NullOrderImpl)

Example 95 with Customer

use of org.broadleafcommerce.profile.core.domain.Customer in project BroadleafCommerce by BroadleafCommerce.

the class UncacheableDataProcessor method addCustomerData.

protected void addCustomerData(Map<String, Object> attrMap) {
    Customer customer = CustomerState.getCustomer();
    String firstName = "";
    String lastName = "";
    boolean anonymous = false;
    if (customer != null) {
        if (!StringUtils.isEmpty(customer.getFirstName())) {
            firstName = customer.getFirstName();
        }
        if (!StringUtils.isEmpty(customer.getLastName())) {
            lastName = customer.getLastName();
        }
        if (customer.isAnonymous()) {
            anonymous = true;
        }
    }
    attrMap.put("firstName", firstName);
    attrMap.put("lastName", lastName);
    attrMap.put("anonymous", anonymous);
}
Also used : Customer(org.broadleafcommerce.profile.core.domain.Customer)

Aggregations

Customer (org.broadleafcommerce.profile.core.domain.Customer)98 Order (org.broadleafcommerce.core.order.domain.Order)41 Transactional (org.springframework.transaction.annotation.Transactional)34 Test (org.testng.annotations.Test)33 Address (org.broadleafcommerce.profile.core.domain.Address)14 Rollback (org.springframework.test.annotation.Rollback)11 HashMap (java.util.HashMap)9 CustomerAddress (org.broadleafcommerce.profile.core.domain.CustomerAddress)9 FulfillmentGroup (org.broadleafcommerce.core.order.domain.FulfillmentGroup)8 MergeCartResponse (org.broadleafcommerce.core.order.service.call.MergeCartResponse)6 ArrayList (java.util.ArrayList)5 Money (org.broadleafcommerce.common.money.Money)5 Category (org.broadleafcommerce.core.catalog.domain.Category)5 Product (org.broadleafcommerce.core.catalog.domain.Product)5 AddressImpl (org.broadleafcommerce.profile.core.domain.AddressImpl)5 CommonSetupBaseTest (org.broadleafcommerce.test.CommonSetupBaseTest)5 CustomerImpl (org.broadleafcommerce.profile.core.domain.CustomerImpl)4 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)3 ServiceException (org.broadleafcommerce.common.exception.ServiceException)3 ISOCountry (org.broadleafcommerce.common.i18n.domain.ISOCountry)3