Adding default Billing Address to User Listing

  • Posts: 127
  • Thank you received: 6
5 years 4 months ago #301441

-- HikaShop version -- : 4.01
-- Joomla version -- : 3.6.5
-- PHP version -- : 7

To help identify customers when they call us it would be useful to see Post Codes (or some part of their address) on our back-end User Listing. We could then more quickly find which "Mr Smith" (who has forgotten their username or email address) for instance.

To do this I guess I need to adapt the file listing.php in view user.
Is there any simple way to show the default billing post code for a user?

Something as easy as <?php echo $row->user_email; ?> but for Town, City or Post Code instead?

That would be really helpful, but I bet not quite that simple...

Please Log in or Create an account to join the conversation.

  • Posts: 81484
  • Thank you received: 13062
  • MODERATOR
5 years 4 months ago #301442

Hi,

The users' address is not loaded on the users listing.
You you would have to do something like that:

$addressClass = hikashop_get('class.address');
$addresses = $addressClass->get($row->user_id);
echo reset($addresses)->address_city;

The following user(s) said Thank You: Bobwales

Please Log in or Create an account to join the conversation.

  • Posts: 127
  • Thank you received: 6
5 years 4 months ago #301470

That's a big help Nicolas, Thank you.

I squeezed in an extra column (etc) and added...
<td><?php
$addressClass = hikashop_get('class.address');
$addresses = $addressClass->get($row->user_id);
echo $addresses->address_post_code;
?>
</td>
Not sure why reset() was suggested - I did need to remove that for anything to show.
But the postcodes shown are not those of each user - often a postcode of the previous user shows instead.

If you have a little time attached is my complete file - I can't see where the loop doesn't pick up the correct user...

Attachments:
Last edit: 5 years 4 months ago by Bobwales.

Please Log in or Create an account to join the conversation.

  • Posts: 81484
  • Thank you received: 13062
  • MODERATOR
5 years 4 months ago #301474

Hi,

What you did won't work.
What you did will load the address with its address_id equal to the user_id of the user.
So while you're still loading an address, you're not loading the address of the customer you're looking at, unless you'll lucky and the id is the same, which should be quite uncommon.

However, I can see I made a mistake in the code I gave you. It should by "getByUser" instead of "get". I suppose that's why you got confused. Sorry.

Please Log in or Create an account to join the conversation.

  • Posts: 127
  • Thank you received: 6
5 years 4 months ago #301517

Appreciated Nicolas - do you mean like this?

$addressClass = hikashop_get('class.address');
$addresses = $addressClass->getByUser($row->user_id);
echo $addresses->address_post_code;

Unfortunately that doesn't work.

Please Log in or Create an account to join the conversation.

  • Posts: 81484
  • Thank you received: 13062
  • MODERATOR
5 years 4 months ago #301527

No, I meant this:

$addressClass = hikashop_get('class.address');
$addresses = $addressClass->getByUser($row->user_id);
echo reset($addresses)->address_city;
It won't work without the reset.

Last edit: 5 years 4 months ago by nicolas.

Please Log in or Create an account to join the conversation.

  • Posts: 127
  • Thank you received: 6
5 years 4 months ago #301545

Thank you so much Nicolas!
Once again, superb support and tolerance of an idiot at this end.
Much appreciated and much learned! :)

Please Log in or Create an account to join the conversation.

  • Posts: 127
  • Thank you received: 6
5 years 4 months ago #301655

It would be even more useful to add this extra address column to the array for search, on this override. But I am unsure how to do that.

To search include the address_post_code would be very useful.

At the moment for that table cell the code is:

<td><?php 
				$addressClass = hikashop_get('class.address');
				$addresses = $addressClass->getByUser($row->user_id);
				echo reset($addresses)->address_post_code;
				?>
           </td>
How can I add that to the search?

Please Log in or Create an account to join the conversation.

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
5 years 4 months ago #301664

Hello,

To add it to the search, best would require the modification of core files.
Unfortunately that is not recommended because you will loose your modification by updating HikaShop.
Another solution would be to copy a part of the code in the "view.html.php" into the listing view in order to re-perform the loading of the user list with extra elements for the search fields (and an extra loaded table in the main query).
It would require some time and development ; it is not something we can do within few minutes and paste few lines in the forum.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: Bobwales

Please Log in or Create an account to join the conversation.

  • Posts: 127
  • Thank you received: 6
5 years 4 months ago #301759

Merci Jerome
That looks beyond me, unless I find a darkened room for a couple of days!

I had hoped that adding strings for search happens on the Table Header rows during $this->pageinfo->filter->...etc statement.
But I recognise my naivety. Thanks for looking.

.....
  <th class="title"><?php echo JHTML::_('grid.sort', JText::_('HIKA_EMAIL'), 'huser.user_email', $this->pageInfo->filter->order->dir, $this->pageInfo->filter->order->value); ?></th>

<?php // extra info added BW Dec 18 ?>
  <th class="title"><?php	echo JHTML::_('grid.sort', 'Postcode', '', $this->pageInfo->filter->order->dir, $this->pageInfo->filter->order->value); ?></th>

I will try to find some time as it would be a useful feature for us at Juicy Bikes - thanks for your pointer.
KR
Bob

Last edit: 5 years 4 months ago by Bobwales.

Please Log in or Create an account to join the conversation.

Time to create page: 0.071 seconds
Powered by Kunena Forum