Fixed Subscription Renewal Date with 1 year term

Hi all,

We offer an annual subscription to our club members (using Stripe Pro Forms), with a fixed renewal date each year (December 31st). We let our users subscribe at any point during the year, but their membership must be renewed on the 31st for insurance purposes.

I have followed this article, which sets a fixed EOT and it works great:-

The problem is that this method sets the renewal period to the original number of days. So if a user registers on December 1st, they will renew on the 31st (30 days later) as expected. But they will then automatically be renewed every 30 days after that. Is there any work around for this?

Our form code is as follows:
[s2Member-Pro-Stripe-Form rp=“1” rt=“Y” rr=“1” accept_coupons=“1”]
[s2Member-Pro-Stripe-Form level=“1” ccaps="" desc=“€20 EUR / Yearly (recurring charge, for ongoing access)” cc=“EUR” custom="—" ta=“0” tp=“0” tt=“D” ra=“20” rp="[php]echo $days_until_fixed_eot_time;[/php]" rt=“D” rr=“1” coupon="" accept_coupons=“0” default_country_code=“US” captcha=“0” /]
[s2Member-Pro-Stripe-Form level=“2” ccaps="" desc=“€15 EUR / Yearly (recurring charge, for ongoing access)” cc=“EUR” custom="—" ta=“0” tp=“0” tt=“D” ra=“15” rp="[php]echo $days_until_fixed_eot_time;[/php]" rt=“D” rr=“1” coupon="" accept_coupons=“0” default_country_code=“US” captcha=“0” /][/s2Member-Pro-Stripe-Form]

I may be over complicating things, but in effect, we would like to offer members a paid trial (for €20) up to December 31st each year and then auto renew annually (for €20).

Any help would be greatly appreciated.

Thank you

This is absurd. Has it really been three years without any kind of response to this common, unresolved issue?

The linked article does not indicate how to set the RENEWAL date while keeping the renewal period at 1 YEAR. This is a very simple requirement. What we want is a set renewal date (so effectively the first subscription term should be shorter or longer than the rest) followed by a fixed date every year (not 365 days, which will be screwed up by leap years - a specific date).

Hi Wordcrunch, I did make a little progress on this with the wpsharks guys via support (who were very helpful in fairness to them). There were two problems - first was manually setting the renewal date to 01/01/YEAR - this just took a little bit of PHP to calculate the number of days to the EOY. It works well. The second issue was that when you subscribe, the payment gateways (Stripe in this case) take set the renewal date to one year from the date of purchase - which is not what we wanted in this case. They don’t have a facility to charge a flat fee for a part year membership and then auto renew at a fixed point of time in the future. The only way around this was to sell a “trial” membership that runs to the end of the year and have members manually renew every year. This isn’t an issue with S2Member, but is a limitation of pretty much all of the payment gateways. Hope this helps.

2 Likes

Hi wordcrunch.

Setting a fixed date for subscription renewal can be done for the first renewal, but not following ones. Regular terms in a subscription can’t be changed, so if you say it’s monthly, it renews monthly.

What can be changed is the initial term (it’s the trial term, but you’re charging for it). This one can be 3 days if you want, and then the regular ones kick in. So if your fix date is in 2 weeks, you can make that initial term 14 days, and then the regular ones start from there (monthly or whatever you set it to).

To adjust that initial term dynamically, you would need a bit of PHP that calculates the difference between the current time and the fixed date you want, and adjusts your s2 shortcode for the payment in the trial attributes of the shortcode.

So you could do something like…

<?php
$fixed_date     = 'March 20th';
$amount_per_day = '0.50';
$initial_period = ceil((strtotime($fixed_date) - time()) / DAY_IN_SECONDS);
$initial_amount = ceil($initial_period * $amount_per_day);

// Now configure your shortcode with the trial term and amount you calculated above.
// The shortcode here has been abbreviated for clarity in this regard.
echo do_shortcode('[s2Member-PayPal-Button ... ta="'.$initial_amount.'" ... tp="'.$initial_period.'" ... /]');
?>

It’s like this because payment gateways don’t let you change the regular term, that is established when the subscription gets created. We can use the trial term to play with this at the very beginning of the subscription, but not afterwards.

I hope that makes sense and helps you. Let me know if you have other questions.

:slight_smile:

1 Like

Thanks folks, I did discover this through trial and error, and should note that a significant issue that made it challenging was the inability to correctly handle php in shortcodes as described in the knowledgebase articles (even when edited in text mode) - producing the gateway warning that the tp value needs to be numeric. In my case, we ended up installing a php snippet plugin to run the do_shortcode() function as described above. It’s nowhere close to elegant, we’d much rather not have this on the site where editors can break stuff so easily, but it works. We don’t have time to implement this but perhaps a better way would be to create a shortcut override in a child theme’s functions.php (or a wrapper shortcode) that will generate the values and then call the do_shortcode() with the modified parameters.

Yes, a PHP execution plugin is required for PHP to work on the page (e.g. the PHP snippets one you mentioned). There are less options available for Gutenberg, but it’s possible to use the older ones with the Classic Editor, though.

I am thinking about implementing some way of doing this from the admin area, maybe as new shortcode attributes. I want to find a way to improve this.

Thank you for the feedback! :smiley:

1 Like

Ideally you could add a fixed date for renewal field that would handle the calculations so nothing would need to be done on the front end (in this case the shortcode would not include tp, td, etc but just frd, frp, for example)

1 Like