susan767 Posted February 6, 2009 Share Posted February 6, 2009 Hi, I am trying to set up a small online store and earnestly looking for help with PHP coding. I have uploaded related image files and php files as attachments. My invoice email is created by reading a variable from two different php files according to the payment method (Cash on Delivery or Paypal) The invoice is created properly when the customer pays with Cash on Delivery (Exhibit A) but missing information in the invoice paid with PayPal (Exhibit B). As you can see, PayPal invoice (Exhibit B) is missing Sub-Total, Delivery method and Total amount. The file that creates html is html_checkout_process.php. The corresponding information is written by a single variable $Vartaxe and Line 53 contains the html code (I've also remarked it with lots of ***'s) $Vartaxe is read from one of the two files, according to the payment method. 1. When payment is Cash on Delivery: checkout_process.php (This is working properly, corresponds to Exhibit A) Line 236 (remarked with lots of ***'s) contains the statement related to $Vartaxe. This is the file's only statement associated with $Vartaxe. 2. Whey payment is made with PayPal: paypal_standard.php (The problem file. Corresponds to Exhibit B) Line 515 (remarked with lots of ***'s) contains the statement related to $Vartaxe. This is the file's only statement associated with $Vartaxe. It looks like the information is not being captured properly in the second case because the variables are not properly declared and/or used. Any suggestion and advice regarding solving the problem would be highly appreciated. Susan [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/144010-need-help-with-variable-not-being-read-properly/ Share on other sites More sharing options...
Ninjakreborn Posted February 6, 2009 Share Posted February 6, 2009 Those two PHP files seem fine. They are exactly handling the vartaxes the same on both pages. What you need to do is copy/paste the code for the form(s) that are used to submit this data into the php files. I want to see how the data is getting passed. My guess is it's passing it a little bit different in the two types of payment methods and I would like to take a look at it and see if there is a way to tell. Quote Link to comment https://forums.phpfreaks.com/topic/144010-need-help-with-variable-not-being-read-properly/#findComment-755698 Share on other sites More sharing options...
susan767 Posted February 6, 2009 Author Share Posted February 6, 2009 Those two PHP files seem fine. They are exactly handling the vartaxes the same on both pages. What you need to do is copy/paste the code for the form(s) that are used to submit this data into the php files. I want to see how the data is getting passed. My guess is it's passing it a little bit different in the two types of payment methods and I would like to take a look at it and see if there is a way to tell. Thanks for your reply. Yes, vartaxes are being handled identically in both files, but my guess is that in lines 50-55 of checkout_process.php, it's calling the before_process() routine before calculating order_totals. However, in paypal_standard.php, it's trying to use order_totals inside the before_process routine, ie. before they're defined. If there's any other file that you would like to see, I'd be more than happy to provide. Susan Quote Link to comment https://forums.phpfreaks.com/topic/144010-need-help-with-variable-not-being-read-properly/#findComment-755706 Share on other sites More sharing options...
gizmola Posted February 6, 2009 Share Posted February 6, 2009 Susan, First off, I glanced at html_checkout_process. This entire file does absolutely nothing other than interpolate a big string. While this has nothing to do with your question, there's just a much better way to do what you're doing there, and it's called a HEREDOC. Heredocs will interpolate values the same way as using " stuff $var stuff". You do this: $myvar = Put my html in here, and mix in vars like $var as I like. no need for escaping. Here's more stuff! Isn't this better! HERE; $echo $myvar; Secondarily, this is just oscommerce code --- so you should be posting in the 3rd party scripts section, as this isn't code you wrote is it? All things considered, I think the most likely explanation is that you have a configuration issue with your server, or paypal or both. There's no point in us trying to debug code that is part of a well known ecommerce system. Needless to say there's a huge difference in just indicating COD where there's nothing that needs to happen, vs. paypal where the paypal servers are being called and results are being stored. Quote Link to comment https://forums.phpfreaks.com/topic/144010-need-help-with-variable-not-being-read-properly/#findComment-755722 Share on other sites More sharing options...
susan767 Posted February 6, 2009 Author Share Posted February 6, 2009 Susan, First off, I glanced at html_checkout_process. This entire file does absolutely nothing other than interpolate a big string. While this has nothing to do with your question, there's just a much better way to do what you're doing there, and it's called a HEREDOC. Heredocs will interpolate values the same way as using " stuff $var stuff". You do this: $myvar = <<<HERE Put my html in here, and mix in vars like $var as I like. no need for escaping. Here's more stuff! Isn't this better! HERE; $echo $myvar; Secondarily, this is just oscommerce code --- so you should be posting in the 3rd party scripts section, as this isn't code you wrote is it? All things considered, I think the most likely explanation is that you have a configuration issue with your server, or paypal or both. There's no point in us trying to debug code that is part of a well known ecommerce system. Needless to say there's a huge difference in just indicating COD where there's nothing that needs to happen, vs. paypal where the paypal servers are being called and results are being stored. Thanks for your advice on HEREDOC, I'll try to implement it. As for the third party script section, I did not know that such forum existed. Sorry about that. Is there a way to "move" this topic to that board? Getting back to the issue, I understand that there is a significant difference between COD and PayPal in terms of data exchange, but the information that I'm missing originates from my side and PayPal server does not alter any. Therefore, I should be able to simply retrieve it and print it out, as in the COD case. That's all I want to do. Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/144010-need-help-with-variable-not-being-read-properly/#findComment-755727 Share on other sites More sharing options...
gizmola Posted February 6, 2009 Share Posted February 6, 2009 Susan, First off, I glanced at html_checkout_process. This entire file does absolutely nothing other than interpolate a big string. While this has nothing to do with your question, there's just a much better way to do what you're doing there, and it's called a HEREDOC. Heredocs will interpolate values the same way as using " stuff $var stuff". You do this: $myvar = Put my html in here, and mix in vars like $var as I like. no need for escaping. Here's more stuff! Isn't this better! HERE; $echo $myvar; Secondarily, this is just oscommerce code --- so you should be posting in the 3rd party scripts section, as this isn't code you wrote is it? All things considered, I think the most likely explanation is that you have a configuration issue with your server, or paypal or both. There's no point in us trying to debug code that is part of a well known ecommerce system. Needless to say there's a huge difference in just indicating COD where there's nothing that needs to happen, vs. paypal where the paypal servers are being called and results are being stored. Thanks for your advice on HEREDOC, I'll try to implement it. As for the third party script section, I did not know that such forum existed. Sorry about that. Is there a way to "move" this topic to that board? Getting back to the issue, I understand that there is a significant difference between COD and PayPal in terms of data exchange, but the information that I'm missing originates from my side and PayPal server does not alter any. Therefore, I should be able to simply retrieve it and print it out, as in the COD case. That's all I want to do. Thanks again I can move it there, so I will do that if this goes on further. In answer to your question this code starting at line 49 or so is where all the calculation occurs. / load the before_process function from the payment modules $payment_modules->before_process(); require(DIR_WS_CLASSES . 'order_total.php'); $order_total_modules = new order_total; $order_totals = $order_total_modules->process(); So for whatever reason, $order_totals, which is expected to be an array of strings, apparently is empty when it processes. The code for the order_total class is in order_total.php, which you didn't include. As oscommerce appears to be a rats nest with a mindboggling number of global variables it is relying on, again the most logical explanation is that there's something happening inside the factory class that's different when it's paypal. Again glancing at the paypal script, there are calls being made and files being generated and all sorts of stuff that could fail due to simple things like permissions or php.ini settings that prevent the use of fopen(). Quote Link to comment https://forums.phpfreaks.com/topic/144010-need-help-with-variable-not-being-read-properly/#findComment-755743 Share on other sites More sharing options...
susan767 Posted February 6, 2009 Author Share Posted February 6, 2009 I can move it there, so I will do that if this goes on further. In answer to your question this code starting at line 49 or so is where all the calculation occurs. / load the before_process function from the payment modules $payment_modules->before_process(); require(DIR_WS_CLASSES . 'order_total.php'); $order_total_modules = new order_total; $order_totals = $order_total_modules->process(); So for whatever reason, $order_totals, which is expected to be an array of strings, apparently is empty when it processes. The code for the order_total class is in order_total.php, which you didn't include. As oscommerce appears to be a rats nest with a mindboggling number of global variables it is relying on, again the most logical explanation is that there's something happening inside the factory class that's different when it's paypal. Again glancing at the paypal script, there are calls being made and files being generated and all sorts of stuff that could fail due to simple things like permissions or php.ini settings that prevent the use of fopen(). Yes, I think it would be better to continue this topic in the proper forum. Thanks for your attention. I'm attaching order_total.php hoping that it can provide a clue for resolving the problem. Susan [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/144010-need-help-with-variable-not-being-read-properly/#findComment-755747 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.