Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Price Update/Import by membership level mode

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 09-11-2003, 09:14 AM
  finestshops's Avatar 
finestshops finestshops is offline
 

eXpert
  
Join Date: Oct 2002
Location: Toronto, Canada
Posts: 335
 

Default Price Update/Import by membership level mode

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

Code:

Let me know if I missed something.
__________________
Best regards,

Anton Pachkine
finestshops.com/x-cart
Reply With Quote
  #2  
Old 09-27-2003, 03:09 PM
 
dealsondeals dealsondeals is offline
 

eXpert
  
Join Date: Dec 2002
Location: Dallas, Texas, USA
Posts: 231
 

Default

What version is this mod for?

Thanks,

Glen
__________________
Never understimate stupidity.
--------
X-Cart Version: 3.5.2
Hosting:mind-in-design.net
Configuration: Virtual Dedicated Server || Intel Pentium 4 2.4 GHZ CPU || 1024MB PC2100 DDR RAM || Linux || PHP 4.3.2 || MySQL server 4.0.14
Reply With Quote
  #3  
Old 09-27-2003, 05:38 PM
  finestshops's Avatar 
finestshops finestshops is offline
 

eXpert
  
Join Date: Oct 2002
Location: Toronto, Canada
Posts: 335
 

Default

Quote:
Originally Posted by dealsondeals
What version is this mod for?

I used it in 3.4.4 and 3.4.7
should work in any 3.4.*
__________________
Best regards,

Anton Pachkine
finestshops.com/x-cart
Reply With Quote
  #4  
Old 09-27-2003, 06:56 PM
 
dealsondeals dealsondeals is offline
 

eXpert
  
Join Date: Dec 2002
Location: Dallas, Texas, USA
Posts: 231
 

Default

Thanks Anton!

I'll implement it, just did a install of 3.4.7 and looking to see what bells and whistles to add.

Regards,

Glen
__________________
Never understimate stupidity.
--------
X-Cart Version: 3.5.2
Hosting:mind-in-design.net
Configuration: Virtual Dedicated Server || Intel Pentium 4 2.4 GHZ CPU || 1024MB PC2100 DDR RAM || Linux || PHP 4.3.2 || MySQL server 4.0.14
Reply With Quote
  #5  
Old 11-15-2003, 04:25 PM
  adpboss's Avatar 
adpboss adpboss is offline
 

X-Man
  
Join Date: Feb 2003
Location: Ontario, Canada
Posts: 2,389
 

Default

This is nice but I wish I was smart enough to figure out how to import pricing by qty (wholesale pricing). If it could create and import quantity pricing it would truly be the bomb.

Nice mod nonetheless, thanks Anton.
Reply With Quote
  #6  
Old 11-15-2003, 04:39 PM
  finestshops's Avatar 
finestshops finestshops is offline
 

eXpert
  
Join Date: Oct 2002
Location: Toronto, Canada
Posts: 335
 

Default

Quote:
Originally Posted by adpboss
If it could create and import quantity pricing it would truly be the bomb.

This is easy. I'm using it already for several months.
Modify import file like this:

$columns[0] - is your product code in import file
$columns[1] - is your product price in import file
$columns[2] - is your product min qty for this price price in import file

in 2 places change

Code:
quantity=1

to

Code:
quantity='$columns[2]'

change

Code:
$f = "INSERT $sql_tbl[pricing] VALUES ('','$pid[productid]','1','$columns[1]','$membership')";

to

Code:
$f = "INSERT $sql_tbl[pricing] VALUES ('','$pid[productid]','$columns[2]','$columns[1]','$membership')";


done
enjoy
__________________
Best regards,

Anton Pachkine
finestshops.com/x-cart
Reply With Quote
  #7  
Old 11-15-2003, 04:43 PM
  adpboss's Avatar 
adpboss adpboss is offline
 

X-Man
  
Join Date: Feb 2003
Location: Ontario, Canada
Posts: 2,389
 

Default

Anton, you are simply the greatest.

I was about to go back and do another mod that is similar but doesnt add to the pricing tables.

For reference that mod is located here
http://forum.x-cart.com/viewtopic.php?t=1696

The only question I still have about this mod is what happens when someone accidentally has the same sku for 2 products? Wouldn't that pooch the whole thing?

I prefer to update off of Product ID if possible.
Reply With Quote
  #8  
Old 11-15-2003, 04:53 PM
  finestshops's Avatar 
finestshops finestshops is offline
 

eXpert
  
Join Date: Oct 2002
Location: Toronto, Canada
Posts: 335
 

Default

Quote:
Originally Posted by adpboss
The only question I still have about this mod is what happens when someone accidentally has the same sku for 2 products? Wouldn't that pooch the whole thing?
I prefer to update off of Product ID if possible.

With product id this would be much easier, but most people do not know have product id, they only have productcode.

If you want ptoduct id, just change

$pid[productid]

to

$columns[0]
__________________
Best regards,

Anton Pachkine
finestshops.com/x-cart
Reply With Quote
  #9  
Old 11-15-2003, 04:54 PM
  adpboss's Avatar 
adpboss adpboss is offline
 

X-Man
  
Join Date: Feb 2003
Location: Ontario, Canada
Posts: 2,389
 

Default

This is wonderful, thank you so much for supporting this mod with me.

I really do appreciate it.
Reply With Quote
  #10  
Old 11-15-2003, 05:04 PM
  finestshops's Avatar 
finestshops finestshops is offline
 

eXpert
  
Join Date: Oct 2002
Location: Toronto, Canada
Posts: 335
 

Default

Let me know if it works
__________________
Best regards,

Anton Pachkine
finestshops.com/x-cart
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 09:39 AM.

   

 
X-Cart forums © 2001-2020