• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Pre-Populate Text Field with HikaShop Company Name

Pre-Populate Text Field with HikaShop Company Name 10 years 10 months ago #28096

  • contact13
  • contact13's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 30
  • Thank you received: 5
Not sure what I'm doing wrong here... I'd like to populate a logged in user's Company Name Text Field based off of the user's Company Name in the hikashop_address table. I'm getting the following error:

"Parse error: syntax error, unexpected T_STRING in /.../administrator/components/com_rsform/helpers/rsform.php(568) : eval()'d code on line 9"

I feel certain it's an issue with how I'm using the second query in the following code. Any help correcting the query would be greatly appreciated!
//<code>
$user   = JFactory::getUser();
$db   = JFactory::getDbo();
$userId  = $user->get('id');
 
// Is the user logged in? rw1869
if ($userId) {
  // Grab the value from the database.
    $db->setQuery("SELECT `address_company` FROM `#__hikashop_address` WHERE `address_user_id`=("SELECT `user_id` FROM `#__hikashop_user` WHERE `user_cms_id` = '".$userId."'";));
    return $db->loadResult();
}
//</code>
The administrator has disabled public write access.

Pre-Populate Text Field with HikaShop Company Name 10 years 10 months ago #28099

  • alexp
  • alexp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 2253
  • Thank you received: 180
There is indeed a syntax error within your query. I am not quite sure about the hikashop table structure, but you could try the following query instead:
$db->setQuery("SELECT ha.address_company FROM #__hikashop_address ha LEFT JOIN #__hikashop_user hu ON ha.address_user_id=hu.user_cms_id WHERE hu.user_cms_id = '".$userId."' LIMIT 1");

For more details on this i think it would be best to contact the hikashop support.
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
Last Edit: 10 years 10 months ago by alexp.
The administrator has disabled public write access.
The following user(s) said Thank You: contact13

Pre-Populate Text Field with HikaShop Company Name 10 years 10 months ago #28101

  • contact13
  • contact13's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 30
  • Thank you received: 5
Thanks for your help.

That did indeed get rid of the error. I'm not getting the result back that I want- but it did get rid of the error. I'll play around with the DB tables a little bit and perhaps post back some screen shots in case it ever helps someone else.

I really appreciate your feedback.
The administrator has disabled public write access.

Pre-Populate Text Field with HikaShop Company Name 10 years 10 months ago #28103

  • contact13
  • contact13's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 30
  • Thank you received: 5
Alright- I put together some screen shots. I recognize that this is halfway a HikaShop question, so I really understand if no one is willing to help me, but I am trying to populate the fields for RSForm Pro, so I thought it might help others as well. In the below screen shots I have outlined the problem I'm facing.

I want to return the company name from #__hikashop_address based off the User ID of the logged in user. However, Hikashop apparently uses its own id as well, so it needs either two queries or a joining of the tables... See below.

If anyone wants to help- that'd be great. I would certainly appreciate it, and I'm sure someone else at some point would as well. I don't think it'll be that impossible for someone smarter than me, but my brain is maxed out at this point.





Thanks in advance.
The administrator has disabled public write access.

Pre-Populate Text Field with HikaShop Company Name 10 years 10 months ago #28121

  • contact13
  • contact13's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 30
  • Thank you received: 5
No one wants to take this on? I think a query joining the two tables would do it... Just need a little help on that query. I think the query supplied by alexp above gets us close.
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!