Here's the code fragment from my Multiple Ship-To Addresses plugin that builds up the dropdown list input:
Code:
$addresses = $db->Execute("SELECT address_book_id FROM " . TABLE_ADDRESS_BOOK . " WHERE customers_id = " . (int)$_SESSION['customer_id']);
if ($addresses->EOF) {
zen_redirect(zen_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'));
}
$multishipAddresses = array();
while(!$addresses->EOF) {
$multishipAddresses[] = array ( 'id' => $addresses->fields['address_book_id'],
'text' => str_replace("\n", ', ', zen_address_label($_SESSION['customer_id'], $addresses->fields['address_book_id']))
);
$addresses->MoveNext();
}
Then, you use the built-in Zen Cart function to display the dropdown:
Code:
echo zen_draw_pull_down_menu('address[]', $multishipAddresses);
Bookmarks