Author Topic: Item Purchase Logs?  (Read 5014 times)

Spider-k

  • Guest
Item Purchase Logs?
« on: May 14, 2007, 07:37:28 pm »
Hello. I love the SMFShop mod, and I would really love it if there was some sort of log which shows you who bought what, for Admins, so they could see which users bought items, even after they were used out.
Thanks in advance!

Offline Basil Beard

Re: Item Purchase Logs?
« Reply #1 on: June 06, 2007, 01:02:56 am »
Creating a log is pretty easy. Printing it is a little harder, but to create a log just create a db table called

{whatever your db_prefix is}, probably smf_, shop_logs

(so if it is smf_ it would be smf_shop_logs)

the table should have log_id(an int) user_id(an int) item_id(an int) and date(an int)

then find this part of code

Code: [Select]
else

{

mysql_free_result($result);



// Put item in user's inventory

db_query("

INSERT INTO {$db_prefix}shop_inventory

(ownerid, itemid, amtpaid)

VALUES (

{$ID_MEMBER},

{$_GET['id']},

{$row['price']})", __FILE__, __LINE__);



// Decrease user's money

db_query("

UPDATE {$db_prefix}members

SET money = money - {$row['price']}

WHERE ID_MEMBER = {$ID_MEMBER}

LIMIT 1",

__FILE__, __LINE__);



// Decrease stock by 1

db_query("

UPDATE {$db_prefix}shop_items

SET stock = stock - 1

WHERE id = {$_GET['id']}

LIMIT 1", __FILE__, __LINE__);



and add
Code: [Select]
                $date = date('mdHi');
db_query("
INSERT INTO {$db_prefix}shop_logs
     (owner_id, item_id, date)
                        VALUES
                             ({$ID_MEMBER}, {$_GET['id']}, {$date})
", __FILE__, __LINE__);

that should work. You can then access logs through phpmyadmin or write code to accomplish it for you,
Arrrrr!

Offline perplexed

Re: Item Purchase Logs?
« Reply #2 on: June 20, 2007, 07:20:49 am »
is this likely to be a feature in the next shop release?
Estne volumen in toga, an solum tibi libet me videre?

Offline Hamyrenz

Re: Item Purchase Logs?
« Reply #3 on: November 19, 2009, 11:00:21 am »
I don't have no encountered regarding with creating a log but on the printing I was very confused.


_________________
clothing label

Offline DracoGuard

Re: Item Purchase Logs?
« Reply #4 on: December 05, 2009, 04:02:26 pm »
why so many line spaces in your code post? :P  I hate reading code several pages down when it can be compressed to just a few lines.

Doesn't this work here?
Quote from: Basil Beard & Edited by: DracoGuard
Code: [Select]
else
{
mysql_free_result($result);
// Put item in user's inventory
db_query("
INSERT INTO {$db_prefix}shop_inventory
(ownerid, itemid, amtpaid)
VALUES (
{$ID_MEMBER},
{$_GET['id']},
{$row['price']})", __FILE__, __LINE__);
// Decrease user's money
db_query("
UPDATE {$db_prefix}members
SET money = money - {$row['price']}
WHERE ID_MEMBER = {$ID_MEMBER}
LIMIT 1", __FILE__, __LINE__);
// Decrease stock by 1
db_query("
UPDATE {$db_prefix}shop_items
SET stock = stock - 1
WHERE id = {$_GET['id']}
LIMIT 1", __FILE__, __LINE__);