Page 1 of 1

Street address

PostPosted: November 14th, 2011, 12:13 pm
by bethperkins
My client wants to store customer mailing addresses (not Email - street address and city/state). We also do not want customers to have to enter address info twice (billing and mailing address).

I know that the billing address is not stored on the Wordpress database. Is there any way I can get an address to pre-populate from the billing address using either Authorize or PayPal Pro?

Thanks
Beth

Re: Street address

PostPosted: November 16th, 2011, 3:24 pm
by Bruce C
There is a way. What payment gateway are you planning on using?

Re: Street address

PostPosted: November 16th, 2011, 4:20 pm
by bethperkins
My client is leaning towards Authorize.net but I don't have the final answer yet. Will it make a difference in our ability to grab the Bill To address? Thanks for your help

Re: Street address

PostPosted: November 16th, 2011, 9:35 pm
by Bruce C
No, it will not make a difference in if you can. I would suggest adding a user_meta value for the street address using the Pro forms. You can do it like this:


Put this underneath the Pro Form on your page

Code: Select all
<?php
if 
(!empty ($_POST['s2member_pro_authnet_checkout[street]']))
    {
        //Will catch values on the submission of the Pro form ( only for Authorize.net )
        $billingvalue = $_POST['s2member_pro_authnet_checkout[street]'] . "\r\n" . $POST['s2member_pro_authnet_checkout[city]'] . ', ' . $_POST['s2member_pro_authnet_checkout[state]'] . ' ' . $_POST['s2member_pro_authnet_checkout[zip]'];
        //Set a cookie for after checkout
        setcookie('custom_billing_address_value', $billingvalue);
    }
?>


And this in your s2hacks.php file ( under wp-content\mu-plugins\s2hacks.php. If you don't have it, create it. )

Code: Select all
<?php
function billing_user_meta 
($id)
    {
        add_user_meta ($id, 's2member_billing_address', $_COOKIE['custom_billing_address_value']);
    }
add_action ('user_register', 'billing_user_meta');
?>

Re: Street address

PostPosted: November 16th, 2011, 10:54 pm
by Jason Caldwell
I know that the billing address is not stored on the Wordpress database. Is there any way I can get an address to pre-populate from the billing address using either Authorize or PayPal Pro?
Yes, you may need to implement a custom routine of your own for this though. I'm attaching a sample script that might assist you in this regard. Please feel free to follow-up if you have other questions about how this sample script works.

Create this directory and file:
/wp-content/mu-plugins/my-s2-pro-form-processor.php
( these are MUST USE plugins, see: http://codex.wordpress.org/Must_Use_Plugins )
Code: Select all
<?php
add_action 
("ws_plugin__s2member_during_configure_user_registration_front_side_paid", "my_s2_pro_form_processor");
function my_s2_pro_form_processor ($vars = array ())
    {
        $user_id = /* Grab User's new ID in WordPress®. */ $vars["user_id"];
        /**/
        if (isset /* PayPal Checkout. */ ($_POST["s2member_pro_paypal_checkout"]))
            $s2_co_vars = $_POST["s2member_pro_paypal_checkout"];
        /**/
        else if /* Or, this for Authorize.Net. */ (isset ($_POST["s2member_pro_authnet_checkout"]))
            $s2_co_vars = $_POST["s2member_pro_authnet_checkout"];
        /**/
        if (isset ($s2_co_vars) && is_array ($s2_co_vars) && ($s2_co_vars = c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($s2_co_vars))))
            {
                /* Original Shortcode Attributes for the Pro Form. Might be useful in some cases. */
                $s2_sc_attrs = unserialize (c_ws_plugin__s2member_utils_encryption::decrypt ($s2_co_vars["attr"]));
                /**/
                $email = $s2_co_vars["email"];
                $username = $s2_co_vars["username"];
                $first_name = $s2_co_vars["first_name"];
                $last_name = $s2_co_vars["last_name"];
                /**/
                $custom_fields = /* Array of all Custom Fields. */ $s2_co_vars["custom_fields"];
                /**/
                $customer_age = /* Now, a specific Custom Field. */ $custom_fields["customer_age"];
                /* Use the Unique ID you gave a Custom Registration Field ( ex: `customer_age` ). */
                /**/
                $card_type = $s2_co_vars["card_type"];
                $card_number = $s2_co_vars["card_number"];
                $card_expiration = $s2_co_vars["card_expiration"];
                $card_verification = $s2_co_vars["card_verification"];
                $card_start_date_issue_number = $s2_co_vars["card_start_date_issue_number"];
                /**/
                $street = $s2_co_vars["street"];
                $city = $s2_co_vars["city"];
                $state = $s2_co_vars["state"];
                $country = $s2_co_vars["country"];
                $zip = $s2_co_vars["zip"];
                /**/
                /* Now you might store information of your own. */
                /* http://codex.wordpress.org/Function_Reference/update_user_option */
                update_user_option ($user_id, "customer_age", $customer_age);
                /**/
                /* You might retrieve this in the future with this function. */
                /* http://codex.wordpress.org/Function_Reference/get_user_option */
                $customer_age = get_user_option ("customer_age", $user_id);
            }
    }
?>
my-s2-pro-form-processor.zip
(1023 Bytes) Downloaded 28 times

Re: Street address

PostPosted: November 17th, 2011, 7:42 am
by bethperkins
Thank you!

Re: Street address

PostPosted: November 27th, 2011, 10:07 pm
by bethperkins
OK - I tried to implement both of these approaches and was not successful. I was unable to create the cookie in the first option.
In the second option, I copied the file above and added the code to update the data fields like so
Code: Select all
   update_user_option ($street, "customer_street", $customer_street);
   update_user_option ($city, "customer_city", $customer_city);
   update_user_option ($state, "customer_state", $customer_state);
        update_user_option ($zip, "customer_zip", $customer_zip);


and I installed the file my_s2_pro_form_processor.php in my mu-plugins folder but I don't believe the data is being stored. Can you tell me if there is something else that I need to do?

Beth

Re: Street address

PostPosted: November 28th, 2011, 4:29 pm
by bethperkins
Got it working! I combined suggested use of add_user_meta from Ace Of Spades and the form processor function from Jason and each of the Bill To fields are now in the user meta table on my database! Two quick questions - how do I update the user screen to display them and would it be possible to also store the coupon code? My customer wants to track the use of coupon codes

Re: Street address

PostPosted: December 13th, 2011, 4:15 pm
by colinp386
Jason et al.

Another Pro Forms user here, that's not quite so skilled at the programming side of things.
Seems to me that the lack of an option to pre-populate basic CC information (street, city, state, zip) from a members profile is strangely lacking. Is this on your to-do list?
If not a little more help would be appreciated.
I know how to add the my-s2-pro-form-processor.php file to the must_use directory, but am struggling to figure out how to implement it, such that when a user fills out the initial registration form that has address, city etc. that I can then have a button on it to populate the address info into the billing section. And for those who are upgrading from say level 0 to level 1 via the upgrade form can again select a button to populate the billing fields.
In addition (perhaps a new topic) The billing forms don't give the option to have a different User Name to Billing Name. This is going to cause an issue for our Corporate clients who often use a colleagues Corp. Credit Card to bill our services.

Thanks
Colin

Re: Street address

PostPosted: December 13th, 2011, 4:26 pm
by Eduan
@Colin
So what you want to do is add fields like city, zip etc.?
If so you can do so from WP Admin -> s2Member -> General Options -> Registration/Profile Fields & Options.

Hope this helps. :)

Re: Street address

PostPosted: December 13th, 2011, 5:52 pm
by colinp386
Not quite Eduan; :-)

I already have those fields included in their profile.
I am wanting the user data from those fields to populate into the BILLING fields when they pay by Credit Card.

C.

Re: Street address

PostPosted: December 15th, 2011, 8:26 pm
by Jason Caldwell
colinp386 wrote:Seems to me that the lack of an option to pre-populate basic CC information (street, city, state, zip) from a members profile is strangely lacking. Is this on your to-do list?
If not a little more help would be appreciated.
While it's true that you can hack this in, making it possible with s2Member, it's not something that the current release of s2Member makes possible in a default installation. The storage of this personally identifiable information; including, but not limited to CC numbers, expiration dates, street, city, state, zip; is intentionally stored within your Payment Gateway, and NOT within WordPress.

In addition (perhaps a new topic) The billing forms don't give the option to have a different User Name to Billing Name. This is going to cause an issue for our Corporate clients who often use a colleagues Corp. Credit Card to bill our services.
I think you mean "First/Last Name". Yes, this is a known issue. We are working to improve this for a future release. The Billing First/Last Name will go into the Customer's profile for WordPress. While it's possible for a Customer to change this after logging in the the first time, ideally we would give the Customer a chance to use separate billing details during checkout.

Re: Street address

PostPosted: December 15th, 2011, 9:04 pm
by colinp386
Hi Jason,

Thanks for the reply, I guess I may not have explained as well as I might.
I totally get that one does not want to hold PIM information in the database for sure as heck not CC number :-)

However;
When a new subscriber signs up if we are asking for profile Address, Town, State, ZiP etc they are currently forced to enter it all again in the Billing Section.
What I'm looking for is a button or tick box which is common on many forms that says that the Profile and Billing Address is the same, so they don't have to enter twice. I guess this can be done with javascript.
I'm not looking for the billing info to be stored in the db.

Re 2 yes I did mean "First/Last Name" thanks for the heads up that your on this :-) Yay