Hello,
/************* PROBLEM **********************/
I bumped into this post recently because I was in need of something similar to what you are looking. Let me tell you what was my problem.
I am working on a site that is only able to deliver to a list of zipcodes. I had already managed to restrict the zipcodes that can be entered whenever an account is created or whenever a user wants to add a new addres to their address book.
However I did not want this restriction on the billing address step since I want customers to be able to pay with cards that are registered under any zip code. I managed to make this restriction not to apply whenever the user wanted to change the billing address since this one is used in order to accept card payments.
The problem was that when a user enters their billing address it automatically saves itself into the users address book. This was a conflict for me because I did not want users to have an address in their address book with a zip code or address overall that was outside that list I mentioned before.
I found two solutions for my problem but one of them could not be implemented due to my hosting service. However the second solution is fit to be implemented on any server.
/********** SOLUTION*******************/
In case you don't want to read all that.
1: Create a trigger on the database after an insert on orders table.
2: Execute statement in a php statement.
In my case I opted for the second solution since my hosting service did not allowed the creation of triggers in their databases for several reasons.
The file which I decided to modify is uner the following folder structure:
zen_cart_root_folder/includes/templates/template_default/templates/tpl_checkout_success_default.php
I went all the way down on the source file and added the following lines.
<?php
$db->Execute("DELETE FROM orders WHERE entry_postcode NOT IN (SELECT postcode FROM my_postcode_table_I_added_to_db)");
?>
There is one flaw with this solution though. There is a possibility that after the user adds the new address that has no restriction he may go back and change the delivery address to the one which is momentarily saved in his address book. I oversaw this flaw since it is not very likely that a user would go back at such moment and reset the delivery address one more time. Besides this whenever any user gets an order placed this statement is ran and all the unwanted addresses in every user account is cleaned away.
The good thing is that the billing address is saved in the orders table so this solution does not corrupt the zencart admin site invoice and orders functionality.
There are many other grounds on which such addresses can be deleted so this deletion solution can be applied in other grounds.
This was the closest post I came across when first trying to look for a solution but nothing was available.
Hope it helps.