• Resolved MistaDan

    (@mistadan)


    Hi,
    I need to display company name from the address array built from the user’s profile fields. I need to display the company name in the customer-pages-contextual-toolbar.template.php. I have poured over the forum and google and can’t find anything of use. I would think it should be relatively easy, but the way it is called in account-view-address.template.php doesn’t make sense to me. How does one access this data?

    Thanks

    • This topic was modified 8 years, 1 month ago by MistaDan.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter MistaDan

    (@mistadan)

    Not sure if there was an easier way, but I ended up sticking this at the top of customer-pages-contextual-toolbar.template.php (for anyone else who might want to do this).

    <?php $address = new CUAR_AddressesAddOn; ?>
    <?php $current_user = wp_get_current_user(); ?>
    <?php $address_id = $address->get_registered_user_addresses(); ?>
    <?php $address_id = array_keys( $address_id ); ?>
    <?php $address = $address->get_owner_address('usr', array($current_user->ID), $address_id[0]); ?>

    and then get the company from the resulting array

    $address['company']

    NOTE: Concerning $address_id, I ditched business address, so I only have one address id to deal with.

    • This reply was modified 8 years, 1 month ago by MistaDan.
    • This reply was modified 8 years, 1 month ago by MistaDan.
    Plugin Contributor Vincent Mimoun-Prat

    (@vprat)

    Here is a shorter way to get the current user address:

    <?php
    $ad_addon = cuar_addon('address-manager');
    $address = $ad_addon->$this->get_owner_address('usr', array(get_current_user_id(), CUAR_AddressHelper::$DEFAULT_HOME_ADDRESS_ID);
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display Address’ is closed to new replies.