• Jason Winter

    (@winternetweb)


    I have successfully been able to select a record after performing a search.

    However, I want to be able to grab the firstname and lastname fields to be entered into WooCommerce so on the order ticket people know the recipient for the order.

    Further, the (hidden) location field I would like passed along in some way on the report, too. Visible on the report, but hidden from the user during checkout (maybe using display:none?)

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author xnau webdesign

    (@xnau)

    The key to doing something like this is the ability to determine the Participants Database record ID to use. I won’t go into too much detail, I don’t know what you’ve done or what your level of expertise is, it will certainly require a facility with using custom php in WordPress, so I assume you know your way around all that stuff.

    First, figure out how you’re going to get your custom values into your WooCommerce form. That will probably be a filter.

    In your filter handler, you will need to determine the record ID to use. Once you’ve got that, you can grab the saved values for that ID using Participants_Db::get_participant($id).

    The location field will probably be a hidden field (so, no need to hide it) in Participants Database (typically, this would be a included in the signup form so that the value is assigned when the user submits that form), but when you grab the record data, it will simply be a value in that data, so you can display it in the WooCommerce form as needed.

    supernova42

    (@supernova42)

    I had a similar problem. The difficulty I had is that the Participants Database Record ID will be totally different to the WordPress ID so I used UserName instead because these two fields will be the same.

    I found that by using php I could achieve so much more within Participants Database and therefore I used the Plugin ‘Insert php’ by Will Bontrager. Remember when you enter the php code you must be in TEXT mode and not VISUAL mode. I initially made that mistake.

    [insert_php]
    $current_user = wp_get_current_user();
    $users_name=$current_user->user_login;
    /*This will give the UserName of the current user*/

    $user_firstname=$current_user->user_firstname
    $user_lastname=$current_user->user_lastname
    /*This will give the first and last names of the current user*/

    echo do_shortcode(‘[pdb_list template=responsive filter=”username=’.$users_name.'” fields=”record_id,first_name,last_name,etc”]’);
    [/insert_php]

    I did actually modify the responsive filter to give me a slightly different layout, but it’s not important at this stage.

    You might have to play around with this to get exactly what you want, but try it out and see how you go.

    Another useful method you could try is

    [insert_php]
    $current_user = wp_get_current_user();
    $user_name=$current_user->user_login;
    $user_id = Participants_Db::get_record_id_by_term(‘username’, $user_name);
    $record = Participants_Db::get_participant( $user_id );
    echo do_shortcode(‘[pdb_record record_id=’.$user_id.’]’);
    [/insert_php]

    Mike Meinz

    (@mikemeinz)

    @supernova42

    I don’t understand how your solution using firstname and lastname would work when there are multiple people with the same firstname and lastname. At my company, there were four people named Tom Johnson.

    supernova42

    (@supernova42)

    The only unique fields are Record_ID and UserName and regardless of how many staff you have with the same name, they will have different UserNames. You can use the above functions to obtain the UserName of the person logged in. Once you have that UserName you can obtain the Record_ID and First_Name, Last_Name etc.

    It’s just a question of modifying the functions to suite your purpose…

    Hello and good day.

    Fantastic plugin. Seems very flexible and powerful.

    The echo do_shortcode statement does not work.

    I keep getting an php T_ECHO error.

    I am simply trying to insert the record ID into a page of any logged in user.

    I h ave also downloaded the older version and the page now displays but only if I omit the opening [insert_php] shortcode. But only the Firstname and Lastname are displayed.

    Seems the shortcode tags are not working.

    Can someone help?

    It seems the newest version of Insert PHP is out.

    • This reply was modified 6 years, 9 months ago by rayeason. Reason: added update
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Grabbing record fields to use in WooCommerce’ is closed to new replies.