Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Hiding and defaulting fields when adding product


Spoondog

Recommended Posts

Hello,

 

I'm trying to figure out how to hide and/or default specific fields in categories.php, to simplify the process of adding products and limit what the person adding products can do.

 

Specifically, I want to:

 


  •  
  • Hide "Products Status" and assume it's always in stock.
  • Hide "Date Available" and assume it's always the current date.
  • Hide "Products Manufacturer".
  • Make "Tax Class" default to the only option I have - "Taxable Goods" (defaults to "none" currently).
  • Hide "Products Quantity" and assume it's always 1 (I've set my config to not check stock numbers).
  • Hide "Products Model".
  • Hide "Products URL".

 

I guess I just need to know which bits to edit - I thought it'd be fairly easy but there seems to be several lines relevant for each field and I'm not sure where to start.

 

Any help appreciated!

Link to comment
Share on other sites

Cory,

 

In admin>categories.php:

 

1) Find this:

<tr>

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

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

</tr>

change to:

<!--

<tr>

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

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

</tr> -->

 

 

 

2) Find this:

<tr>

<td class="main"><?php echo TEXT_PRODUCTS_DATE_AVAILABLE; ?><br><small>(YYYY-MM-DD)</small></td>

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' '; ?><script language="javascript">dateAvailable.writeControl(); dateAvailable.dateFormat="yyyy-MM-dd";</script></td>

</tr>

 

change it to:

<!-- <tr>

<td class="main"><?php echo TEXT_PRODUCTS_DATE_AVAILABLE; ?><br><small>(YYYY-MM-DD)</small></td>

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' '; ?><script language="javascript">dateAvailable.writeControl(); dateAvailable.dateFormat="yyyy-MM-dd";</script></td>

</tr> -->

 

3) Find this:

<tr>

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

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_pull_down_menu('manufacturers_id', $manufacturers_array, $pInfo->manufacturers_id); ?></td>

<tr>

 

Change to:

<!-- <tr>

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

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_pull_down_menu('manufacturers_id', $manufacturers_array, $pInfo->manufacturers_id); ?></td>

</tr> -->

 

4) skipped

 

5) Find this:

 

<tr>

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

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_quantity', $pInfo->products_quantity); ?></td>

</tr>

 

Change to:

 

<!-- <tr>

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

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_quantity', $pInfo->products_quantity); ?></td>

</tr> -->

 

6) Find this:

 

<tr>

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

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_model', $pInfo->products_model); ?></td>

</tr>

 

Change to:

 

<!-- <tr>

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

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_model', $pInfo->products_model); ?></td>

</tr> -->

 

7) Find this:

 

<tr>

<td class="main"><?php if ($i == 0) echo TEXT_PRODUCTS_URL . '<br><small>' . TEXT_PRODUCTS_URL_WITHOUT_HTTP . '</small>'; ?></td>

<td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . tep_draw_input_field('products_url[' . $languages[$i]['id'] . ']', (isset($products_url[$languages[$i]['id']]) ? stripslashes($products_url[$languages[$i]['id']]) : tep_get_products_url($pInfo->products_id, $languages[$i]['id']))); ?></td>

</tr>

 

Change to:

 

<!-- <tr>

<td class="main"><?php if ($i == 0) echo TEXT_PRODUCTS_URL . '<br><small>' . TEXT_PRODUCTS_URL_WITHOUT_HTTP . '</small>'; ?></td>

<td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . tep_draw_input_field('products_url[' . $languages[$i]['id'] . ']', (isset($products_url[$languages[$i]['id']]) ? stripslashes($products_url[$languages[$i]['id']]) : tep_get_products_url($pInfo->products_id, $languages[$i]['id']))); ?></td>

</tr> -->

 

Sorry, can't help you with 4. If you don't want these fields to appear on the product page, you will have to make similar changes to catalog>product_info.php

 

 

Chris

Link to comment
Share on other sites

It all worked, thanks again! I thought that it would look for values in those fields when the form was submitted, which is why I was scared of just removing them... but it's all good :) Only one caveat is that when the product is added, it's inactive (I guess from hiding the product status field)... but I've fixed that by hiding that row with CSS instead of commenting out the HTML:

 

<tr style="visibility: hidden;">

 

...as for number 4, after looking in includes/functions/html_output.php I found that you can specify a default value for the field. I only have one taxable class so I just specified "1" as the default tax id:

 

tep_draw_pull_down_menu('products_tax_class_id', $tax_class_array, '1', 'onchange="updateGross()"')

Link to comment
Share on other sites

Cory,

 

Actually the default for new products should be ACTIVE. But, I am glad you got it worked out.

 

 

 

Chris

 

ps. If you don't want those fields to show on the catalog side, you will need to make similar changes to the product_info.php file.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...