You are here

public function UcAddressesAddress::copyAddress in Ubercart Addresses 6.2

Same name and namespace in other branches
  1. 7 class/UcAddressesAddress.class.php \UcAddressesAddress::copyAddress()

Make a copy of this address.

This method only copies the aggregrated schema object over. The fields aid, address_name, default_shipping and default_billing will be emptied.

@access public

Parameters

UcAddressesAddressBook $addressBook: (optional) The address book to copy the address to. Defaults to the address book the current address belongs to.

Return value

UcAddressesAddress A new instance of UcAddressesAddress.

File

class/UcAddressesAddress.class.php, line 156
Contains the UcAddressesAddress class.

Class

UcAddressesAddress
The main address class used by uc_addresses (and extension modules).

Code

public function copyAddress(UcAddressesAddressBook $addressBook = NULL) {
  if (!$addressBook) {
    $addressBook = $this->addressBook;
  }

  // Get a copy of our schema address and empty the fields aid,
  // address_name, default_shipping and default_billing.
  $schemaAddress = clone $this
    ->getSchemaAddress();
  $schemaAddress->aid = 0;
  $schemaAddress->address_name = '';
  $schemaAddress->default_shipping = 0;
  $schemaAddress->default_billing = 0;
  $schemaAddress->uid = $addressBook
    ->getUserId();

  // Create a new address.
  $address = new UcAddressesAddress($addressBook, $schemaAddress);
  return $address;
}