Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> eCommerce
Author Message
alien73
Involved
Involved



Joined: Sep 15, 2008
Posts: 352

PostPosted: Tue Feb 10, 2009 3:46 pm Reply with quote

What's left that's not working.. Sorry there's alot of examples above.
 
View user's profile Send private message Visit poster's website
horrorcode
Involved
Involved



Joined: Jan 17, 2009
Posts: 272
Location: Missouri

PostPosted: Tue Feb 10, 2009 3:56 pm Reply with quote

Dont be I need to be simpler with my posts.

Code:
$link = mysql_connect($dbhost,$dbuname, $dbpass) OR DIE ("Unable To Connect To Database");

mysql_select_db($dbname, $link) OR DIE("Unable To Select To Database");
$sql = "SELECT pid,name, pnum, a1, listp, specialprice,numberstock,stock FROM CCart_products ORDER BY name LIMIT $offset,$searchrows";
$result = $db->sql_query($sql);
mysql_close($link);


mysql_connect
mysql_select_db
mysql_close

What should those be?
Those are found in root/ipn.php, admin/modules/ccart/orders.php, and admin/modules/ccart/inventory.php
 
View user's profile Send private message
alien73







PostPosted: Tue Feb 10, 2009 4:24 pm Reply with quote

Well it should no longer use $link just call the database the way RN does with any other module
 
horrorcode







PostPosted: Tue Feb 10, 2009 7:03 pm Reply with quote

Im not sure what you mean, Ive tried comparing it to other files but than again I dont have that much experience at this. I tried just leaving sql and result but that doesnt make a difference.
 
alien73







PostPosted: Tue Feb 10, 2009 7:45 pm Reply with quote

did you try this

global $db;

$sql = 'SELECT pid,name, pnum, a1, listp, specialprice, numberstock, stock FROM CCart_products ORDER BY name LIMIT $offset, $searchrows';
$result = $db->sql_query($sql);
 
horrorcode







PostPosted: Tue Feb 10, 2009 8:17 pm Reply with quote

Ah, no I hadnt I got a little overwhelmed, Im going to try to finish it now. Thanks again for all the help, I dont know what to say, you rock
 
alien73







PostPosted: Tue Feb 10, 2009 8:30 pm Reply with quote

What are your plans... Are you doing the changes so you can use CCart yourself or do you have other intentions?
 
horrorcode







PostPosted: Tue Feb 10, 2009 8:44 pm Reply with quote

Just to use it, I was using oscommerce before but got tired of its complexity. It seems alot simpler, plus it seems well thought out. On top of that this has been a great learning experience, Ive tried a couple other coversions in the past and never had one this succesful, your code was nicely wrote from the get go.

I tried what you gave and it worked with inventory.php but not orders.php and Im not sure but I dont think Ill know about ipn until I test?
 
alien73







PostPosted: Tue Feb 10, 2009 8:58 pm Reply with quote

Thanks..

Make sure you change the name of the tables if your cutting and pasting.. You know how coding goes by now... it will drive you nuts if you let it.
 
alien73







PostPosted: Tue Feb 10, 2009 9:01 pm Reply with quote

Another note make sure you include global $db with inventory.php and ipn.php. I rewrote the ipn about 3-4 years ago with more detail but in all honestly I can't remember where I put it :>)
 
horrorcode







PostPosted: Wed Feb 11, 2009 10:56 am Reply with quote

This one Im getting no where fast with, when you go to orders it just echos the "Delete IPN/Order" box, not sure why but Im sure theres not supposed to be 2. I tried global before and after OpenTable just to check, Anyways heres the old code:

Code:


echo "<br>";
OpenTable();
echo "<center>";
echo "<form action=\"delete\" method=\"post\"><select name=\"choice\" size=\"1\">";
$sql = sql_query("select * from CCart_ipn_orders  ORDER BY ipn_id  ");
while(list($ipn_id, $txn_id) = sql_fetch_row($sql)) {
if ($ipn_id == $txn_id){
$sel = "selected ";
}
$delete = "admin.php?op=delete_orders&id=$ipn_id&delete=true";
echo "<option $sel value=\"$delete\">$ipn_id==>$txn_id</option>";
$sel = "";
}
echo "</select>";
echo "<input TYPE=\"button\" VALUE=\"Delete IPN/Order!\" onClick=\"jump(this.form)\"></form>";
echo "</center>";
CloseTable();
echo "<br>";
OpenTable();
search_display($offset,$numresults);
CloseTable();
echo "<br>";
OpenTable();
$link = mysql_connect($dbhost,$dbuname, $dbpass) OR DIE ("Unable To Connect To Database");
mysql_select_db($dbname, $link) OR DIE("Unable To Select To Database");
$sql = "SELECT * FROM CCart_ipn_orders  ORDER BY ipn_id DESC LIMIT $offset,$searchrows ";
$result = mysql_query($sql);
mysql_close($link);
print "<TABLE  BORDER=0 CELLPADDING=1 CELLSPACING=2>";
$even = 0;
while ($row = mysql_fetch_array($result)) {
($even % 2) == 0 ? $bgcolor = "#eeeeee" : $bgcolor = "#FFFFFF";
$even = $even + 1;
print "<TR BGCOLOR=$bgcolor>


And the new, Im thinking something to do with the empty select option, line 12?
Code:


echo "<br>";
OpenTable();
echo "<center>";
echo "<form action=\"delete\" method=\"post\"><select name=\"choice\" size=\"1\">";
$sql = $db->sql_query("select * from CCart_ipn_orders  ORDER BY ipn_id  ");
while(list($ipn_id, $txn_id) = $db->sql_fetchrow($sql)) {
if ($ipn_id == $txn_id){
$sel = "selected ";
}
$delete = "admin.php?op=delete_orders&id=$ipn_id&delete=true";
echo "<option $sel value=\"$delete\">$ipn_id==>$txn_id</option>";
$sel = "";
}
echo "</select>";
echo "<input TYPE=\"button\" VALUE=\"Delete IPN/Order!\" onClick=\"jump(this.form)\"></form>";
echo "</center>";
CloseTable();
echo "<br>";
OpenTable();
search_display($offset,$numresults);
CloseTable();
echo "<br>";
OpenTable();
global $db;

$sql = "SELECT * FROM CCart_ipn_orders  ORDER BY ipn_id DESC LIMIT $offset,$searchrows ";
$result = $db->sql_query($sql);
print "<TABLE  BORDER=0 CELLPADDING=1 CELLSPACING=2>";
$even = 0;
while ($row = $db->sql_fetchrow($result)) {
($even % 2) == 0 ? $bgcolor = "#eeeeee" : $bgcolor = "#FFFFFF";
$even = $even + 1;
print "<TR BGCOLOR=$bgcolor>


Maybe seeing it here will help me realize whats being looked over. Thanks again
 
alien73







PostPosted: Wed Feb 11, 2009 11:19 am Reply with quote

You won't see any orders in the IPN until you get orders from Paypal. There's 2 boxes there and when page fills up you will have one on the top and one on bottom.
 
horrorcode







PostPosted: Wed Feb 11, 2009 11:26 am Reply with quote

Oh...than its working lol...thank you.

What about ipn in root, if you go to the url you get an error, the same error about rnconfig, so I added the require mainfile and it returns another error. With the others in root I added the require/include mainfile and it loads the module page.
 
alien73







PostPosted: Wed Feb 11, 2009 11:37 am Reply with quote

Note you can't see ipn.php in the browser it's only function is to tell Paypal to put the ipn variables from an order in CCart's order table.
 
horrorcode







PostPosted: Wed Feb 11, 2009 1:04 pm Reply with quote

Alright, it works but it doesnt seemto be sending the ipn data back to the site, nothing shows up on the orders page and it doesnt update the quantity/stock, it never shows the customer message either so I dont know.

Im starting a new project right now though, but it does work Ill just have a message stating that all payments have to undergo 24 hour verification. Oh this is the new ipn you had in the scripts.zip btw, I changed the old dbi in there and changed the email addys but that didnt help.
 
alien73







PostPosted: Wed Feb 11, 2009 7:50 pm Reply with quote

You did enter the ipn address in your Paypal account right? Unfortunately CCart doesn't update stock. This was a feature that was planned, but never came about. So I did put the new ipn in the zip file.. cool!

Can you post the ipn code!
 
Palbin
Site Admin



Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania

PostPosted: Wed Feb 11, 2009 8:39 pm Reply with quote

Does the form send the return address or does he need to set it?

_________________
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan. 
View user's profile Send private message
horrorcode







PostPosted: Wed Feb 11, 2009 9:32 pm Reply with quote

Sorry, yeah I entered it in paypal. Hope you finish that stock feature someday, for now its okay though. About the return address I was wondering that myself, it lets you set a return address but it sends some weird stuff back with you in the url, and Id have to test it again to get that.

Code:


<?php
///////////////////////////////////////
//CCart Pro 2.1b IPN updated version 2
//Licenced Under GPL 2003/////////////
//www.theguitarfiles.com/CC/CallowaysCart
//www.theguitarfiles.com//////////////
///////////////////////////////////////
include "config.php";
////////////////////////////////////////////
///////EDIT the 2 email address below////////
$from_email="hcrc@horror-code.com"; //<-------------Enter your email address here
$reply_email="sales@horror-code.com";//<-------------Enter your reply email address here
////////////////////////////////////////////
///////END EDIT////////
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
$ipn_id = $_POST['ipn_id'];
$txn_id = $_POST['txn_id'];
$item_name1 = $_POST['item_name1'];
$item_name2 = $_POST['item_name2'];
$item_name3 = $_POST['item_name3'];
$item_name4 = $_POST['item_name4'];
$item_name5 = $_POST['item_name5'];
$receiver_email = $_POST['receiver_email'];
$item_number1 = $_POST['item_number1'];
$item_number2 = $_POST['item_number2'];
$item_number3 = $_POST['item_number3'];
$item_number4 = $_POST['item_number4'];
$item_number5 = $_POST['item_number5'];
$payment_status = $_POST['payment_status'];
$payment_type = $_POST['payment_type'];
$payment_gross = $_POST['payment_gross'];
$payment_fee = $_POST['payment_fee'];
$tax = $_POST['tax'];
$pending_reason = $_POST['pending_reason'];
$payer_email = $_POST['payer_email'];
$payer_id = $_POST['payer_id'];
$num_cart_items = $_POST['num_cart_items'];
$quantity1 = $_POST['quantity1'];
$quantity2 = $_POST['quantity2'];
$quantity3 = $_POST['quantity3'];
$quantity4 = $_POST['quantity4'];
$quantity5 = $_POST['quantity5'];
$payment_date = $_POST['payment_date'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$address_street = $_POST['address_street'];
$address_city = $_POST['address_city'];
$address_state = $_POST['address_state'];
$address_zip = $_POST['address_zip'];
$address_country = $_POST['address_country'];
$address_status = $_POST['address_status'];
$verify_sign = $_POST['verify_sign'];
$option_name1 = $_POST['option_name1'];
$option_selection1 = $_POST['option_selection1'];
$option_name2 = $_POST['option_name2'];
$option_selection2 = $_POST['option_selection2'];
$memo = $_POST['memo'];
$custom = $_POST['custom'];
$invoice = $_POST['invoice'];
$txn_type = $_POST['txn_type'];
$subscr_id = $_POST['subscr_id'];
$subscr_date = $_POST['subscr_date'];
$subscr_effective = $_POST['subscr_effective'];
$period1 = $_POST['period1'];
$period2 = $_POST['period2'];
$period3 = $_POST['period3'];
$amount1 = $_POST['amount1'];
$amount2 = $_POST['amount2'];
$amount3 = $_POST['amount3'];
$mc_amount1 = $_POST['mc_amount1'];
$mc_amount2 = $_POST['mc_amount2'];
$mc_amount3 = $_POST['mc_amount3'];
$mc_currency = $_POST['mc_currency'];
$mc_gross = $_POST['mc_gross'];
$recurring = $_POST['recurring'];
$recur_times = $_POST['recur_times'];
$password = $_POST['password'];
$username = $_POST['username'];
if (!$fp) {
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
$mailbody.="NOTE:This is an automated customer receipt: Please do not reply\n\n";
$mailbody.="=======================================================\n\n";
$mailbody.="Dear $first_name $last_name,\n";
$mailbody.="Thank you for your recent order with us!\n\n";
$mailbody.="Your order will has be processed \n\n";
$mailbody.="If you have any questions, please contact us: $from_email\n\n";
$mailbody.="Customer ID#: $payer_id \n\n";
$mailbody.="Invoice#: $txn_id\n\nDate/Time Of Order:$payment_date\n\nOrder Details:\n\n";
$mailbody.="=======================================================\n\n";
$mailbody.="Product Description: ($item_name1) \n";
$mailbody.="Item #: ($item_number1) \n";
$mailbody.="Quantity: ($quantity1)\n\n";
if ($item_name2==""){
}else{
$mailbody.="Product Description (2): ($item_name2)\n";
$mailbody.="Item #: ($item_number2) \n";
$mailbody.="Quantity: ($quantity2)\n\n";
}
if ($item_name3==""){
}else{
$mailbody.="Product Description (3):($item_name3) \n";
$mailbody.="Item #: ($item_number3) \n";
$mailbody.="Quantity: ($quantity3)\n\n";
}
if ($item_name4==""){
}else{
$mailbody.="Product Description (4):($item_name4) \n";
$mailbody.="Item #: ($item_number4) \n";
$mailbody.="Quantity: ($quantity4)\n\n ";
}
if ($item_name5==""){
}else{
$mailbody.="Product Description (5):($item_name5) \n";
$mailbody.="Item #: ($item_number5) \n";
$mailbody.="Quantity: ($quantity5)\n\n";
}
$mailbody.="=======================================================\n\n";
$mailbody.="Total Products to be shipped:($num_cart_items)\n\n";
$mailbody.="Total Gross Payment=$$payment_gross \n\n";
$mailbody.="Sales Tax=$$tax\n\n";
$mailbody.="=======================================================\n\n";
$mailbody.="Shipping To Address: \n\n $address_street\n $address_city \n $address_state $address_zip\n $address_country \n\n";
$mailbody.="Your Address is : $address_status by Paypal\n\n";
$mailbody.="=======================================================\n\n";
$mailbody.=" Verify ID: $verify_sign\n\n $first_name - Please print this email for your personal records\n\n Thanks again for shopping with us!\n\n";
mail($payer_email, "Thanks for your order", $mailbody, "From: $from_email\nReply-To: $reply_email");

global $db
$resultat_sql = $db->sql_query("INSERT INTO CCart_ipn_orders(ipn_id,
txn_id,
item_name1,
item_name2,
item_name3,
item_name4,
item_name5, 
receiver_email,
item_number1,
item_number2,
item_number3,
item_number4,
item_number5, 
payment_status,
payment_type,
payment_gross,
payment_fee,
tax,
pending_reason,
payer_email,
payer_id,
num_cart_items,
quantity1,
quantity2,
quantity3,
quantity4,
quantity5, 
payment_date,
first_name,
last_name,
address_street,
address_city,
address_state,
address_zip,
address_country,
address_status,
verify_sign,
option_name1,
option_selection1,
option_name2,
option_selection2,
memo,
custom,
invoice,
txn_type,
subscr_id,
subscr_date,
subscr_effective,
period1,
period2,
period3,
amount1,
amount2,
amount3,
mc_amount1,
mc_amount2,
mc_amount3,
mc_currency,
mc_gross,
recurring,
recur_times,
password,
username )
VALUES ('$ipn_id',
'$txn_id',
'$item_name1',
'$item_name2',
'$item_name3',
'$item_name4',
'$item_name5', 
'$receiver_email',
'$item_number1',
'$item_number2',
'$item_number3',
'$item_number4',
'$item_number5',
'$payment_status',
'$payment_type',
'$payment_gross',
'$payment_fee',
'$tax',
'$pending_reason',
'$payer_email',
'$payer_id',
'$num_cart_items',
'$quantity1',
'$quantity2',
'$quantity3',
'$quantity4',
'$quantity5',
'$payment_date',
'$first_name',
'$last_name',
'$address_street',
'$address_city',
'$address_state',
'$address_zip',
'$address_country',
'$address_status',
'$verify_sign',
'$option_name1',
'$option_selection1',
'$option_name2',
'$option_selection2',
'$memo',
'$custom',
'$invoice',
'$txn_type',
'$subscr_id',
'$subscr_date',
'$subscr_effective',
'$period1',
'$period2',
'$period3',
'$amount1',
'$amount2',
'$amount3',
'$mc_amount1',
'$mc_amount2',
'$mc_amount3',
'$mc_currency',
'$mc_gross',
'$recurring',
'$recur_times', 
'$password',
'$username' )",$db);
}

else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
}
}

fclose ($fp);
}
?>
 
alien73







PostPosted: Wed Feb 11, 2009 9:35 pm Reply with quote

If your referring to the return address of the the customer Paypal sends the address info to the ipn which is then stored in CCart orders table. Or if your referring to his Paypal details? If so he would need to edit he Paypal email etc.. in admin under main settings.
 
alien73







PostPosted: Thu Feb 12, 2009 12:30 am Reply with quote

I took a quick look at the ipn script and you will need to change

lines 142-144

$db = mysql_connect($dbhost,$dbuname, $dbpass);
mysql_select_db($dbname);
$resultat_sql = mysql_query("INSERT INTO CCart_ipn_orders(ipn_id,



to

Global $db;
//->$db = mysql_connect($dbhost,$dbuname, $dbpass);
//->mysql_select_db($dbname);
$resultat_sql = $db->sql_query("INSERT INTO CCart_ipn_orders(ipn_id,



Notice I used //-> to comment out the old database call


Try it and let us know how you make out.
 
alien73







PostPosted: Thu Feb 12, 2009 12:33 am Reply with quote

Please refresh my memory on the return address: Are we talking about a email address or a residence.
 
horrorcode







PostPosted: Thu Feb 12, 2009 12:59 am Reply with quote

Already did that and no dice^^ The address I wonder about is the one paypal uses to return you to the site, yes thats set in admin but it has a funny string behind it when you click return in paypal, I have to replicate it unless you can remember where or what that is? Maybe the ipn api changed too much, are there others still using ccart??
 
horrorcode







PostPosted: Thu Feb 12, 2009 1:11 am Reply with quote

Okay I guess this is paypal sending that string back,
?merchant_return_link=Return+to+HorrorCode
could that have anything to do with ipn?
 
alien73







PostPosted: Thu Feb 12, 2009 7:15 am Reply with quote

I still use the same IPN with my custom NOScart version on our site so it works.

Make sure you have your web address in this format
[ Only registered users can see links on this board! Get registered or login! ]


do you have a live test version?
 
Palbin







PostPosted: Thu Feb 12, 2009 3:06 pm Reply with quote

I was refering to the fact that in the form you can send [ Only registered users can see links on this board! Get registered or login! ] instead of setting it in your paypal preferences.

I'm not 100% certain on this. That is just my limited understanding. The reason for this is that if you have multiple sites then setting it in your preferences would not work.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> eCommerce

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©