Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

category flags, adding a new one?


Guest

Recommended Posts

Posted

am i missing something?

 

is this the only entry in admin/categories.php for setting product status?

case 'setflag':

if ( ($HTTP_GET_VARS['flag'] == '0') || ($HTTP_GET_VARS['flag'] == '1')) {

if (isset($HTTP_GET_VARS['pID'])) {

tep_set_product_status($HTTP_GET_VARS['pID'], $HTTP_GET_VARS['flag']);

}

 

i've tried to add:

case 'setflag':

if ( ($HTTP_GET_VARS['flag'] == '0') || ($HTTP_GET_VARS['flag'] == '1') || ($HTTP_GET_VARS['flag'] == '2') ) {

if (isset($HTTP_GET_VARS['pID'])) {

tep_set_product_status($HTTP_GET_VARS['pID'], $HTTP_GET_VARS['flag']);

}

 

 

and (to change the color of the indicators):

<?php

if ($products['products_status'] == '1') {

echo tep_image(DIR_WS_IMAGES . 'icon_status_green.gif', IMAGE_ICON_STATUS_GREEN, 9, 9) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'action=setflag&flag=0&pID=' . $products['products_id'] . '&cPath=' . $cPath) . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_red_light.gif', IMAGE_ICON_STATUS_RED_LIGHT, 9, 9) . '</a> <a href="' . tep_href_link(FILENAME_CATEGORIES, 'action=setflag&flag=2&pID=' . $products['products_id'] . '&cPath=' . $cPath) . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_yellow_light.gif', IMAGE_ICON_STATUS_YELLOW_LIGHT, 9, 9) . '</a>';

} else {

echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'action=setflag&flag=1&pID=' . $products['products_id'] . '&cPath=' . $cPath) . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_green_light.gif', IMAGE_ICON_STATUS_GREEN_LIGHT, 9, 9) . '</a> ' . tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', IMAGE_ICON_STATUS_RED, 9, 9) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'action=setflag&flag=2&pID=' . $products['products_id'] . '&cPath=' . $cPath) . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_yellow_light.gif', IMAGE_ICON_STATUS_YELLOW_LIGHT, 9, 9) . '</a>';

}

 

if ($products['products_status'] == '2') {

echo tep_image(DIR_WS_IMAGES . 'icon_status_green.gif', IMAGE_ICON_STATUS_GREEN, 9, 9) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'action=setflag&flag=0&pID=' . $products['products_id'] . '&cPath=' . $cPath) . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_red_light.gif', IMAGE_ICON_STATUS_RED_LIGHT, 9, 9);

}

?>

 

 

but when i tick the yellow light i've just added... but nothing happened. any suggestions?

Posted

i was able to get this working when you add or edit a product, but i can't figure out why it's not working on admin/categories.php when i tick one of the light indicators :huh:

anyone have any suggestions as to what variable or function i've missed?

Posted

you could download the enable/disable categories contribution and get the code from it.

Posted

it's a duplicate of the original online/offline products query. i'm trying to add a third and that's what i'm having troubles with.

 

i have to think this is what's causing me the problems?

if ( ($HTTP_GET_VARS['flag'] == '0') || ($HTTP_GET_VARS['flag'] == '1') || ($HTTP_GET_VARS['flag'] == '2') ) {
Posted

a third led? Yes there is more to it. There is a function in the admin\includes\functions\general.php tep_set_product_status that has to be modified to store the different values. Then your if statement has to change to accomodate all cases (0,1,2) separately. Because now you have

if ($products['products_status'] == '1') {

// do something

}else{

// do something else

}

 

It should been

if ($products['products_status'] == '1') {
// do 1
}elseif($products['products_status'] == '2') {
// do 2
}else{
// do something else
}

Posted

ah! that's what i was looking for :)

what am i doing wrong on this?

////
// Sets the status of a product
 function tep_set_product_status($products_id, $status) {
if ($status == '1') {
  return tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '1', products_last_modified = now() where products_id = '" . (int)$products_id . "'");
} elseif ($status == '0') {
  return tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0', products_last_modified = now() where products_id = '" . (int)$products_id . "'");
} else {

} elseif ($status == '2') {
  return tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '2', products_last_modified = now() where products_id = '" . (int)$products_id . "'");
} else {


  return -1;
}
 }

 

produces: Parse error: syntax error, unexpected T_ELSEIF in general.php line 746

 

which is:

} elseif ($status == '2') {

Posted

you have a redundant else in between the elseif statements

 

	} else {

Posted

thank you :)

 

now i cannot get these products to show up on the manufacturer page, but it shows up on the product sitemap fine, can you spot any errors?

 

query:

//-MS- Generate Array Transpose (from array md)

$manufacturers_query = tep_db_query("select distinct m.manufacturers_id, m.manufacturers_name from " . TABLE_MANUFACTURERS . " m left join " . TABLE_PRODUCTS . " p on (p.manufacturers_id=m.manufacturers_id) where p.manufacturers_id <> 0 and p.products_status >= '1' order by m.manufacturers_name" );

 

no problems on the page at all, the status 2 products just don't show up.

Posted

check if the status of the products in the database does show as 2. And also try changing this from the query

 

p.products_status >= '1'

 

to

 

p.products_status > 0

Posted

nothing :(

it's showing up in the database as 2

Posted

that query suppose to extract the manufacturers why you mentioned products...?

Posted

where are the products from the manufacturers called then?

Posted

when you click a manufacturer link which script loads up? There should be a script to list all products from a manufacturer. Is it index.php in your case?

Posted

it would be allproducts.php and the main query was what i edited in that page. do i need to edit something in index.php as well?

Posted

ok then, what's the original query of the allprods.php you have?

Posted
$manufacturers_query = tep_db_query("select distinct m.manufacturers_id, m.manufacturers_name from " . TABLE_MANUFACTURERS . " m left join " . TABLE_PRODUCTS . " p on (p.manufacturers_id=m.manufacturers_id) where p.manufacturers_id <> 0 and p.products_status = '1' order by m.manufacturers_name" );

$mans_array = array();

Posted

how that comes? I thought it was this one here.

 

  $listing_sql = "select p.products_id, p.products_model, pd.products_name, pd.products_description, p.products_image, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id  $where order by pd.products_name";

 

but from the code it should show all products in the allprods.php script

Posted

not in mine, is there more than one all products contribution? can you login to my test site to see the query i posted?

Posted

I am confused. The allprods.php script is present but you want the products to show on the all manufacturers page? That page shows only the manufacturers not products. What page/script you need to show the products with products_status=2

Posted

oh sorry, i'm confusing myself. i was looking in the wrong file! :D

 

once you select a manufacturer, THEN show the available products (inside the manufacturer page)

 

 

which i think is index.php?manufacturers_id=blablabla

Posted

ok I see, Then backup the catalog\index.php file, then replace all occurances of

 

p.products_status = '1'

 

with

 

p.products_status > 0

 

and retry.

Posted

appears to have done the trick, thank you :D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...