/**
  * Get addresses.
  *
  * @return array
  */
 protected function getAddresses()
 {
     $addresses = [];
     if ($this->customer->hasData('address')) {
         $addresses = $this->customer->getDataFieldConfig('address')['source']->getAddresses();
     }
     return array_merge($addresses, $this->addresses);
 }
示例#2
0
 /**
  * Get data of Customer information, addresses on tabs.
  *
  * @param Customer $customer
  * @param Address|Address[]|null $address
  * @return array
  */
 public function getDataCustomer(Customer $customer, $address = null)
 {
     $data = ['customer' => $customer->hasData() ? parent::getData($customer) : parent::getData()];
     if (null !== $address) {
         $this->openTab('addresses');
         $data['addresses'] = $this->getTabElement('addresses')->getDataAddresses($address);
     }
     return $data;
 }
 /**
  * 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 billing address for asserts.
  *
  * @param Customer $customer
  * @return null|Address
  */
 protected function getBillingAddress(Customer $customer)
 {
     return $customer->hasData('address') ? $customer->getDataFieldConfig('address')['source']->getAddresses()[0] : null;
 }
示例#5
0
 /**
  * Prepare order data.
  *
  * @param array $data
  * @return array
  */
 protected function prepareOrderData(array $data)
 {
     $customerGroupId = $this->customer->hasData('group_id') ? $this->customer->getDataFieldConfig('group_id')['source']->getCustomerGroup()->getCustomerGroupId() : 1;
     $result = ['name' => $this->customer->getFirstname(), 'order' => ['currency' => $data['order_currency_code'], 'account' => ['group_id' => $customerGroupId, 'email' => $this->customer->getEmail()], 'shipping_method' => $data['shipping_method']], 'item' => $this->prepareOrderProductsData($data['entity_id']), 'billing_address' => $this->prepareBillingAddress($data['billing_address_id']), 'shipping_same_as_billing' => 'on', 'payment' => $data['payment_auth_expiration']];
     return $result;
 }