1

A specific user group on my website has the ability to create products on my website. This is all done using Channel Form tags. Unregistered guests may purchase these products.

For the user group that creates these products, I need to create a widget that shows how many of their created products have been sold so far. But I am not sure what template tags would best suit my purposes.

EDIT

So after looking around the database, I found there are 3 tables necessary to create the query I want

FIND THE INTERSECTION OF THESE TWO TABLES

exp_channel_data - to filter the entries to the specific product channel (i.e. channel_id = 15). exp_channel_titles - to further filter the product channel entries by author ID (i.e. author_id = CURRENT_USER)

THEN FIND THE SUM OF THE ITEM TOTALS OF THE SUBSEQUENT RESULTS

exp_store_order_items - this is where I'd presumably use a SQL statement not very dissimilar from the one Justin Long provided me:

{if logged_in_member_group == 1}
    {exp:query sql='SELECT SUM(item_qty) as totalSales FROM exp_store_order_items WHERE entry_id = {entry_id}'}
        {totalSales}
    {/exp:query}
{/if}
1

There is not going to be an actual Store tag that you could use to get this. Having said that it should be fairly simple to query the DB for the information that you need. Something along the lines of:

{if logged_in_member_group == 1}
    {exp:query sql='SELECT SUM(item_qty) as totalSales FROM exp_store_order_items WHERE entry_id = {entry_id}'}
        {totalSales}
    {/exp:query}
{/if}

This assumes the group id of the group you want to have access to it is 1 and the query is placed within the parent channel entries tag as we are using the entry_id to only show the results for that product. You might need to adjust it to your needs.

|improve this answer|||||
  • This is great and definitely in the direction of what I am looking for. Since my SQL is not that great, I just need a little bit more info if you don't mind. I'll add it to my question. – Caleb Faruki Nov 11 '15 at 16:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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