Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Specials contribution


Recommended Posts

Greetings..i'm *attempting* to put together a specials contribution, that will allow you to put products on special, and update the price and expiration date.

 

I'm basing it off of the Quick Price Updates Module, as that seemed like a good starting point. If anyone can give me a hand as to where to go next, this may be very helpful for a few other users out there.

 

Here is my current code, although it does not work yet, and needs a lot of work:

<?php

/*

 $Id: quick_updates.php,v 1.4b $



 osCommerce, Open Source E-Commerce Solutions

 http://www.oscommerce.com



 Based on the original script contributed by Burt ([email protected])

       and by Henri Bredehoeft ([email protected])

       and Blue Dog ([email protected])

 updated by GniDhal ([email protected]) & xaglo ([email protected])



 Copyright (c) 2003 osCommerce



 Released under the GNU General Public License

*/



 require('includes/application_top.php');

if ($HTTP_POST_VARS) {

  if ($action == "update") {

  $messageStack->add(TEXT_SPECIALS_UPDATED, 'success');



      foreach($HTTP_POST_VARS['product_specials_price'] as $id => $new_price) {

        mysql_query("UPDATE specials SET specials_new_products_price=$new_price WHERE products_id=$id");

      }

      foreach($HTTP_POST_VARS['product_specials_status'] as $id => $new_status) {

        tep_set_specials_status($id, $new_status);

      }

  }





}



?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<title><?php echo TITLE; ?></title>

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

</head>

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

<!-- 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">

     <tr>

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

         <tr>

         <form name="update" method="post" action="<?php echo "$PHP_SELF?action=update"; ?>">

           <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>

           <td align=middle><?php if ($HTTP_GET_VARS['pID']) {

       echo tep_image_submit('button_update.gif', IMAGE_UPDATE);

     } else {

       echo tep_image_submit('button_update.gif', IMAGE_INSERT);

     }

     echo '  <a href="' . tep_href_link(FILENAME_QUICK_UPDATES, 'cPath=' . $cPath . '&pID=' . $HTTP_GET_VARS['pID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>';?>

          </td>



           <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

         </tr>

       </table></td>

     </tr>

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

         <tr>

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

             <tr class="dataTableHeadingRow">

               <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_MODEL ?></td>

               <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS ?></td>

               <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_STATUS ?> <br>off / on</td>

               <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_PRICE ?> </td>

             </tr>

         <tr class="datatableRow">

<?

($sort_by) ? $sort_by = 'ORDER BY '.$sort_by : $sort_by = $HTTP_POST_VARS['sort_order'];

 $result = tep_db_query("SELECT DISTINCT

                                 p.specials_id,

                                p.products_id,

                                p.specials_status,

                                p.specials_new_products_price

                          FROM  " . TABLE_SPECIALS . " as p

                          LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " as pd  ON (p.products_id = pd.products_id)

                          WHERE pd.language_id = '$languages_id'

                          $sort_by

                          ");



   if ($row = mysql_fetch_array($result)) {

       do {

          echo tep_draw_hidden_field( 'sort_order', $sort_by);

          echo '<tr class="dataTableRow" onmouseover="this.className='dataTableRowOver';this.style.cursor='hand'" onmouseout="this.className='dataTableRow'">';

          echo "<td class="smallText" >".$row["products_model"]."</td>n";

          echo "<td><a href="".tep_href_link (FILENAME_CATEGORIES, 'pID='.$row["specials_id"].'&action=new_product'). "">".$row["products_name"]."</a></td>n";

         if ($row['specials_status'] == '1') {

          echo "<td class="smallText" align="center"><input  type="radio" name="product_specials_status[".$row['products_id']."]" value="0" ><input type="radio" name="product_specials_status[".$row['specials_id']."]" value="1" checked ></td>n";

         } else {

          echo "<td nowrap align="center"><input type="radio" style="background-color: #EEEEEE" name="product_specials_status[".$row['products_id']."]" value="0" checked ><input type="radio" style="background-color: #EEEEEE" name="product_specials_status[".$row['specials_id']."]" value="1"></td>n";

         }

          echo "<td class="smallText" align="center"><input type="text" size="7" name="product_specials_price[".$row['specials_id']."]" value={$row['specials_newproducts_price']}></td>n";

       }

       while($row = mysql_fetch_array($result) );

   }



   echo "</table>n";

?></td>

         </tr>

         </table></td>

         </tr>

         <tr>

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



           </table></td>

         </tr>

       </table></td>

     </tr>

   </table></td>

               <table width="100%" border="0" cellspacing="1">

<tr>

<td align=middle><?php if ($HTTP_GET_VARS['pID']) {

       echo tep_image_submit('button_update.gif', IMAGE_UPDATE);

     } else {

       echo tep_image_submit('button_update.gif', IMAGE_INSERT);

     }

     echo '  <a href="' . tep_href_link(FILENAME_QUICK_UPDATES, 'cPath=' . $cPath . '&pID=' . $HTTP_GET_VARS['pID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>';

?></td>

</tr>



</table>

</form>

<!-- body_text_eof //-->

 </tr>

</table>

<!-- body_eof //-->

 </tr>

</table>

<!-- body_eof //-->



<!-- footer //-->

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

<!-- footer_eof //-->

</body>

</html>

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

 

My current error is:

1054 - Unknown column 'p.specials_status' in 'field list'



SELECT DISTINCT p.specials_id, p.products_id, p.specials_status, p.specials_new_products_price FROM specials as p LEFT JOIN products_description as pd ON (p.products_id = pd.products_id) WHERE pd.language_id = '1' 



[TEP STOP]

 

Any help would be great..as i'd like to get this posted so myself and others can benefit. Cheers!

~Jason

Link to comment
Share on other sites

Sorry if i wasnt clear in my first post, i know you can already put products on special, but it is painstakingly SLOW...a form listing all products that you could click on or off, add the price or %, and the expiration date would be much quicker with one update button.

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...