/** * Adds the customer test data. * * @param array $testdata Associative list of key/list pairs * @param \Aimeos\MShop\Common\Manager\Iface $customerManager Customer manager * @param \Aimeos\MShop\Common\Item\Address\Iface $address Customer address item * @throws \Aimeos\MW\Setup\Exception If a required ID is not available */ protected function addCustomerData(array $testdata, \Aimeos\MShop\Common\Manager\Iface $customerManager, \Aimeos\MShop\Common\Item\Address\Iface $address) { $parentIds = array(); $customer = $customerManager->createItem(); foreach ($testdata['customer'] as $key => $dataset) { $address->setCompany($dataset['company']); $address->setVatID(isset($dataset['vatid']) ? $dataset['vatid'] : ''); $address->setSalutation($dataset['salutation']); $address->setTitle($dataset['title']); $address->setFirstname($dataset['firstname']); $address->setLastname($dataset['lastname']); $address->setAddress1($dataset['address1']); $address->setAddress2($dataset['address2']); $address->setAddress3($dataset['address3']); $address->setPostal($dataset['postal']); $address->setCity($dataset['city']); $address->setState($dataset['state']); $address->setCountryId($dataset['countryid']); $address->setTelephone($dataset['telephone']); $address->setEmail($dataset['email']); $address->setTelefax($dataset['telefax']); $address->setWebsite($dataset['website']); $address->setLanguageId($dataset['langid']); $customer->setId(null); $customer->setLabel($dataset['label']); $customer->setCode($dataset['code']); $customer->setStatus($dataset['status']); $customer->setPaymentAddress($address); $customer->setPassword(isset($dataset['password']) ? $dataset['password'] : ''); $customer->setBirthday(isset($dataset['birthday']) ? $dataset['birthday'] : null); $customerManager->saveItem($customer); $parentIds[$key] = $customer->getId(); } return $parentIds; }
/** * Copies the values of the address item into another one. * * @param \Aimeos\MShop\Common\Item\Address\Iface $item Address item * @return \Aimeos\MShop\Common\Item\Address\Iface Common address item for chaining method calls */ public function copyFrom(\Aimeos\MShop\Common\Item\Address\Iface $item) { $this->setCompany($item->getCompany()); $this->setVatID($item->getVatID()); $this->setSalutation($item->getSalutation()); $this->setTitle($item->getTitle()); $this->setFirstname($item->getFirstname()); $this->setLastname($item->getLastname()); $this->setAddress1($item->getAddress1()); $this->setAddress2($item->getAddress2()); $this->setAddress3($item->getAddress3()); $this->setPostal($item->getPostal()); $this->setCity($item->getCity()); $this->setState($item->getState()); $this->setCountryId($item->getCountryId()); $this->setLanguageId($item->getLanguageId()); $this->setTelephone($item->getTelephone()); $this->setTelefax($item->getTelefax()); $this->setEmail($item->getEmail()); $this->setWebsite($item->getWebsite()); $this->setFlag($item->getFlag()); $this->setModified(); return $this; }
/** * Sets the billingaddress of the customer item. * * @param \Aimeos\MShop\Common\Item\Address\Iface $address Billingaddress of the customer item */ public function setPaymentAddress(\Aimeos\MShop\Common\Item\Address\Iface $address) { if ($address === $this->billingaddress && $address->isModified() === false) { return; } $this->billingaddress = $address; $this->setModified(); }
/** * Adds the customer and address data to the given customer item * * @param \Aimeos\MShop\Customer\Item\Iface $customer Customer object * @param \Aimeos\MShop\Common\Item\Address\Iface $address Billing address object * @return \Aimeos\MShop\Customer\Item\Iface Customer object filled with data */ protected function addCustomerData(\Aimeos\MShop\Customer\Item\Iface $customer, \Aimeos\MShop\Common\Item\Address\Iface $address, $code, $password) { $label = $address->getLastname(); if (($part = $address->getFirstname()) !== '') { $label = $part . ' ' . $label; } if (($part = $address->getCompany()) !== '') { $label .= ' (' . $part . ')'; } $customer->setPaymentAddress($address); $customer->setCode($code); $customer->setPassword($password); $customer->setLabel($label); $customer->setStatus(1); return $customer; }
/** * Adds the customer and address data to the given customer item * * @param \Aimeos\MShop\Customer\Item\Iface $customer Customer object * @param \Aimeos\MShop\Common\Item\Address\Iface $address Billing address object * @param string $code Unique customer code, e.g. user name or e-mail address * @param string $password Plain-text password for the customer * @return \Aimeos\MShop\Customer\Item\Iface Customer object filled with data */ protected function addCustomerData(\Aimeos\MShop\Customer\Item\Iface $customer, \Aimeos\MShop\Common\Item\Address\Iface $address, $code, $password) { $extra = $this->getContext()->getSession()->get('client/html/checkout/standard/address/extra'); $label = $address->getLastname(); if (($part = $address->getFirstname()) !== '') { $label = $part . ' ' . $label; } if (($part = $address->getCompany()) !== '') { $label .= ' (' . $part . ')'; } $customer->setPaymentAddress($address); $customer->setPassword($password); $customer->setLabel($label); $customer->setCode($code); $customer->setStatus(1); try { $customer->setBirthday((string) $extra['customer.birthday']); } catch (\Aimeos\MShop\Exception $e) { // don't break on invalid birthdays } /** client/html/checkout/standard/order/account/standard/groupids * List of groups new customers should be assigned to * * Newly created customers will be assigned automatically to the groups * given by their IDs. This is especially useful if those groups limit * functionality for those users. * * @param array List of group IDs * @since 2016.03 * @category User * @category Developer */ $config = $this->getContext()->getConfig(); $gids = (array) $config->get('client/html/checkout/standard/order/account/standard/groupids', array()); $customer->setGroups($gids); return $customer; }
/** * Sends the notification e-mail for the given customer address and products * * @param \Aimeos\MShop\Context\Item\Iface $context Context item object * @param \Aimeos\MShop\Common\Item\Address\Iface $address Payment address of the customer * @param array $products List of products a notification should be sent for */ protected function sendMail(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Common\Item\Address\Iface $address, array $products) { $view = $context->getView(); $view->extProducts = $products; $view->extAddressItem = $address; $helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $context->getI18n($address->getLanguageId())); $view->addHelper('translate', $helper); $mailer = $context->getMail(); $message = $mailer->createMessage(); $helper = new \Aimeos\MW\View\Helper\Mail\Standard($view, $message); $view->addHelper('mail', $helper); $client = $this->getClient($context); $client->setView($view); $client->getHeader(); $client->getBody(); $mailer->send($message); }