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.

Fixed date of year membership term?

Home Forums Community Forum Fixed date of year membership term?

This topic contains 6 replies, has 2 voices. Last updated by  Antoine Houdaille 4 years, 10 months ago.

Topic Author Topic
Posted: Tuesday Feb 14th, 2012 at 10:27 pm #5135

Hi,

we bought the plugin (pro) for a club web site, but may have made a mistake..

The use case here is as follows
– Memberships all end at the same date 30 June.
– From January to June membership price is lower (because it’ll end in June)
– From July to December membership price is full.
– We need to keep the actual registration date somewhere
– But want to manage renewals for everyone in June

Now that we are trying to implement this with the plugin, we are not finding how to achieve this, or if it’s possible.

Did we miss something ? Or is there a workaround to this ?

Would it be ok, for example, to create and schedule some code/task on our server that would update the database to:
– copy the actual registration date to a custom field
– set the registration date to the beginning of the current membership year (maybe based on a field defined by an admin)

And would that impact the renewal/reminder process ?

also, even if members have paid the reduced price for their membership because they joined late in the year, they are supposed to pay full rate when renewing. Does this mean we’d need to also alter this value in the database so that renewal not be at the reduced price ?

Thanks for your help !

Antoine :)

List Of Topic Replies

Viewing 6 replies - 1 through 6 (of 6 total)
Author Replies
Author Replies
Posted: Wednesday Feb 15th, 2012 at 4:40 pm #5262
David Welch
Username: dwbiz05

I would create a function to manipulate the paypal button info when the button is loaded each time.

For example, create a function that checks the current date.

If the current date is Jan-June then it sets the lower price as the “trial period” that ends June 30th (may need to calculate the exact days on that as well.)

Then it would set the regular price to be set as due immediately after trial ends and is an annual payment.

That way, no matter when they join, the paypal subscription would end on June 30th automatically.

I think that would do what you want. It make take some trial and error to get the timing right with the paypal subscription.

Dave

Posted: Wednesday Feb 15th, 2012 at 6:45 pm #5287

Thanks for the reply Dave,

Sounds like this would allow us to not only manage the different prices depending on registration date – which, for now, we intended to cater for by offering 2 sets of prices (in 2 tabs).. but also adjust the membership end date to make it coincide with the clubs term of end june. Sounds great !

I have no idea how to create/add such a function though, may need to do a bit of reading. Can you point to what I/we should read to learn about functions and the trial thing and setting the end date and price for next term ?

thanks again

Antoine

PS: you just won a book, The End Of Business As Usual, by Brian Solis – send your mailing address to antoineh at igo2group.com and I’ll ship it :)

Posted: Wednesday Feb 15th, 2012 at 7:29 pm #5292
David Welch
Username: dwbiz05

You’ll need to write a php function (my opinion) and put it in the functions.php file of your theme.

I’ll see if I can put something together when I get a chance later tonight.

Really shouldn’t be extremely difficult, just don’t have the time at the moment… lol.

The tricky part will be getting the new subscription price to start on the right date with PayPal’s system.

Are you using Pro of either s2member or Paypal?

Dave

  • This reply was modified 4 years, 10 months ago by  David Welch.
  • This reply was modified 4 years, 10 months ago by  David Welch.
Posted: Wednesday Feb 15th, 2012 at 7:47 pm #5298

Thanks Dave, that would be great !

We have bought s2member pro.. but trying to avoid paypal pro for now.

Does this sound like something I should ask the plugin developers about too ?

cheers

Antoine

Posted: Thursday Feb 16th, 2012 at 1:54 am #5318
David Welch
Username: dwbiz05

OK

Well, let me say that PayPal does not make this easy.

1. They don’t allow trial periods over about 90 days if you are using the ‘D’ option.
2. They don’t allow second trial periods with no payment ($0.00).

Here is what, in my attempt, has to be done.

1. Create a trial period in MONTHS for the remaining months until July 1. Charge the full or reduced price, depending on the current month.
2. Create a second period in DAYS to run off any remaining days in June. Charge a $0.01 fee for paypal to accept the second trial period.
3. Set the standard rate and time period of 1 year that *should* start on July 1.

Now, to the code:

s2member doesn’t accept a second trial period. I don’t know if it matters if you add one or not, but it’s not an option in their button builder (at least not free).

NOTE: I’m on the free version of s2member and even then, the following code has only been minimally tested. I do not claim it’s perfection but it seemed to work for me in initial tests:

Basically, I’ve created a few functions along with a shortcode that you *should* be able to use to do what you want.

First, the shortcode:

[equal-time-pp full='' part='' code='']

This is the shortcode you use to place your buttons on the page/post.

3 Variables are available… really required.
1. full – This is the full amount you charge with trailing zeros. Example: 50.00
2. part – This is the partial payment you charge for Jan. – June registrations. Same format as above.
3. code – This is the s2member shortcode you can generate in the paypal button generator in s2member. NOTE: do not use the “[” or “/]” tags… just copy everything else in between them.

EXAMPLE S2MEMBER SHORTCODE:

[s2Member-PayPal-Button level="1" ccaps="" desc="." ps="paypal" lc="" cc="USD" dg="0" ns="1" custom="" ta="5.00" tp="1" tt="D" ra="10.00" rp="1" rt="Y" rr="1" rrt="" rra="1" image="default" output="button" /] 

ONLY COPY THIS:

s2Member-PayPal-Button level="1" ccaps="" desc="." ps="paypal" lc="" cc="USD" dg="0" ns="1" custom="" ta="5.00" tp="1" tt="D" ra="10.00" rp="1" rt="Y" rr="1" rrt="" rra="1" image="default" output="button"

SO THE NEW SHORTCODE WOULD LOOK LIKE THIS:

[equal-time-pp full='50.00' part='30.00' code='s2Member-PayPal-Button level="1" ccaps="" desc="." ps="paypal" lc="" cc="USD" dg="0" ns="1" custom="" ta="5.00" tp="1" tt="D" ra="10.00" rp="1" rt="Y" rr="1" rrt="" rra="1" image="default" output="button"']

Clear as MUD? lol!

Now, you need to add this code probably to your functions.php file. It’s php code so make sure it’s inside the starting and ending php tags.

THE CODE:

function equal_time_pp_form($atts){
	
	extract( shortcode_atts( array(
		'full' => '0.01',
		'part' => '0.01',
		'code' => '[s2Member-PayPal-Button /]',
	), $atts ) );
	
	$full_price = $full; //full year membership
	
	$partial_price = $part; //half year membership

	$code = '['.$code.' /]';
	//This assumes full payment
	$first_trial_price = $full_price;

	//Calculate number of days through June 30.
	$month = date("n");
	
	//Get the number of days for second trial
	//Or first trial if less than 1 month
	$trial_days = trial_days();
	
	//Check what time of year current month is in
	if($month >= 7){
		//Add 6 months to first trial if after June 30
		$pay_months = (12 - $month) + 6;
	}
	else {
		//Months before June 30
		$pay_months = 6 - $month;
		
		//This is the short-term price for Jan - June.
		$first_trial_price = $partial_price;	
	}
	
	//Set Trial Info
	if($pay_months == 0){
		$first_trial_time = $trial_days;
		$first_trial_type = 'D';
		$first_trial_amount = $first_trial_price;
		$second_trial_time = $trial_days;
		$second_trial_type = 'D';
		$second_trial_amount = '0.01';
		$normal_time = '1';
		$normal_type = 'Y';
		$normal_amount = $full_price;
	}
	else {
		$first_trial_time = $pay_months;
		$first_trial_type = 'M';
		$first_trial_amount = $first_trial_price;
		$second_trial_time = $trial_days;
		$second_trial_type = 'D';
		$second_trial_amount = '0.01';
		$normal_time = '1';
		$normal_type = 'Y';
		$normal_amount = $full_price;
	}

	/* REPLACE SHORTCODE INFO WITH TRIAL INFO */
	$code = preg_replace('/ta=".*?"/','ta="'.$first_trial_amount.'"', $code);
	$code = preg_replace('/tp=".*?"/','tp="'.$first_trial_time.'"', $code);
	$code = preg_replace('/tt=".*?"/','tt="'.$first_trial_type.'"', $code);
	$code = preg_replace('/ra=".*?"/','ra="'.$normal_amount.'"', $code);
	$code = preg_replace('/rp=".*?"/','rp="'.$normal_time.'"', $code);
	$code = preg_replace('/rt=".*?"/','rt="'.$normal_type.'"', $code);
	
	//Add Hack to Include 2nd Trial
	add_action('ws_plugin__s2member_during_sc_paypal_button','edit_paypal_form');
	
	//Run modified s2member shortcode
	$pp_form = do_shortcode($code);
	
	//Remove Second Trial Hack To Keep From Affecting Other Forms
	remove_action('ws_plugin__s2member_during_sc_paypal_button','edit_paypal_form');
	
	//Send form to browser
	return $pp_form;

}

add_shortcode('equal-time-pp','equal_time_pp_form');

function edit_paypal_form($vars=array())
{
	//Second Trial Variables
	$second_trial_time = trial_days();		
	$second_trial_type = 'D';		
	$second_trial_amount = '0.01';
	
	//Extra Code Added To S2Member PP Form
	$extra_items = '  ';
	
	//Replace With New Code
	$new_code = str_replace("",$extra_items,$vars['code']);

	//Upate PP Form Code
	$vars['code'] = $new_code;
}

function trial_days(){
	
	//Get number of days left in June
	$day = date("d");
	
	if($day > 30){
		$day = 30;
	}
	
	//Have to use 32 to make Paypal work right... I think.
	$trial_days = 32 - $day;
	
	return $trial_days;
}

Whew! That took a lot longer than I thought and of course, no guarantee it’s perfect but it seems it can be done… somehow.

LOL!

Dave

  • This reply was modified 4 years, 10 months ago by  David Welch.
Posted: Thursday Feb 16th, 2012 at 6:22 am #5356

Dave,

thanks heaps for your time and effort here, really appreciated. I hope my favorite developer can put this to use asap !

Antoine :)

Viewing 6 replies - 1 through 6 (of 6 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.