Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
// unit test:
foreach(array(Order::BILLING, Order::SHIPPING) as $type){
${$type."Address"} = new CustomerAddress();
${$type."Address"}->setFirstName("{$type} First");
${$type."Address"}->setLastName("{$type} Last");
${$type."Address"}->setAddress1("{$type} 123 Main Street");
${$type."Address"}->setAddress2("{$type} Apt 123");
${$type."Address"}->setCity("{$type} New York");
${$type."Address"}->setState("{$type} NY");
${$type."Address"}->setPostalCode("{$type} 10011");
}
$order->setShippingAddress($shippingAddress);
$order->setBillingAddress($billingAddress);
// Order.php
public function setShippingAddress(CustomerAddress $address)
{
$this->shippingName = sprintf("%s %s", $address->getFirstName(), $address->getLastName());
$this->shippingAddress1 = $address->getAddress1();
$this->shippingAddress2 = $address->getAddress2();
$this->shippingCity = $address->getCity();
$this->shippingState = $address->getState();
$this->shippingPostalCode = $address->getPostalCode();
}
public function setBillingAddress(CustomerAddress $address)
{
$this->billingName = sprintf("%s %s", $address->getFirstName(), $address->getLastName());
$this->billingAddress1 = $address->getAddress1();
$this->billingAddress2 = $address->getAddress2();
$this->billingCity = $address->getCity();
$this->billingState = $address->getState();
$this->billingPostalCode = $address->getPostalCode();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.