Jump to content

Need help with variable not being read properly


susan767

Recommended Posts

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]

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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. 

 

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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().

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.