Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Diminishing/Non-Diminishing Stock


^Pariah^

Recommended Posts

Been searching contribs on / off for awhile now without success

 

Some items we sell are stocked in quantity - or may be special buy-ins that we have limited amounts of

 

Some items are made-to-order and so never "run out"

 

I need something a little more complex than "check stock level" and "subtract stock"

 

Ideally is a toggle per item that says if that item is to conform to the above rule

 

ie whether an item is "diminishing" or "non-diminishing"

 

I will keep on digging thru contribs, but if you have any ideas, please point me in the right direction

 

Thanx :)

Link to comment
Share on other sites

  • 2 weeks later...

Going to post this so that anybody who finds it can hopefully benefit as much as I have :)

 

Some items I did not want to show on the main page ( index.php ) in renamed "Featured Products For Month" - which is just a reworked "new products for month of" that randomly selects and shows items from the catalog

 

Sometimes, I do not want a photo to appear on the front page of the web, but still want it to be viewable else elsewhere

 

These might be ones where I think the photography aint up to scratch or in some way detracts from the initial style I want to portray - but I still want to be able to sell the item !

 

So ....

 

1. Added a field to the database

 

I did this thru phymyadmin as I wanted to see the structure - but could have been done with sql

 

Table : products

 

New Field : products_show_main_page

 

Type : TinyInt (1)

 

Null : No

 

Default : 1

 

0 = False = Will Not be shown on main page

 

1 = True = Will be shown on main page

 

I added it right at the bottom so it did not stuff around with any other arrays - I hope :)

 

Really should go thru and make sure it can't - but is too much hassle at this stage

 

2. Modified random argument to only select items where the field is True

 

File : catalog/includes/modules/new_products.php

 

Added : and products_show_main_page = '1'

 

Line 24 is now : $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' and products_show_main_page = '1' order by p.products_date_added desc limit " . MAX_RANDOM_SELECT_NEW);

 

Line 26 is now : $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' and products_show_main_page = '1' order by p.products_date_added desc limit " . MAX_RANDOM_SELECT_NEW);

 

** At this point is fully functional - provided don't mind setting field manually

** But let's be nice and try to get it to work from OSC Admin

 

3. Admin side

 

 

a. Define the names for the radio buttons etc in admin/includes/languages/english/categories.php

 

define('TEXT_PRODUCTS_SHOW_MAIN_PAGE', 'Show Product on Main Page ');

define('TEXT_PRODUCTS_SHOW_MAIN_PAGE_TRUE', 'Yes');

define('TEXT_PRODUCTS_SHOW_MAIN_PAGE_FALSE', 'No');

 

b. Create the arrays to get/put data from/into this field in /admin/categories.php

 

Search for products_status

MOST of these will need to be modified

Pretty sure you can forget about some like red/Green bits

I have previous mods - so line numbers don't really help

No idea about p.products and pd.products - but i changed them anyway and nothing broke ... yet !

 

221

// Next Line added as part of products_show_main_page ...

'products_show_main_page' => tep_db_prepare_input($HTTP_POST_VARS['products_show_main_page']),

 

333

// Line modded as part of products_show_main_page ...

tep_db_query("insert into " . TABLE_PRODUCTS . " (products_quantity, products_model,products_image, products_price, products_date_added, products_date_available, products_weight, products_status, products_show_main_page, products_tax_class_id, manufacturers_id) values ('" . tep_db_input($product['products_quantity']) . "', '" . tep_db_input($product['products_model']) . "', '" . tep_db_input($product['products_image']) . "', '" . tep_db_input($product['products_price']) . "', now(), '" . tep_db_input($product['products_date_available']) . "', '" . tep_db_input($product['products_weight']) . "', '0', '" . (int)$product['products_show_main_page'] . (int)$product['products_tax_class_id'] . "', '" . (int)$product['manufacturers_id'] . "')");

 

417

// Next line added as part of products_show_main_page ...

'products_show_main_page' => '',

 

425

//Next line modded as part of products_show_main_page .... Not really sure what p. and pd. refer to tho :(

$product_query = tep_db_query("select pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_show_main_page, p.products_tax_class_id, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'");

 

459

// Above 5 lines blatanlty copied and changed as part of products_show_main_page mod ...

if (!isset($pInfo->products_show_main_page)) $pInfo->products_show_main_page = '1';

switch ($pInfo->products_show_main_page) {

case '0': $in_status = false; $out_status = true; break;

case '1':

default: $in_status = true; $out_status = false;

// And added an extra closing brace

}

 

734

// Next line modded as part of products_show_main_page .... still have no idea WTF p. and pd. are tho ...

$product_query = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_url, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.products_show_main_page, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "'");

 

962

// Added products_show_main_page to next line .... oneday I will find out what it all means

$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.products_show_main_page, p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and pd.products_name like '%" . tep_db_input($search) . "%' order by pd.products_name");

 

966

// Added products_show_main_page to next line

$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.products_show_main_page from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by pd.products_name");

 

995

// I have decided NOT to add products_show_main_page ... pretty sure this is just for Red and Green LEDs

 

 

And so far nothing broken - can still change status and description and attributes and preview and update - woo hoo !

 

 

c. Encode the buttons into /admin/categories.php

 

 

I wanna put this str8 under products_status - so just searched for TEXT_PRODUCTS_STATUS and just copied it and slightly changed it

 

543

<!-- Next block added for products_show_main_page -->

<tr>

<td class="main"><?php echo TEXT_PRODUCTS_SHOW_MAIN_PAGE; ?></td>

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_radio_field('products_show_main_page', '1', $in_status) . ' ' . TEXT_PRODUCTS_SHOW_MAIN_PAGE_TRUE . ' ' . tep_draw_radio_field('products_show_main_page', '0', $out_status) . ' ' . TEXT_PRODUCTS_SHOW_MAIN_PAGE_FALSE; ?></td>

</tr>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<!-- End of block -->

 

And still no errors - woo hoo again :)

 

And it alls eems to be working fine - I can live with that

 

As per http://www.oscommerce.com/forums/index.php?sho...40entry643740 ...

 

... the item is made inactive if you set products_show_main_page = False

 

(If i sort that one out I will update this thread )

 

Tim A.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...