Here is a simple mode for product price update by membership level.
This mod will update or add product/price/membership data from csv file.
/provider/price_update.php
Note:
$columns[0] - is your product code in import file
$columns[1] - is your product price in import file
Code:
<?
/*****************************************************************************\
+-----------------------------------------------------------------------------+
| X-Cart |
| Copyright (c) 2001-2003 Ruslan R. Fazliev <rrf@rrf.ru> |
| All rights reserved. |
+-----------------------------------------------------------------------------+
| PLEASE READ THE FULL TEXT OF SOFTWARE LICENSE AGREEMENT IN THE "COPYRIGHT" |
| FILE PROVIDED WITH THIS DISTRIBUTION. THE AGREEMENT TEXT IS ALSO AVAILABLE |
| AT THE FOLLOWING URL: http://www.x-cart.com/license.php |
| |
| THIS AGREEMENT EXPRESSES THE TERMS AND CONDITIONS ON WHICH YOU MAY USE |
| THIS SOFTWARE PROGRAM AND ASSOCIATED DOCUMENTATION THAT RUSLAN R. |
| FAZLIEV (hereinafter referred to as "THE AUTHOR") IS FURNISHING OR MAKING |
| AVAILABLE TO YOU WITH THIS AGREEMENT (COLLECTIVELY, THE "SOFTWARE"). |
| PLEASE REVIEW THE TERMS AND CONDITIONS OF THIS LICENSE AGREEMENT |
| CAREFULLY BEFORE INSTALLING OR USING THE SOFTWARE. BY INSTALLING, |
| COPYING OR OTHERWISE USING THE SOFTWARE, YOU AND YOUR COMPANY |
| (COLLECTIVELY, "YOU") ARE ACCEPTING AND AGREEING TO THE TERMS OF THIS |
| LICENSE AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY THIS |
| AGREEMENT, DO NOT INSTALL OR USE THE SOFTWARE. VARIOUS COPYRIGHTS AND |
| OTHER INTELLECTUAL PROPERTY RIGHTS PROTECT THE SOFTWARE. THIS |
| AGREEMENT IS A LICENSE AGREEMENT THAT GIVES YOU LIMITED RIGHTS TO USE |
| THE SOFTWARE AND NOT AN AGREEMENT FOR SALE OR FOR TRANSFER OF TITLE.|
| THE AUTHOR RETAINS ALL RIGHTS NOT EXPRESSLY GRANTED BY THIS AGREEMENT. |
| |
| The Initial Developer of the Original Code is Ruslan R. Fazliev |
| Portions created by Ruslan R. Fazliev are Copyright (C) 2001-2003 |
| Ruslan R. Fazliev. All Rights Reserved. |
+-----------------------------------------------------------------------------+
\*****************************************************************************/
#
# $Id: price_update.php,v 1 2003/09/10 ant Exp $
#
@set_time_limit(1800);
require "../smarty.php";
require "../config.php";
require "./auth.php";
require "../include/security.php";
if ($REQUEST_METHOD=="POST") {
$provider_condition=($single_mode?"":" AND $sql_tbl[products].provider='$login'");
if($fp = @fopen($userfile,"r")) {
while ($columns = fgetcsv ($fp, 65536, $delimiter)) {
if ($columns[0]) {
if ($what == "p") {
$pid = func_query_first ("SELECT * FROM $sql_tbl[products] WHERE productcode='$columns[0]' $provider_condition");
$f = "SELECT count(*) FROM $sql_tbl[pricing] WHERE productid='$pid[productid]' AND membership='$membership' AND quantity=1";
echo $f."
";
$tmp = array_pop(func_query_first($f));
# $tmp = db_query ($f);
echo $tmp."
";
if ($tmp != 0)
{
$f = "UPDATE $sql_tbl[pricing] SET price='$columns[1]' WHERE productid='$pid[productid]' AND membership='$membership' AND quantity=1";
echo $f."
";
db_query ($f);
}
else
{
$f = "INSERT $sql_tbl[pricing] VALUES ('','$pid[productid]','1','$columns[1]','$membership')";
echo $f."
";
db_query ($f);
}
}
}
}
$smarty->assign("main", "price_updated");
} else {
$smarty->assign("main", "error_inv_update");
}
} else {
$smarty->assign ("main", "price_update");
}
require "../include/categories.php";
@include "../modules/gold_display.php";
$smarty->display("provider/home.tpl");
?>
skin1/single/home.tpl
Code:
After:
{elseif $main eq "inv_update"}
{include file="provider/main/inv_update.tpl"}
Add:
{elseif $main eq "price_update"}
{include file="provider/main/price_update.tpl"}
skin1/provider/main/price_update.tpl
Code:
{* $Id: price_update.tpl,v 1.0 2003/09/10 ant Exp $ *}
{include file="location.tpl" last_location="Price update"}
{capture name=dialog}
<h3><font color=red>Script is in testing! Please back up database!</font></h3>
<FORM method=POST action="price_update.php" enctype="multipart/form-data">
<TABLE border=0 cellpadding=0 cellspacing=4 width="100%">
<TR>
<TD>Membership</TD>
<TD>
<select name=membership>
<option value="">Default Price</option>
{section name=level loop=$membership_levels}
<option value="{$membership_levels[level].membership}">{$membership_levels[level].membership}</option>
{/section}
</select>
</TD>
</TR>
<TR>
<TD>Update</TD>
<TD><SELECT name=what>
<OPTION value="p" selected>Pricing</OPTION>
</SELECT></TD>
</TR>
<TR>
<TD>CSV delimiter</TD>
<TD>{include file="provider/main/ie_delimiter.tpl"}</TD>
</TR>
<TR>
<TD>CSV file</TD>
<TD><INPUT type=file name=userfile></TD>
</TR>
<TR>
<TD colspan=2><INPUT type=submit value="Update">
</TABLE>
</FORM>
{/capture}
{include file="dialog.tpl" content=$smarty.capture.dialog title="Price Update" extra="width=100%"}
skin1/provider/menu.tpl
Let me know if I missed something.