Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How to time limit products in the database?


sharkcity

Recommended Posts

Hi

 

First of all, I would like to wish everyone a happy new year!

 

I need a small option for a script named quick productadder. Link is here: http://www.oscommerce.com/community/contri...ch,productadder

 

This contribution is very useful for me, but I would like to have some small options to limit the visibility of products in time. I think to a drop down menu, where I can choose how long I want that the specified product will be available.

Exmaple 1 week, 3 weeks, 1 months etc...

 

Any help will be highly appreciated! Thanks forwards.

 

 

Here is the script:

<?php

################################################################################

# Product Adder. Upload into your Admin Directory and open it up in a #

# Browser. Add a product. Done. #

# #

# Image functionality is not quite right, when you add a #

# Product that has no image. #

# #

# Please DO NOT email me regarding this script. Post any questions to the #

# relevant thread in http://www.oscommerce.com/forums/viewforum.php?f=7 #

# #

# This script is freely usable and updatable by you. Use it for any purpose #

# you like. All I ask is that if you make it better or more functional in any #

# way, that you contribute your new script to Oscommerce Downloads Area. #

# #

################################################################################

require('includes/application_top.php');

 

$sql = mysql_query("SELECT MAX(products_id) FROM products");

$row = mysql_fetch_array($sql);

$prodID = $row['0']+1; // Gives us the next highest product number.

 

######### ---- POPULATE THE FORM DROP_DOWNS AND SELECT BOXES ---- #########

 

// manufacturer drop down

$sql2 = mysql_query("SELECT manufacturers_id, manufacturers_name FROM manufacturers ORDER BY manufacturers_name");

$row2 = mysql_fetch_array($sql2);

 

// category drop down

 

// $sql3 = mysql_query("SELECT categories_id, categories_name FROM categories_description ORDER BY categories_name");

// $categorize = mysql_fetch_array($sql3);

 

######### ---- NOW WE NEED TO ADD THE NEW PRODUCT TO THE RELEVANT TABLES IN THE DATABASE ---- #########

if ($action == "addproduct") {

// IMAGE UPLOADER

$uploaddir = DIR_FS_CATALOG . DIR_WS_IMAGES;

 

if (($file == "none")||($file=="")) {

$file_name = "";

}

else {

copy($file, $uploaddir.$file_name);

unlink($file);

}

// END IMAGE UPLOADER

$now = date("Y-m-d G:i:s");

$now2 = date("Y-m-d");

$products_description_form = nl2br($products_description_form);

$result = mysql_query("INSERT INTO products

(products_id,

products_quantity,

products_model,

products_image,

products_price,

products_date_added,

products_last_modified,

products_date_available,

products_weight,

products_status,

products_tax_class_id,

manufacturers_id,

products_ordered)

VALUES

('$prodID',

'$products_quantity_form',

'$products_model_form',

'$file_name',

'$products_price_form',

'$now',

'$now',

'',

'$products_weight_form',

'$products_status_form',

'$products_tax_class_id_form',

'$product_manufacturer_form',

'0')");

if ($result) {

echo "<p>Stage 1 done</p>";

}

$result2 = mysql_query("INSERT INTO products_description

(products_id,

language_id,

products_name,

products_description,

products_url,

products_viewed)

VALUES

($prodID,

$language_id_form,

'$products_name_form',

'$products_description_form',

'$products_url_form',

0)");

if ($result2) {

echo "<p>Stage 2 done</p>";

}

$result3 = mysql_query("INSERT INTO products_to_categories

(products_id,

categories_id)

VALUES

($prodID,

$categories_id_form)");

 

$random = date("U");

echo "<p>Successfully Added - feel free to <a href=\"$PHP_SELF?$random\">add another</a>.</p>";

exit;

}

?>

<html>

<head>

<title>Product Adder</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">

<!--

table { border: #000000; border-style: dashed; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}

th { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; text-align: center; background-color: #CCCCCC; padding-top: 3px; padding-bottom: 3px}

td { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; padding-left: 8px; padding-top: 2px; padding-bottom: 2px}

.required { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; padding-left: 8px; padding-top: 2px; padding-bottom: 2px; color: #FF0000; font-weight:bold}

-->

</style>

<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">

<!-- header //-->

<?php

require(DIR_WS_INCLUDES . 'header.php');

?>

<!-- header_eof //-->

<!-- body //-->

<table border="0" width="100%" cellspacing="2" cellpadding="2">

<tr>

<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">

<!-- left_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>

<!-- left_navigation_eof //-->

</table></td>

<!-- body_text //-->

<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">

 

<form name="form1" method="POST" action="productadder.php" ENCTYPE="multipart/form-data">

<input type="hidden" name="action" value="addproduct">

<table width="70%" border="0" cellspacing="0" cellpadding="0">

<tr>

<th colspan="2">New Product:</th>

</tr>

<tr>

<td>Product ID</td>

<td><b>

<?php echo $prodID; ?>

</b></td>

<input type="hidden" name="products_id_form" value="<?php echo $prodID; ?>">

</tr>

<tr>

<td>Quantity Available (numeric)</td>

<td>

<input type="text" name="products_quantity_form" maxlength="5" size="3">

</td>

</tr>

<tr>

<td>Product Model</td>

<td>

<input type="text" name="products_model_form">

</td>

</tr>

<tr>

<td>Products Image</td>

<td><input type="file" size=40 name="file"></td>

</tr>

<tr>

<td class="required">Products Price (no ? sign)</td>

<td>

<input type="text" name="products_price_form">

</td>

</tr>

<tr>

<td>Product Weight (numeric)</td>

<td>

<input type="text" name="products_weight_form">

<input type="hidden" name="products_status_form" value="1">

<input type="hidden" name="products_tax_class_id_form" value="0">

</td>

</tr>

<tr>

<td>Product Manufacturer</td>

<td>

<select name="product_manufacturer_form">

<?php

if(mysql_num_rows($sql2)) {

print "<option value=\"\">No manufacturer</a>";

while($row = mysql_fetch_row($sql2)) {

print("<option value=\"$row[0]\">$row[1]</option>");

}

}

?>

</select>

</td>

</tr>

<tr>

<th colspan="2">Products Description</th>

</tr>

<tr>

<td>Product ID</td>

<td><b>

<?php echo $prodID; ?>

</b></td>

<input type="hidden" name="products_id_form" value="<?php echo $prodID; ?>">

<input type="hidden" name="language_id_form" value="1">

</tr>

<tr>

<td class="required">Product Name</td>

<td>

<input type="text" name="products_name_form">

</td>

</tr>

<tr>

<td class="required">Product Description</td>

<td>

<textarea name="products_description_form" rows="10" cols="40"></textarea>

<input type="hidden" name="products_url_form" value="">

<input type="hidden" name="products_viewed_form" value="0">

</td>

</tr>

<tr>

<th colspan="2">Which Category ?</th>

</tr>

<tr>

<td>Product ID</td>

<td><b>

<?php echo $prodID; ?>

</b></td>

<input type="hidden" name="products_id_form" value="<?php echo $prodID; ?>">

</tr>

<tr>

<td>Category to go into</td>

<td>

<?php

 

echo tep_draw_pull_down_menu('categories_id_form', tep_get_category_tree());

 

?>

</td>

</tr>

<tr>

<td>

 

</td>

<td>?</td>

</tr>

<tr>

<td>

<div align="right">

<input type="submit" name="Submit" value="Submit">

</div>

</td>

<td>

<input type="reset" name="Submit2" value="Reset">

</td>

</tr>

</table>

</form>

<!-- body_text_eof //-->

</tr>

</table>

<!-- body_eof //-->

<!-- footer //-->

<?php

require(DIR_WS_INCLUDES . 'footer.php');

?>

<!-- footer_eof //-->

<br>

 

</body>

</html>

<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Link to comment
Share on other sites

Hi

 

First of all, I would like to wish everyone a happy new year!

Thank you and likewise !

 

I need a small option for a script named quick productadder. Link is here: http://www.oscommerce.com/community/contri...ch,productadder

 

This contribution is very useful for me, but I would like to have some small options to limit the visibility of products in time. I think to a drop down menu, where I can choose how long I want that the specified product will be available.

Exmaple 1 week, 3 weeks, 1 months etc...

 

Any help will be highly appreciated! Thanks forwards.

Cute name for this contrib but if I read well it is merely there for adding products a little bit quiker to your database. However the functionality you want is already available within the stock osCommerce installation and is called Specials (you'll find it under Catalog in your admin).

Link to comment
Share on other sites

Thank you. I use differently the oscommerce system. I give access for registered members to this file and I let costumers add products. That?s why I need this future directly in the productadder.php file included. I don't want give access to the admin specials. Anyways, again great thank for your answer. :)

Link to comment
Share on other sites

Thank you. I use differently the oscommerce system. I give access for registered members to this file and I let costumers add products. That?s why I need this future directly in the productadder.php file included. I don't want give access to the admin specials. Anyways, again great thank for your answer. :)

 

Clear <_<

Not something easily done but you could take the admin specials module as a sample and build it into that contribution you use.

 

Good luck with it and HNY !

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...