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.

Simple Commerce Purchase Download Page

January 23, 2012 11:57am

Subscribe [1]
  • #1 / Jan 23, 2012 11:57am

    morethanfire

    9 posts

    Is there a better way to gather all the Simple Commerce Items “entry_id” based off the Simple Commerce Purchases? Right now i have the code below and it works a little, but i cannot figure out why it is duplicating them.

    {exp:query sql="SELECT DISTINCT exp_simple_commerce_purchases.item_id, exp_simple_commerce_items.entry_id FROM exp_simple_commerce_purchases, exp_simple_commerce_items WHERE member_id = '{member_id}' AND exp_simple_commerce_items.item_id"}
     {entry_id}
    {/exp:query}

    Code above will write: “7 7 9 9 10 10”. If i am to just write out “SELECT” and not “SELECT DISTINCT” it shows them as ” 7 7 7 9 9 9 10 10 10” Is there a way to get display it as “7|9|10”? What I am trying do is have a download section for the logged in member and it show all his/her downloads.

  • #2 / Jan 23, 2012 3:54pm

    morethanfire

    9 posts

    I figured it all out. I guess sleep does work. Query that worked in my favor is below.

    SELECT DISTINCT a.item_id, b.item_id, b.entry_id 
    FROM exp_simple_commerce_purchases a 
    INNER JOIN exp_simple_commerce_items b ON  a.item_id = b.item_id
    WHERE a.member_id = '{member_id}'

     

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

ExpressionEngine News!

#eecms, #events, #releases