- Posts: 127
- Thank you received: 6
Adding default Billing Address to User Listing
7 years 9 months ago #301441
by Bobwales
Adding default Billing Address to User Listing was created by Bobwales
-- 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...
-- 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.
7 years 9 months ago #301442
by nicolas
Replied by nicolas on topic Adding default Billing Address to User Listing
Hi,
The users' address is not loaded on the users listing.
You you would have to do something like that:
The users' address is not loaded on the users listing.
You you would have to do something like that:
Code:
$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.
7 years 9 months ago - 7 years 9 months ago #301470
by Bobwales
Replied by Bobwales on topic Adding default Billing Address to User Listing
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...
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...
Last edit: 7 years 9 months ago by Bobwales.
Please Log in or Create an account to join the conversation.
7 years 9 months ago #301474
by nicolas
Replied by nicolas on topic Adding default Billing Address to User Listing
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.
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.
7 years 9 months ago #301517
by Bobwales
Replied by Bobwales on topic Adding default Billing Address to User Listing
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.
$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.
7 years 9 months ago - 7 years 9 months ago #301527
by nicolas
Replied by nicolas on topic Adding default Billing Address to User Listing
No, I meant this:
It won't work without the reset.
Code:
$addressClass = hikashop_get('class.address');
$addresses = $addressClass->getByUser($row->user_id);
echo reset($addresses)->address_city;
Last edit: 7 years 9 months ago by nicolas.
Please Log in or Create an account to join the conversation.
7 years 9 months ago #301545
by Bobwales
Replied by Bobwales on topic Adding default Billing Address to User Listing
Thank you so much Nicolas!
Once again, superb support and tolerance of an idiot at this end.
Much appreciated and much learned!
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.
7 years 9 months ago #301655
by Bobwales
Replied by Bobwales on topic Adding default Billing Address to User Listing
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:
How can I add that to the search?
To search include the address_post_code would be very useful.
At the moment for that table cell the code is:
Code:
<td><?php
$addressClass = hikashop_get('class.address');
$addresses = $addressClass->getByUser($row->user_id);
echo reset($addresses)->address_post_code;
?>
</td>
Please Log in or Create an account to join the conversation.
7 years 9 months ago #301664
by Jerome
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.
Replied by Jerome on topic Adding default Billing Address to User Listing
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,
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.
7 years 9 months ago - 7 years 9 months ago #301759
by Bobwales
Replied by Bobwales on topic Adding default Billing Address to User Listing
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.
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
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.
Code:
.....
<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: 7 years 9 months ago by Bobwales.
Please Log in or Create an account to join the conversation.
Time to create page: 0.220 seconds