latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

EU VAT

Home Forums Community Forum EU VAT

This topic contains 11 replies, has 2 voices. Last updated by  Robert Feranec 3 years, 8 months ago.

Topic Author Topic
Posted: Saturday Apr 27th, 2013 at 5:32 am #48546

Hello,

I really like your plugin. I have been using it for couple of months and now I have upgraded to the PRO. This is exactly what I need – except one thing. I can not figure out, what would be the simplest way to proceed EU VAT. In the free version I had to use couple of steps/pages to navigate clients through buying process, but now I would like to have only one form. This is what I need:

– If my customer is from my country -> he has to always pay VAT
– If my customer is a company from EU (except my country) -> he doesn’t pay VAT
– If my customer is a person from EU -> he does have to pay VAT
– If my customer is outside EU -> he never pays VAT

Examples (I am from Slovakia):
– A company from Slovakia pays 20% VAT
– A person from Slovakia pays 20% VAT
– A person from Germany pays 20% VAT
– A company from Germany with valid VAT number doesn’t pay 20% VAT
– A person from US doesn’t pay 20% VAT
– A company from US doesn’t pay 20% VAT

The solution I need should look something like this:
1) I have to: add Custom Registration field: Person or Company
2) I have to: add Custom Registration fields: Company & EU VAT
3) I have to: always show country selection in registration form
4) I have to: set up Custom Tax rate for EU countries to 20%
5) I have to: DO NOT APPLY the TAX for EU COMPANIES (except my country) – this is the most difficult step

Any ideas please? Solving this issue may help a lot of your European customers – they all must have same problem.

Thank you very much,
– Robert

List Of Topic Replies

Viewing 11 replies - 1 through 11 (of 11 total)
Author Replies
Author Replies
Posted: Monday Apr 29th, 2013 at 4:29 pm #48666

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

Posted: Monday Apr 29th, 2013 at 10:41 pm #48713
Bruce
Username: Bruce
Staff Member

but the problem is, there is not the custom input field value from the html code – I have added this to the checkout template:

The best way to accomplish what you want here would be to use the second example from this Knowledge Base Article. You’ll want to shy away from editing the PayPal Utilities file.

Knowledge Base » Using Variables In A Shortcode

Posted: Tuesday Apr 30th, 2013 at 1:11 am #48756

Thank you so much Bruce. This is exactly what I need!

Posted: Tuesday Apr 30th, 2013 at 4:34 pm #48818

I have successfully tested your recommendation. Works great!
I have now removed all the changes from paypal-utiilties.inc (you are right, they should not be there) and I will move it to s2-hacks.php (that should not be a problem). I can successfully write and read custom values in the from. Now, I would like to dynamically show the the price – similar like this:

Item price …. XX
Tax …………..YY
———————
Total …………ZZ

Please, is there a way to get the Item price (AMOUNT) in the form? I have been looking around, but I can not find out how to get the amount value inside my custom form template. I would like to show the customer TOTAL (AMOUNT + TAX) before he/she goes to pay. Thank you again.

Posted: Wednesday May 1st, 2013 at 12:19 am #48880
Bruce
Username: Bruce
Staff Member

Please, is there a way to get the Item price (AMOUNT) in the form? I have been looking around, but I can not find out how to get the amount value inside my custom form template. I would like to show the customer TOTAL (AMOUNT + TAX) before he/she goes to pay. Thank you again.

Glad to hear you figured out the first part of this. I’m going to take a look and see if I can get something for you on this right now.

Posted: Wednesday May 1st, 2013 at 12:25 am #48881
Bruce
Username: Bruce
Staff Member

Thanks for your patience.

I talked with the lead developer and (for PayPal) s2Member calculates tax in with everything else in this file:

/s2member-pro/includes/classes/gateways/paypal/paypal-utilities.inc.php

The function that does this is c_ws_plugin__s2member_pro_paypal_utilities::paypal_cost(). So what you’d do here is use the amount you get here minus the ra attribute, and that’ll give you the tax.

Posted: Wednesday May 1st, 2013 at 12:53 am #48883

Thank you very much Bruce. This is not what I am looking for, but it’s interesting to know I can do that too.

What I actually need is to know a way to show “ra” in the form.

For example if I use:
[s2Member-Pro-PayPal-Form level="1" template="eu-vat-paypal-checkout-form.php" ccaps="test" desc="Online Course" ps="paypal" lc="" cc="USD" dg="0" ns="1" custom="www.domain.com" ta="0" tp="0" tt="D" ra="99.00" rp="1" rt="L" rr="BN" rrt="" rra="2" accept="paypal" accept_via_paypal="paypal" coupon="" accept_coupons="0" default_country_code="" captcha="0" /]

I need to show in the form something like:
Online course ………………… 99

Is this possible?

Once I solve this, I will post all the code here, so your other european customers can use it too. Thank you very much for your help.

Posted: Wednesday May 1st, 2013 at 12:56 am #48884
Bruce
Username: Bruce
Staff Member

I need to show in the form something like:
Online course ………………… 99

I see. You’ll have to use the information here to do this:

Pre Sale FAQs » Is it possible to modify s2Member® Pro Form templates?

That will allow you edit what’s shown in the Pro Forms. As far as getting the necessary information there, you might have to use some fancy JavaScript if you want it to update before they submit the form.

Posted: Wednesday May 1st, 2013 at 1:09 am #48886

Thank you for very fast answer. I have created my own template and it works fine. I just don’t know how to get there the “ra” value. I need to know the “ra” for the script and php to calculate and show all the information about VAT directly and dynamically in the form.

Posted: Wednesday May 1st, 2013 at 1:20 am #48887
Bruce
Username: Bruce
Staff Member

I just don’t know how to get there the “ra” value. I need to know the “ra” for the script and php to calculate and show all the information about VAT directly and dynamically in the form.

I’d say the easiest way to do this would be to create a global array of the information you need in PHP from the last piece of code you made before the template, and then use it in the template. s2Member doesn’t pass this attribute directly to the template.

Posted: Wednesday May 1st, 2013 at 1:43 am #48888

ah, oki. I thought its possible, as “desc” is available in template as %%description%%. I will try to figure out how to get the amount value in the template.

Viewing 11 replies - 1 through 11 (of 11 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.