AccountPage_Controller::deleteaddress PHP Method

deleteaddress() public method

public deleteaddress ( SS_HTTPRequest $req ) : SS_HTTPResponse
$req SS_HTTPRequest
return SS_HTTPResponse
    function deleteaddress($req)
    {
        // NOTE: we don't want to fully delete the address because it's presumably still
        // attached to an order. Setting MemberID to 0 means it won't show up in the address
        // book any longer.
        $address = $this->member->AddressBook()->byID($req->param('ID'));
        if ($address) {
            $address->MemberID = 0;
            $address->write();
        } else {
            $this->httpError(404, 'Address not found');
        }
        return $this->redirectBack();
    }