ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Showing Purchases from SCM on A Profile Page

October 31, 2010 9:53am

Subscribe [2]
  • #1 / Oct 31, 2010 9:53am

    Okapi Creative

    384 posts

    Got as far as being able to display all the purchases from the SCM on a custom profile page but can’t pare it down to the logged in user.

    Am using this following code courtesy of Andre Weaver in this thread but can’t get it to work showing the items of only the logged in member.

    SELECT p.purchase_id, 
                p.member_id, 
                p.item_id,
                p.purchase_date, 
                p.item_cost, 
                p.paypal_details, 
                t.entry_id, 
                t.title, 
                t.url_title, 
                t.status 
    FROM exp_simple_commerce_purchases p 
    INNER JOIN exp_simple_commerce_items i ON p.item_id = i.item_id
    INNER JOIN exp_channel_titles t ON i.entry_id = t.entry_id
    WHERE p.member_id = 1;

    Obviously can’t show the logged-in member ID variable on the last line and tried a few solutions from the forums but no luck…anyone able to help?

  • #2 / Oct 31, 2010 10:03am

    Okapi Creative

    384 posts

    Ok…got a bit further but still not working. I have this now at top of template:

    <?php
    global $SESS;
    $member_id = $SESS->userdata['member_id'];
    ?>

    And am using this in the query:

    WHERE p.member_id = '<?php echo $member_id; ?>'

    Getting this error:

    A PHP Error was encountered
    Severity: Notice

    Message: Trying to get property of non-object

    Filename: libraries/Functions.php(650) : eval()‘d code

    Line Number: 3

  • #3 / Nov 01, 2010 5:21am

    John Henry Donovan

    12339 posts

    tarquin,

    This thread is more appropriate to the CodeShare Corner so moving it there.

    The Session Class syntax is different for EE2.x. Try the following

    <?php
    $member_id = $this->EE->session->userdata['member_id'];
    ?>
  • #4 / Nov 01, 2010 5:24am

    Okapi Creative

    384 posts

    Oops…sorry John!


    Cheers…didn’t realize that! Will try it now!

    Thanks!!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases