/** * Prepare data. * * @param Customer $customer * @param Customer $initialCustomer [optional] * @return string */ protected function prepareData(Customer $customer, Customer $initialCustomer = null) { if ($initialCustomer) { $customer = $customer->hasData() ? array_merge($initialCustomer->getData(), $customer->getData()) : $initialCustomer->getData(); } else { $customer = $customer->getData(); } $name = (isset($customer['prefix']) ? $customer['prefix'] . ' ' : '') . $customer['firstname'] . (isset($customer['middlename']) ? ' ' . $customer['middlename'] : '') . ' ' . $customer['lastname'] . (isset($customer['suffix']) ? ' ' . $customer['suffix'] : ''); return [$name, $customer]; }
/** * Prepare data. * * @param Customer $customer * @param Customer $initialCustomer [optional] * @param Address $address [optional] * @return array */ protected function prepareData(Customer $customer, Customer $initialCustomer = null, Address $address = null) { if ($initialCustomer) { $data['customer'] = $customer->hasData() ? array_merge($initialCustomer->getData(), $customer->getData()) : $initialCustomer->getData(); } else { $data['customer'] = $customer->getData(); } if ($address) { $data['addresses'][1] = $address->hasData() ? $address->getData() : []; } else { $data['addresses'] = []; } return $data; }
/** * Get all error validation messages for fields. * * @param Customer $customer * @return array */ public function getValidationMessages(Customer $customer) { $messages = []; foreach (array_keys($customer->getData()) as $field) { $element = $this->_rootElement->find(sprintf($this->validationText, 'advice-validate-c' . str_replace('_', '-', $field))); if ($element->isVisible()) { $messages[$field] = $element->getText(); } } return $messages; }
/** * Prepare customer data. * * @param array $data * @return array */ protected function prepareCustomerData(array $data) { return ['currency_id' => $data['base_currency_code'], 'customer_id' => $this->customer->getData('id'), 'payment' => $data['payment_authorization_amount'], 'store_id' => $this->order->getDataFieldConfig('store_id')['source']->store->getStoreId()]; }