Pagina 1 di 1

Incrementa/Decrementa prezzo x% per tutti i prodotti

Inviato: 19/09/2010, 12:18
da Dax87
Ciao ragazzi,

ho trovato questa contrb interessante:
http://addons.oscommerce.com/info/4663
Increase/Decrease price by x% for all products or products from a category

se hai 1000 prodotti di cui il prezzo aumenta del 3% diventa dura.. questo varia il prezzo in automatico... e molto semplice... ma solo dei prodotti e NON AGLI ATTRIBUTI.

secondo voi c'e la possibilità al file di admin di integrare la variazione del prezzo anche per gli attributi?

ex:
Maglietta 25 euro

attrib:
nera + 2.00 euro
rossa + 3.00 euro

la contrib va modificare i 25 euro aggiungendo la % ma non varia gli attributi che rimangono sempre con i vecchi prezzi.

modifica solo i prodotti ma i prezzi degli attributi rimangono invariati..

qualcuno sa modificarla?....

codice:

Codice: Seleziona tutto

<?php
/*
  $Id: mail.php,v 1.1.1.1 2004/03/04 23:38:43 ccwjr Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  require('includes/application_top.php');
  
  if (isset($_GET["action"]) && $_GET["action"]=='modify_prices') {
	$category_id = $_POST["category_id"];
	if (trim($_POST["amount"])!="0") {
		$amount = $_POST["amount"];
	}
	elseif (trim($_POST["amount_dollars"]!="0")) {
		$amount_dollars = $_POST["amount_dollars"];
	}
	$operation = $_POST["operation"];
	if ($category_id != 'all') {
		$query = 'select p.products_id, p.products_price, ptc.categories_id from 
			 products p,
			 products_to_categories ptc
			 where p.products_id = ptc.products_id
			 and ptc.categories_id = "'.(int)$category_id.'"';
		$result = mysql_query($query) or die(mysql_error());
		$number_of_modified_records = 0;
		while ($row = mysql_fetch_array($result)) {
			if ($operation == "plus") {
				if (isset($amount) && trim($amount)!="0") {
					$new_price = round((1+($amount/100)) * $row["products_price"],2);
				}
				elseif (isset($amount_dollars) && trim($amount_dollars)!="0") {
					$new_price = $row["products_price"] + $amount_dollars;
				}
			}
			else {
				if (isset($amount) && trim($amount)!="0") {
					$new_price = round((1-($amount/100)) * $row["products_price"],2);
				}
				elseif (isset($amount_dollars) && trim($amount_dollars)!="0") {
					$new_price = $row["products_price"] - $amount_dollars;
				}
			}
			$query_update = 'update products set products_price = '.$new_price.' where products_id = '.$row["products_id"];
			mysql_query($query_update);
			$number_of_modified_records++;
		}
	}
	else {
		$query = 'select products_id, products_price from products';
		$result = mysql_query($query) or die(mysql_error());
		$number_of_modified_records = 0;
		while ($row = mysql_fetch_array($result)) {
			if ($operation == "plus") {
				if (isset($amount) && trim($amount)!="0") {
					$new_price = round((1+($amount/100)) * $row["products_price"],2);
				}
				elseif (isset($amount_dollars) && trim($amount_dollars)!="0") {
					$new_price = $row["products_price"] + $amount_dollars;
				}
			}
			else {
				if (isset($amount) && trim($amount)!="0") {
					$new_price = round((1-($amount/100)) * $row["products_price"],2);
				}
				elseif (isset($amount_dollars) && trim($amount_dollars)!="0") {
					$new_price = $row["products_price"] - $amount_dollars;
				}
			}
			$query_update = 'update products set products_price = '.$new_price.' where products_id = '.$row["products_id"];
			mysql_query($query_update);
			$number_of_modified_records++;
		}	
	}
  }
  

?>
<!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 MODIFY_PRICES_TITLE;?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/menu.js"></script>

       <script language="Javascript1.2"><!-- // load htmlarea
// MaxiDVD Added WYSIWYG HTML Area Box + Admin Function v1.7 - 2.2 MS2 HTML Email HTML - <head>
      _editor_url = "<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_ADMIN; ?>htmlarea/";  // URL to htmlarea files
        var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
         if (navigator.userAgent.indexOf('Mac')        >= 0) { win_ie_ver = 0; }
          if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
           if (navigator.userAgent.indexOf('Opera')      >= 0) { win_ie_ver = 0; }
       <?php if (HTML_AREA_WYSIWYG_BASIC_EMAIL == 'Basic'){ ?>  if (win_ie_ver >= 5.5) {
       document.write('<scr' + 'ipt src="' +_editor_url+ 'editor_basic.js"');
       document.write(' language="Javascript1.2"></scr' + 'ipt>');
          } else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
       <?php } else{ ?> if (win_ie_ver >= 5.5) {
       document.write('<scr' + 'ipt src="' +_editor_url+ 'editor_advanced.js"');
       document.write(' language="Javascript1.2"></scr' + 'ipt>');
          } else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
       <?php }?>
// --></script>
       <script language="JavaScript" src="htmlarea/validation.js"></script>
       <script language="JavaScript">
<!-- Begin
       function init() {
define('customers_email_address', 'string', 'Customer or Newsletter Group');
}
//  End -->
</script>
</head>
<body OnLoad="init()" 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="0">
      <tr>
        <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading"><?php echo MODIFY_PRICES_TITLE;?></td>
            <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
          <tr><?php echo tep_draw_form('mail', 'prices_per.php', 'action=modify_prices'); ?>
            <td><table border="0" width="100%" cellpadding="0" cellspacing="2">
              <tr>
                <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
              </tr>
              <tr>
                <td class="smallText"><b><?php echo MODIFY_PRICES_CATEGORY;?></b><br>
					<select name='category_id'>
						<option value='all'><?php echo MODIFY_PRICES_ALL;?></option>
						<?php
							$query = "select categories_id, categories_name from categories_description";
							$result = mysql_query($query);
							while ($row = mysql_fetch_array($result)) {
								echo '<option value='.$row["categories_id"].'>'.$row["categories_name"].'</option>';
							}
							mysql_free_result($result);
						?>
					</select>
                </td>
              </tr>
              <tr>
                <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
              </tr>
              <tr>
                <td class="smallText"><b>+/-</b><br>
					<select name='operation'>
						<option value='plus'>+</option>
						<option value='minus'>-</option>
					</select>
                </td>
              </tr>
              <tr>
                <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
              </tr>
              <tr>
                <td class="smallText"><b><?php echo MODIFY_PRICES_AMOUNT;?></b><br><input type=text name=amount size=4 value=0>%</td>
              </tr>
              <tr>
                <td class="smallText"><b><?php echo MODIFY_PRICES_OR;?></b><br>$<input type=text name=amount_dollars size=4 value=0></td>
              </tr>
              <tr>
                <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
              </tr>
              <tr>
                <td class="smallText"><b>
                	<?php
                		if (isset($_GET["action"]) && $_GET["action"]=='modify_prices') {
                			echo $number_of_modified_records . " products modified";
                			if (isset($amount) && trim($amount)!="0") echo " by ".$amount."% ";
                			else echo " by $".$amount_dollars;
                		}
                	?>
                </b></td>
              </tr>
              <tr>
                <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
              </tr>
              <tr>
                <td>
                    <tr>
                    <td align="right"><?php echo '<a href="' . tep_href_link('prices_per.php') . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a> ' . tep_image_submit('button_confirm.gif', IMAGE_SEND_EMAIL); ?></td>
                    </tr>
                    <td class="smallText"></td>
                  </tr>
                </table></td>
             </tr>
            </table></td>
          </form></tr>
<!-- body_text_eof //-->
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<table aling=center><tr><td>Powered by <a href=http://www.PinkCrow.net>PinkCrow</a></td></tr></table>
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Re: Incrementa/Decrementa prezzo x% per tutti i prodotti

Inviato: 19/09/2010, 15:17
da dynamo
come ti ho detto in pm una richiesta del genere è più facile che venga accolta se postata in Job Opportunities

cmq tutto è possibile con php e mysql basta avere conoscenze e tempo ;)

Re: Incrementa/Decrementa prezzo x% per tutti i prodotti

Inviato: 19/09/2010, 16:09
da Dax87
dynamo ha scritto:come ti ho detto in pm una richiesta del genere è più facile che venga accolta se postata in Job Opportunities

cmq tutto è possibile con php e mysql basta avere conoscenze e tempo ;)
io non ho proprio questa conoscenza avrei bisogno di un aiutino :P ps: chi puo' spostare il post ????

Re: Incrementa/Decrementa prezzo x% per tutti i prodotti

Inviato: 19/09/2010, 19:46
da dynamo
Dax87 ha scritto:
dynamo ha scritto:come ti ho detto in pm una richiesta del genere è più facile che venga accolta se postata in Job Opportunities

cmq tutto è possibile con php e mysql basta avere conoscenze e tempo ;)
io non ho proprio questa conoscenza avrei bisogno di un aiutino :P ps: chi puo' spostare il post ????
fai prima a riscriverlo di là ;)