Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using WordPress E-Commerce (get shopped) and would like to get a list of items that a user has purchased, just a list of post IDs would be perfect. Is there any way for me to get this?

It must be stored somewhere.. has anyone attempted this before?

share|improve this question

closed as off-topic by Pieter Goosen, gmazzap, cybmeta, kaiser Nov 22 '14 at 8:45

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

2 Answers 2

Query the table wp_wpsc_purchase_logs, it contains all information about previous purchases.

add this to your themes functions.php:

Get purchased articles by user_id or for the current user
function haet_recently_bought_articles($user_id=0){

    //only if there is an active user, otherwise we would get all purchased items from unregistered users
    if($user_id>0) {
        global $wpdb;
        $sql = $wpdb->prepare("
                SELECT prodid, name, price
                FROM `".$wpdb->prefix."wpsc_cart_contents` 
                INNER JOIN `".$wpdb->prefix."wpsc_purchase_logs` ON purchaseid = ".$wpdb->prefix."
                WHERE  user_ID = %d
                ORDER BY date DESC"
        $items = $wpdb->get_results($sql,ARRAY_A);
        return $items;
    return null;

and add the following lines to the template to show the products e.g. page-.php

<ul class="articles">
    $articles = haet_recently_bought_articles();
    foreach($articles AS $article){
        echo '<li>'.$article['name'].'</li>';
share|improve this answer
An example would probably be useful. – toscho Apr 30 '13 at 20:20
global $wpsc_cart;  

This is the global variable , looping through this will get all the info ie products added in cart by user, just do

 print_r( $wpsc_cart; )

and you will come to know.

share|improve this answer
That's not quite what I'm after. I'm looking for a full list of purchases, not just what's in the cart right now. – Matt Potts Apr 13 '12 at 11:17
Shopping Cart Settings in admin presentation check <?php echo wpsc_shopping_cart(); ?> ) this gives shopping cart. – amolv Apr 13 '12 at 12:43
Sorry, the shopping cart isn't what I'm after. I'm after a full list of all product IDs that have been purchased by the logged in user – Matt Potts Apr 13 '12 at 13:23
Shopping cart is nothing but list of all product purchased by logged in user, but why do need only product ids of product purchased by logged in user? – amolv Apr 13 '12 at 13:50
I'm trying to find out what products a user has bought preivously. – Matt Potts Apr 14 '12 at 13:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.