Tips and Tricks HQ Support Portal › Forums › WP eStore Forum › How to get buyer's name and email address to be used in PHP code
- This topic has 12 replies, 3 voices, and was last updated 6 years, 7 months ago by
ec999.
-
AuthorPosts
-
August 18, 2018 at 8:32 pm #15033
ec999
MemberHello
I want to sell computer programs as digital downloads. However, each program needs to be activated with a unique activation code specific for the buyer. The buyer’s name is needed to make the activation code, which will be made automatically using PHP code on the Thank You return page.
After the PayPal payment, eStore receives the transaction data including the buyer’s name and email address. I need all this data. How can I obtain the data as variables I can use in the PHP code?
Thank you very much in advance.
Best regards
August 19, 2018 at 3:59 am #78367admin
KeymasterIts better to hook into it after the IPN notification is received (instead of the thank you page). The IPN is a guaranteed event where as the thank you page event is only triggered if the customer doesn’t close the browser before they get to the thank you page.
You can use the following action hook get notified everything an order is processed by estore (after it receives the IPN notification)
eStore_product_database_updated_after_payment
Below is an example snippet of code:
add_action( 'eStore_product_database_updated_after_payment', 'my_custom_code', $ipn_data, $cart_items );
function my_custom_code ($ipn_data, $cart_items) {
//The $ipn_data, $cart_items arrays contain all the useful data.
//Do something with it.
}August 20, 2018 at 8:14 pm #78368ec999
MemberThank you for your response. I think that is just what I need to be able to do what I want.
However, since I have no experience in going into the code of wordpress plugins, I would be happy if you could give me slightly more details – especially in regard to where I should place the above code supplemented with my own extra code.
I do have some experience in PHP coding, but my computer programs are made using PowerBasic for Windows.
Thanks again. So far my experience with eStore has been great. Really a fine plugin!
August 21, 2018 at 3:59 am #78369admin
KeymasterThat is something you will need to handle using the following. I will need to understand what your setup is, what you want the code to do etc.
August 22, 2018 at 4:33 pm #78370ec999
MemberThanks for your response.
I just found “3rd party integration” in the settings section.
If this is activated then eStore will post the IPN(instant payment notification) to the URL specified. I think that would be a good solution for me.
Could the information that I need then be obtained by using the code you provided in your first response? Or is another approach needed?
Thanks.
August 23, 2018 at 4:11 am #78371admin
KeymasterNormally, you would forward the IPN notification to a 3rd party script. Like a PHP script that you have somewhere (on your site or on an external site).
The action hook is something that you can use from a custom plugin’s code. Usually, it is better to add customization via a small custom plugin.
August 24, 2018 at 8:07 pm #78372ec999
MemberYes, I think you are right. A custom plugin using the action hook you provided in your first reply would be the best. I will go for that solution. Thank you.
August 31, 2018 at 7:12 pm #78373ec999
MemberTo get the information of the sale I tried to send the information via email to my self using the following code:
add_action( ‘eStore_product_database_updated_after_payment’, ‘my_custom_code’, $ipn_data, $cart_items );
function my_custom_code ($ipn_data, $cart_items) {
//The $ipn_data, $cart_items arrays contain all the useful data.
//Do something with it.
$message = $ipn_data . ” *** ” . $cart_items;
$message = wordwrap($message, 70, “rn”, TRUE);
$message = str_replace(“n.”, “n..”, $message);
$header = “from:sender@email”;
$subject = “sales data”;
$to = “receiver@email”;
$mail_sent = @mail($to,$subject,$message,$header);
}
However the mail produced only the following: ***
i.e. $ipn_data and $cart_items seemed to be empty variables. Can you explain that? Thanks in advance for your response.
P.S. I have inserted my PDT Identity Token in the PayPal settings.
September 5, 2018 at 10:55 am #78374ec999
MemberI wonder if you have seen my previous post? Can you help me? Thanks
September 6, 2018 at 4:19 am #78375admin
KeymasterThe $ipn_data and $cart_items are array variables. You can’t just put them in a string like the way you have it. Arrays can’t be printed that way. Do a google search to learn how you can add an Array’s content to a string (that should be helpful for you). It is beyond the scope of this forum to provide help on the understanding of PHP coding. Since you are not a PHP coder, please hire a freelancer coder to do your customization.
September 6, 2018 at 7:18 pm #78376ec999
MemberUsing implode to transform the arrays to a string as shown below does not make any difference. The result is still ***. The arrays seem to be empty.
add_action( ‘eStore_product_database_updated_after_payment’, ‘my_custom_code’, $ipn_data, $cart_items );
function my_custom_code ($ipn_data, $cart_items) {
//The $ipn_data, $cart_items arrays contain all the useful data.
//Do something with it.
$message = implode(“*”,$ipn_data) . ” *** ” . implode(“*”,$cart_items);
$message = wordwrap($message, 70, “rn”, TRUE);
$message = str_replace(“n.”, “n..”, $message);
$header = “from:sender@email”;
$subject = “sales data”;
$to = “receiver@email”;
$mail_sent = @mail($to,$subject,$message,$header);
}
September 6, 2018 at 9:13 pm #78377wzp
Moderator@ec999 — Where you define & insert the custom code hook & function matters. As @admin pointed out; “It is beyond the scope of this forum to provide help on the understanding of PHP coding. Since you are not a PHP coder, please hire a freelancer coder to do your customization” …or take him up on the custom work order option:
September 7, 2018 at 7:00 pm #78378ec999
MemberThank you! I will find another solution to what I want to accomplish. I will not bother you any more with my questions.
-
AuthorPosts
- You must be logged in to reply to this topic.