Get user address outside hikashop
9 years 2 months ago #274013
by kyratn
Get user address outside hikashop was created by kyratn
Hi,
I am trying to get user address inside easy profile view.
What I want is to show user shipping address street, city, zip and use them to show location on google map....
I have read this topic www.hikashop.com/support/forum/developme...ikashop-address.html and used code below Provided by Nicolas 3 years ago:
Issue is that I get address of wrong user. I think some connection between user id is missing but as I have never done something similar I need help here. Could it be that code has changed after 3 years?
Thanks
I am trying to get user address inside easy profile view.
What I want is to show user shipping address street, city, zip and use them to show location on google map....
I have read this topic www.hikashop.com/support/forum/developme...ikashop-address.html and used code below Provided by Nicolas 3 years ago:
Code:
// Get a db connection.
$db = JFactory::getDbO();
$db->setQuery('SELECT user_id FROM #__hikashop_user WHERE user_cms_id = ' . (int) $userId);
$hikashop_id = $db->loadResult();
$db->setQuery('SELECT * FROM #__hikashop_address WHERE address_user_id =' . (int) $hikashop_id);
$address = $db->loadObject();
//then you can do like that to get the address_street for example:
echo $address->address_street;
Issue is that I get address of wrong user. I think some connection between user id is missing but as I have never done something similar I need help here. Could it be that code has changed after 3 years?
Thanks
Please Log in or Create an account to join the conversation.
9 years 2 months ago #274017
by kyratn
Replied by kyratn on topic Get user address outside hikashop
Please ignore. Found the issue.
Have a great day
Have a great day
Please Log in or Create an account to join the conversation.
9 years 2 months ago - 9 years 2 months ago #274066
by kyratn
Replied by kyratn on topic Get user address outside hikashop
Hi,
It looks like I still need some little help here.
I have customizes profile view and it shows location on google map based on entered address in hikashop address listing...However issue is that if you have 2 or more addresses using "echo $address->address_street;" will give first entered/created address and NOT selected in address listing.
So question. Is it possible to get default selected address using those queries? Else easiest way will be to limit user to have only one address.
Many thanks
It looks like I still need some little help here.
I have customizes profile view and it shows location on google map based on entered address in hikashop address listing...However issue is that if you have 2 or more addresses using "echo $address->address_street;" will give first entered/created address and NOT selected in address listing.
So question. Is it possible to get default selected address using those queries? Else easiest way will be to limit user to have only one address.
Many thanks
Last edit: 9 years 2 months ago by kyratn.
Please Log in or Create an account to join the conversation.
9 years 2 months ago #274071
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 Get user address outside hikashop
Hello,
Regards,
Code:
$query = 'SELECT a.* FROM #__hikashop_address AS a INNER JOIN #__hikashop_user AS u ON a.address_user_id = u.user_id WHERE u.user_cms_id = ' . (int)$userId.' AND a.address_published = 1 AND a.address_default = 1';
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: kyratn
Please Log in or Create an account to join the conversation.
9 years 2 months ago #274106
by kyratn
Replied by kyratn on topic Get user address outside hikashop
Hi,
Thank you Jerome. It really helped.
Gave a great day
Thank you Jerome. It really helped.
Gave a great day
Please Log in or Create an account to join the conversation.
9 years 1 month ago #275989
by vadim_29
Replied by vadim_29 on topic Get user address outside hikashop
Hi,
I am using Google Matrix API to calculate distance between users address and the pre-difined store addresses, include js code inside checkout.php.
I want to appoligize about my english and php skill, im new at both of them.
My idea is to make a popup or similar when the user is about to order, that inform him about a store near his address location, otherwise he will pay the shipping ports.
As you can see on the code i'll send, on the line 714, there are a variable that should get the user address, so that google api could calculate the distance between the locations and return the shortest one.
Thank you!
I am using Google Matrix API to calculate distance between users address and the pre-difined store addresses, include js code inside checkout.php.
I want to appoligize about my english and php skill, im new at both of them.
My idea is to make a popup or similar when the user is about to order, that inform him about a store near his address location, otherwise he will pay the shipping ports.
As you can see on the code i'll send, on the line 714, there are a variable that should get the user address, so that google api could calculate the distance between the locations and return the shortest one.
Thank you!
Please Log in or Create an account to join the conversation.
9 years 1 month ago #275990
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 Get user address outside hikashop
Hello,
Your customization is based on HikaShop 2.6.0 which is an old version of HikaShop.
You should update to a more HikaShop version.
Please do not edit the HikaShop core files such as the controllers.
HikaShop is based on the MVC system of Joomla and gives you the possibility to override every views.
So it will be safer and better to use a view override instead of modifying a core file.
The previous given code allow to load an address object from the database but in your case, you want a formatted address, which implicates the usage of the HikaShop address class to convert an object into a human readable address such as "displayAddress" function or "miniFormat" (but these two functions also need to load the address custom field).
Regards,
Your customization is based on HikaShop 2.6.0 which is an old version of HikaShop.
You should update to a more HikaShop version.
Please do not edit the HikaShop core files such as the controllers.
HikaShop is based on the MVC system of Joomla and gives you the possibility to override every views.
So it will be safer and better to use a view override instead of modifying a core file.
The previous given code allow to load an address object from the database but in your case, you want a formatted address, which implicates the usage of the HikaShop address class to convert an object into a human readable address such as "displayAddress" function or "miniFormat" (but these two functions also need to load the address custom field).
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.
Please Log in or Create an account to join the conversation.
9 years 1 month ago #276100
by vadim_29
Replied by vadim_29 on topic Get user address outside hikashop
Hi Jerome,
Thank you for the warning about core files, such checkout.php. When you said that i should override the view(s), you mean files like address_view.php on this path ./components/com_hikashop/views/checkout/tmpl ? ill send you the example.
Sorry again, php is not my strongest. I really need help to finish this.
Thank you for all the support.
Thank you for the warning about core files, such checkout.php. When you said that i should override the view(s), you mean files like address_view.php on this path ./components/com_hikashop/views/checkout/tmpl ? ill send you the example.
Sorry again, php is not my strongest. I really need help to finish this.
Thank you for all the support.
Please Log in or Create an account to join the conversation.
9 years 1 month ago #276101
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 Get user address outside hikashop
Hello,
I mean using the view override system provided by Joomla MVC system.
www.hikashop.com/support/documentation/1...-display.html#layout
Regards,
I mean using the view override system provided by Joomla MVC system.
www.hikashop.com/support/documentation/1...-display.html#layout
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: vadim_29
Please Log in or Create an account to join the conversation.
9 years 1 month ago #276166
by vadim_29
Replied by vadim_29 on topic Get user address outside hikashop
Hi Gerome,
Thank you so much, you are a life saver. Following your wisdom, i managed to get the correct user address.
Thank you so much, you are a life saver. Following your wisdom, i managed to get the correct user address.
The following user(s) said Thank You: Jerome
Please Log in or Create an account to join the conversation.
Time to create page: 0.249 seconds