Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

How do I use new functions in admin


Recommended Posts

tep_address_label is available in the /catalog/includes/functions/general.php

How do I make that function available to the admin section?



I am working on an add-on "Mail Manager", and I'm trying to get the tep_address_label function available to the "Order Editor" add-on.

This is sort of combining two add-ons.


What I have so far...

$billing_address = "\n" . $order->billing['name'] . "<br />";
	if ($order->billing['company']) {
		  	$billing_address .= $order->billing['company'] . "<br />";
	 $billing_address .= $order->billing['street_address'] . "<br />";
	if ($order->billing['suburb']) {
				$billing_address .= $order->billing['suburb'] . ", ";
	if ($order->billing['state']) {
		  	$billing_address .= $order->billing['state'] . " ";
	$billing_address .= $order->billing['postcode'] . "<br />" . $order->billing['country'] . "<br>";
$delivery_address = "\n" . $order->delivery['name'] . "<br />";
	if ($order->delivery['company']) {
		  	$delivery_address .= $order->delivery['company'] . "<br />";
	 $billing_address .= $order->delivery['street_address'] . "<br />";
	if ($order->delivery['suburb']) {
				$delivery_address .= $order->delivery['suburb'] . ", ";
	if ($order->delivery['state']) {
		  	$delivery_address .= $order->delivery['state'] . " ";
	$delivery_address .= $order->delivery['postcode'] . "<br />" . $order->delivery['country'] . "<br>";

$order_comments = $order->info['comments'];
$paymentmethod = $order->info['payment_method'];
$ccardtype = $order->info['cc_type'];
$payment_class = $payment_class->email_footer;

I want to replace this with

$delivery_address = tep_address_label($customer_id, $sendto, 0, '', '<br />');
$billing_address = tep_address_label($customer_id, $billto, 0, '', '<br />');
$order_comments = $order->info['comments'];
$paymentmethod = $order->info['payment_method'];
$ccardtype = $order->info['cc_type'];
$payment_class = $payment_class->email_footer;

I am sure that the order_editor needs to be updated as well for this, but I am new to coding and I'm just trying to wrap my head around how all of this works.


This is the email function that calls the Mail Manager module. I tried to retain the standaard text email as much as I could.



Link to comment
Share on other sites

I've added the function to my admin/includes/functions/general.php

// Return a formatted address
// TABLES: customers, address_book
  function tep_address_label($customers_id, $address_id = 1, $html = false, $boln = '', $eoln = "\n") {
    if (is_array($address_id) && !empty($address_id)) {
      return tep_address_format($address_id['address_format_id'], $address_id, $html, $boln, $eoln);

    $address_query = tep_db_query("select entry_firstname as firstname, entry_lastname as lastname, entry_company as company, entry_street_address as street_address, entry_suburb as suburb, entry_city as city, entry_postcode as postcode, entry_state as state, entry_zone_id as zone_id, entry_country_id as country_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customers_id . "' and address_book_id = '" . (int)$address_id . "'");
    $address = tep_db_fetch_array($address_query);

    $format_id = tep_get_address_format_id($address['country_id']);

    return tep_address_format($format_id, $address, $html, $boln, $eoln);

I've called it like such

$delivery_address = tep_address_label($customer_id, $sendto, 0, '', '<br />');

The problem is now the $customer_id

The address is blank or NULL. How do I set the $customer_id from the orders page?

The $customer_id is in the "orders" table, but I don't know how to set it.


Or should I just leave it the way that I showed before? I don't know what is best practice. It's possible to have different shipping address on each order, that is not in the address book.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...