Tips and Tricks HQ Support Portal › Forums › WP eStore Forum › post-payment processing does not read session cookie
Tagged: custom fields
- This topic has 4 replies, 2 voices, and was last updated 10 years, 1 month ago by mcb927.
-
AuthorPosts
-
October 5, 2014 at 11:51 pm #11562mcb927Member
I use custom forms to collect customer data (used to create PDF documents), and my customers are identified by session cookies. When the forms are complete and the customer wants to purchase the final output, I use echo print_eStore_buy_now_button($doc) to send the customer to PayPal, make the purchase, and return to the site. On the eStore’s paypal.php page, I want to read the session cookie with my customer’s ID and insert it into an unused field in the eStore’s customer table. On line 16 of paypal.php I use this to read the cookie: $uidVal = $_SESSION;. On line 662 (understanding that inserting my code on line 16 has changed the line numbering) I assign my cookie value to your variable $eMember_username. It always comes up blank when I look at the table using phpMyAdmin. I don’t understand why this isn’t working to get my session cookie value into the table.
October 6, 2014 at 9:20 pm #65849adminKeymasterThe IPN is a background post so you can’t read the COOKIE values there. You will need to pass the userid value via the custom field so you have access to it in the post-payment processing script.
Here is an example snippet of code:
add_filter('eStore_custom_field_value_filter', 'add_my_custom_value');
function add_my_custom_value($custom_field_val)
{
$custom_field_val .= '&attyuserid=' . $_SESSION['attyuserid'];
return $custom_field_val;
}Now you will have that value available to you in the post payment processing script. Are you familiar with reading PayPal’s IPN message?
October 7, 2014 at 2:42 am #65850mcb927MemberThank you! I will give that a try. I am familiar with the IPN message from reading through the eStore code looking for a solution. I don’t use the IPN myself – I’m trying to keep things as simple and streamlined as possible – just make use of what is there.
October 8, 2014 at 3:17 am #65851mcb927MemberIt looks like I just don’t know where to put the add_filter code or where to call it from or just how to use it. I added the code snippet above to eStore_misc_functions.php, and I’m not sure how to work with calling the custom field value in paypay.php. I try to avoid messing with any wordpress, theme, or plug-in code and primarily just work with forms and php functions to get and store database info. Could you either point me to a tutorial for working with the add_filter code or let me know more about how to use it? Thank you.
October 8, 2014 at 9:54 pm #65852mcb927MemberI have resolved the issue I was having. I found that the page wp_eStore1.php has several lines of code working with the custom field function similar to what your code snippet is doing. The page reads several session cookie values. Following the examples from that page, I added these lines of code right before the function closes and the assembled $custom_field_val variable is returned:
if(!empty($_SESSION))
{
$name = ‘attyuserid’;
$value = $_SESSION;
$custom_field_val = append_values_to_custom_field($name,$value);
}
After that change, I found where paypal.php reads and assigns values to variables for use in the SQL INSERT query. Again following the examples there (specifically the one that reads the IP address), I added these lines of code:
$customer_attyid = $customvariables;
if(empty($customer_attyid)){$customer_attyid = “No atty ID”;}
On paypal.php I was then able to assign the value of $customer_attyid to the variable $member_username (we are not using eMember) and store the customer ID. It works very well. Hopefully this might help someone else with the same or similar question I had. Thanks again for your help; it pointed me in the right direction.
-
AuthorPosts
- You must be logged in to reply to this topic.