PDA

View Full Version : Trying to create a new status behaviour



Dr_Evil
02-18-2003, 02:40 AM
Hi,
I am trying to create an additional set of status buttons in the admin section.

The purpose of these buttons is so that the site administrator can set a product to sold (and show a message to the user that this product has been sold) and this will not remove the product completely as the other status buttons do.

I did not modify the current status behavior because I wanted to keep that functionality as well. I looked around for a contribution and found one that will signify (by a custom message) when a stock item gets low. This contribution is based on stock quantities.

This is not suitable because I will only ever have one of the product and I simply want to toggle between sold or not sold.

I created a new field in products ( product_status_sold ). I did not modify the current status field as I wanted to keep it
separate as I am completely new to PHP and could not gage the impact on the rest of the app. I created a function, a selection

structure to set the message of "This Product is SOLD" based on the value of the new status field in the products file and created the

new buttons on the admin form. I tested it. The data base is getting populated and the message is getting displayed correctly.

Everything seems to work but the buttons.

I can see the buttons, I can even click them. The problem is that I have duplicated the functionality of the other
status buttons. So when I click on a status my new buttons also behave as if they have been clicked on as well and visa-versa.

I have isolated the problem down to, I think, this group of code. However, I am not sure how I can separate this
code out. I have tried a few things.

Any ideas?



Admin/Categories.php

Starts at about line 44 in Categories.php

if ($HTTP_GET_VARS['action']) {
switch ($HTTP_GET_VARS['action']) {
case 'setflag':
if ( ($HTTP_GET_VARS['flag'] == '0') || ($HTTP_GET_VARS['flag'] == '1') ) {
if ($HTTP_GET_VARS['pID']) {
tep_set_product_status($HTTP_GET_VARS['pID'], $HTTP_GET_VARS['flag']);