Author Topic: Using core fields  (Read 668 times)

Offline limessl

  • Sr. Member
  • ****
  • Posts: 82
    • View Profile
Using core fields
« on: 06/February/2010, 02:34:07 PM »
I'd like to pre-populate some fields by using the values stored in some of the core profile fields (first name, last name, phone, email).

What's the code for retrieving the values stored in those?

Offline netshine

  • Administrator
  • Hero Member
  • *****
  • Posts: 4,959
    • View Profile
Re: Using core fields
« Reply #1 on: 07/February/2010, 10:30:52 AM »
Have you tried this?

$$return nbf_common::get_param($_POST, 'ctl_NBILL_CORE_first_name');$$

Offline limessl

  • Sr. Member
  • ****
  • Posts: 82
    • View Profile
Re: Using core fields
« Reply #2 on: 16/February/2010, 04:14:18 PM »
I should have figured that one out.

Next Q - whilst an order is in the process of being created, is it allocated any sort of id code, and if so is it possible to get hold of it? I know pending orders are given an ID, but the information is being stored prior to the form being submitted.

The alternative would be for me to simply get the user's client ID or some other unique identifier from his record.

Offline netshine

  • Administrator
  • Hero Member
  • *****
  • Posts: 4,959
    • View Profile
Re: Using core fields
« Reply #3 on: 16/February/2010, 07:31:21 PM »
No information is stored until after the form is submitted, when a pending record is created (if pending until paid is switched on), or a live order is created (if pending until paid is off). In the meantime, all the data is all posted back and forth on the form itself.

Offline limessl

  • Sr. Member
  • ****
  • Posts: 82
    • View Profile
Re: Using core fields
« Reply #4 on: 19/February/2010, 07:34:05 PM »
Have you tried this?

$$return nbf_common::get_param($_POST, 'ctl_NBILL_CORE_first_name');$$

I think the flaw here is that if someone has logged in prior to opening the order form then there is no value in that field, as it's already stored in their profile. What I therefore need is a way of retrieving their details from their profile and being able to use those.

Offline netshine

  • Administrator
  • Hero Member
  • *****
  • Posts: 4,959
    • View Profile
Re: Using core fields
« Reply #5 on: 20/February/2010, 08:58:02 AM »
You could try this:

$$if (intval(nbf_cms::$interop->user->id){$sql="SELECT name FROM #__nbill_contact WHERE user_id = " . intval(nbf_cms::$interop->user->id);nbf_cms::$interop->database->setQuery($sql);return nbf_cms::$interop->database->loadResult();}else{return nbf_common::get_param($_POST, 'ctl_NBILL_CORE_first_name') . ' ' . nbf_common::get_param($_POST, 'ctl_NBILL_CORE_last_name');}$$

Splitting first and last name could be more difficult though as they are not stored separately in the database.

 

anything