/** * Edit a customer * * Method will edit a customer's details * * @access public * @param array $input The customer's details * @param int $customerId The optional customer ID. Default will be $input[$this->primaryKeyName] * @param bool $isFullAddressBook TRUE to delete any addresses first before adding them in. Default is FALSE * @param bool $filterUniqueAddress TRUE to only insert unique addresses, FALSE not to check. Default is FALSE * @return bool TRUE if the customer exists and the details were updated successfully, FALSE oterwise */ public function edit($input, $customerId='', $isFullAddressBook=false, $filterUniqueAddress=false) { if (!parent::edit($input, $customerId)) { return false; } if (!isId($customerId)) { $customerId = $input[$this->primaryKeyName]; } if (array_key_exists("addresses", $input) && is_array($input["addresses"]) && !empty($input["addresses"])) { /** * Do we need to clear out our address book first? */ if ($isFullAddressBook) { $this->shipping->deleteByCustomer($customerId); } /** * Sanatise the addresses, just in case */ if (is_associative_array($input["addresses"])) { $input["addresses"] = array($input["addresses"]); } foreach ($input["addresses"] as $address) { $address['shipcustomerid'] = $customerId; if (!$isFullAddressBook && array_key_exists("shipid", $address) && isId($address["shipid"])) { $this->shipping->edit($address); } else if (!$filterUniqueAddress || !$this->shipping->basicSearch($address)) { $this->shipping->add($address); } } } if (isset($input['custpassword']) && !empty($input['custpassword'])) { // change password from edit screen $this->updatePassword($customerId, $input['custpassword']); } return true; }