Auctions are able to be viewed after they are closed
Archived from the Web Auction Discussion forum.
josiah — Wed Oct 03, 2007 7:04 am
My auctions are able to be seen by users (not bid on) after they are closed. Is there a way to make it so they are invisible to users (but not admins) once they are closed?
shannah — Fri Oct 05, 2007 11:52 am
The current version doesn’t do this, however some small changes would allow this to happen.
- In the tables/products/fields.ini file, change the first line from
__sql__=”select p.*,current_high_bid from products p left join (select product_id,max(bid_amount) as current_high_bid from bids group by product_id) as b on p.product_id=b.product_id”
to
__sql__=”select p.*,current_high_bid, c.close_date from products p left join (select product_id,max(bid_amount) as current_high_bid from bids group by product_id) as b on p.product_id=b.product_id left join closed c on p.product_id=c.product_id”
(i.e. we are adding a caculated field close_date to the products table).
- In the tables/products/products.php file, find the block__result_list method. It will look like:
- Code: Select all
function block__result_list(){ if ( isAdmin() ) return PEAR::raiseError("Just show the default list"); $app =& Dataface_Application::getInstance(); $query =& $app->getQuery(); $products = df_get_records_array('products', $query); df_display(array('products'=>&$products), 'public_product_list.html'); }
Add a line:
- Code: Select all
$query['close_date'] = '>';
SO that it becomes:
- Code: Select all
function block__result_list(){ if ( isAdmin() ) return PEAR::raiseError("Just show the default list"); $app =& Dataface_Application::getInstance(); $query =& $app->getQuery(); $query['close_date'] = '>'; $products = df_get_records_array('products', $query); df_display(array('products'=>&$products), 'public_product_list.html'); }
This will make it so that average users will only see the auctions that are not closed yet. The admins will still see all auctions.
-Steve
duane — Sun Oct 07, 2007 7:21 pm
I did exactly as above and closed products are still displayed to users. Any advice?
duane — Sun Oct 07, 2007 7:41 pm
OOPS… I hadn’t created the close_date field in the products table. As soon as I did it all worked. Thank you!
shannah — Mon Oct 08, 2007 9:57 am
Actually I made a mistake with this source code. The line
- Code: Select all
$query['close_date'] = '>';
should have been
- Code: Select all
$query['close_date'] = '=';
The previous version probably showed only the closed auctions, rather than the unclosed auctions.
-Steve
rosekolodny — Sat Feb 07, 2009 11:38 pm
Hey. Steve -
I tried this, and the result was that some of my users could not successfully complete an auction. They received a winning email with the correct product name, but a price of $0.00. And then when I would go view reports, the winner field was blank, and the bid amount field was 0. Oh! Heartache! This behavior was fixed as soon as I restored the _sql_ bit in the fields.ini file to original.
Of course, I will keep testing, as my project needs to be working 100% ASAP. : )
Thanks for your time and hard work!
shannah — Mon Feb 09, 2009 12:12 am
Yes.. the __sql__ bit is crucial. Make sure you used a left join (no inner joins). I haven’t tested out the mods in this post personally but I can’t see any problem with them. Please confirm that your changes to the __sql__ field were exactly as in the post .
-Steve
rosekolodny — Mon Feb 09, 2009 4:38 pm
My changes were cut and pasted, so I’m pretty dang sure they were identical. It took me a long time to track down the problem, and I don’t understand WHY this was the issue, but everything went back to normal as soon as I changed it back.
This is what I do know -
1.View_product.html would display fine, so that means that the field high_bid_amount was OK.
2.Reports were not fine, and reports.php is looking for bid_amount.
- Winner’s email was not fine, and the email sending part of functions.inc.php is looking for bid_amount.
So, something got goofed up when bid_amount was calculated. I guess. This has been a fascinating crash course in the way databases work, but I think I melted a little part of my brain. ; ) And I don’t get to stop now - I have to make reserve prices work, come hell or high water!
-Beth
sauden — Thu Oct 22, 2009 11:12 am
what TYPE is the calculated field? datetime?
Forgive my ignorance
I replaced the line in fields.ini , changed the code in products.php and added the close_date field (as datetime)
I’m uncertain if I am supposed to enter a value into the field (same as closing time?) when adding a new product or leave it empty. When leaving it empy, it doesnt ever generate a value and the open or closed auction always shows. Any value inputted makes the open or closed auction never show.
sauden — Sun Oct 25, 2009 7:54 pm
anyone?