|
24 | 24 | import org.broadleafcommerce.common.money.Money;
|
25 | 25 | import org.broadleafcommerce.common.payment.PaymentType;
|
26 | 26 | import org.broadleafcommerce.common.payment.dto.PaymentRequestDTO;
|
| 27 | +import org.broadleafcommerce.common.util.BLCSystemProperty; |
27 | 28 | import org.broadleafcommerce.core.order.domain.FulfillmentGroup;
|
28 | 29 | import org.broadleafcommerce.core.order.domain.Order;
|
29 | 30 | import org.broadleafcommerce.core.order.service.FulfillmentGroupService;
|
@@ -170,10 +171,25 @@ protected void populateShipTo(Order order, PaymentRequestDTO requestDTO) {
|
170 | 171 | if (fgAddress.getPhonePrimary() != null) {
|
171 | 172 | phone = fgAddress.getPhonePrimary().getPhoneNumber();
|
172 | 173 | }
|
173 |
| - |
| 174 | + String firstName; |
| 175 | + String lastName; |
| 176 | + if (BLCSystemProperty.resolveBooleanSystemProperty("validator.address.fullNameOnly")) { |
| 177 | + String fullName = fgAddress.getFullName(); |
| 178 | + |
| 179 | + if ((fullName.indexOf(' ') != -1) && (fullName.length() > fullName.indexOf(' ') + 1)) { |
| 180 | + firstName = fullName.substring(0, fullName.indexOf('_')); |
| 181 | + lastName = fullName.substring(fullName.lastIndexOf(' ') + 1, fullName.length()); |
| 182 | + } else { |
| 183 | + firstName = fullName; |
| 184 | + lastName = ""; |
| 185 | + } |
| 186 | + } else { |
| 187 | + firstName = fgAddress.getFirstName(); |
| 188 | + lastName = fgAddress.getLastName(); |
| 189 | + } |
174 | 190 | requestDTO.shipTo()
|
175 |
| - .addressFirstName(fgAddress.getFirstName()) |
176 |
| - .addressLastName(fgAddress.getLastName()) |
| 191 | + .addressFirstName(firstName) |
| 192 | + .addressLastName(lastName) |
177 | 193 | .addressCompanyName(fgAddress.getCompanyName())
|
178 | 194 | .addressLine1(fgAddress.getAddressLine1())
|
179 | 195 | .addressLine2(fgAddress.getAddressLine2())
|
@@ -213,10 +229,25 @@ protected void populateBillTo(Order order, PaymentRequestDTO requestDTO) {
|
213 | 229 | if (billAddress.getPhonePrimary() != null) {
|
214 | 230 | phone = billAddress.getPhonePrimary().getPhoneNumber();
|
215 | 231 | }
|
216 |
| - |
| 232 | + String firstName; |
| 233 | + String lastName; |
| 234 | + if (BLCSystemProperty.resolveBooleanSystemProperty("validator.address.fullNameOnly")) { |
| 235 | + String fullName = billAddress.getFullName(); |
| 236 | + |
| 237 | + if ((fullName.indexOf(' ') != -1) && (fullName.length() > fullName.indexOf(' ') + 1)) { |
| 238 | + firstName = fullName.substring(0, fullName.indexOf('_')); |
| 239 | + lastName = fullName.substring(fullName.lastIndexOf(' ') + 1, fullName.length()); |
| 240 | + } else { |
| 241 | + firstName = fullName; |
| 242 | + lastName = ""; |
| 243 | + } |
| 244 | + } else { |
| 245 | + firstName = billAddress.getFirstName(); |
| 246 | + lastName = billAddress.getLastName(); |
| 247 | + } |
217 | 248 | requestDTO.billTo()
|
218 |
| - .addressFirstName(billAddress.getFirstName()) |
219 |
| - .addressLastName(billAddress.getLastName()) |
| 249 | + .addressFirstName(firstName) |
| 250 | + .addressLastName(lastName) |
220 | 251 | .addressCompanyName(billAddress.getCompanyName())
|
221 | 252 | .addressLine1(billAddress.getAddressLine1())
|
222 | 253 | .addressLine2(billAddress.getAddressLine2())
|
|
0 commit comments