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);
}
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;
}
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);
}
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;
}
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);
}
Aggregations