Please, any news on this? I moved ahead a little bit, but I have problem to store the custom fields.
What I have done:
In paypal-utiilties.inc.php i have updated paypal_cost function:
public static function paypal_cost($trial_sub_total = FALSE, $sub_total = FALSE, $state = FALSE, $country = FALSE, $zip = FALSE, $currency = FALSE, $desc = FALSE)
{
//!rf $state = strtoupper(c_ws_plugin__s2member_pro_utilities::full_state($state, ($country = strtoupper($country))));
$rates = strtoupper($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_tax_rates"]);
$default = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_default_tax"];
//!rf START - EU VAT patch
$rates = '';
$eu_my_country = 'SK';
$eu_vat_my_country_rate = '20%';
$eu_countries = array(
'AT','BE','BG','CY','CZ','DK','EE','FI','FR','DE','GR','HU','IE',
'IT','LV','LT','LU','MT','NL','PL','PT','RO','SK','SI','ES','SE','GB');
$country_tmp = $country;
if (!in_array($country, $eu_countries)) //is from EU?
$default = '0%'; //it's ouside eu
else if ($country == $eu_my_country) //is from your country?
$default = $eu_vat_my_country_rate; // yes, it's from my country
else if ($state == '-') //is it a person or company? => check if EU VAT has "-"
$default = $eu_vat_my_country_rate; //it's a person from eu
else
$default = '0%'; //it's a company from eu
//!rf END
$ps = _x("%", "s2member-front percentage-symbol", "s2member");
As I dont need the State input, I use it to transfer the EU VAT to the paypal_cost function to calculate the tax. This works nicely (to be able to see the TAX calculation in form, I had to put a Tax value into Paypal -> Options -> Tax rate calculations)
Only what I have to do now is store additonal custom fields during checkout – e.g . the EU VAT and some billing info. I am able to hook and write to database and check $vars or $_POST like this:
add_action('ws_plugin__s2member_during_paypal_notify_during_subscr_signup_w_update_vars', 'store_my_custom_input_fields');
function store_my_custom_input_fields($vars = array())
{
$user = $vars['user']; // A WP_user object instance.
// Get an array of all the users' s2Member Custom Fields
$custom_fields = get_user_option('s2member_custom_fields',$user->ID);
// Set the value for a specific field ($custom_fields is an array)
$custom_fields['eu_vat_number'] = 'works22:'.print_r($_POST,TRUE); //used for debugging
// Update the Custom Field data
update_user_option($user->ID, "s2member_custom_fields", $custom_fields);
}
but the problem is, there is not the custom input field value from the html code – I have added this to the checkout template:
<label for="eu_vat_number">EU VAT (optional):</label>
<input type="text" name="eu_vat_number" id="eu_vat_number" />
I believe, this is the problem:
1) if I use ws_plugin__s2member_during_paypal_notify_during_subscr_signup_w_update_vars I will not
be able to catch the right $_POST which has the eu_vat_number. Is there a way how I can transfer it in $vars and read after the payment?
2) I can see the eu_vat_number in $_POST directly after a click on Check out with Paypal Button … but, I am not able to find any hook, which is working after that. I found, this should work ws_plugin__s2member_before_paypal_api_response but doesnt :( Do I have to clear cache or set something to be able to use the ws_plugin__s2member_before_paypal_api_response hook?
Please, any ideas? I really need to finish this Checkout page this week. Thank you very much.
– Robert