• Resolved Kevin

    (@st8ofmindz79)


    We are trying to create a form where users are purchasing a yearly subscription that has a trial period of 12 months and we need to make sure that whatever the eot date is after the form is submitted and processed includes the paid year, the trial year and any period left over in their current eot.

    This ends up with the trial period being over a year and we run into errors. Although the form is still output.

    We’re putting the below code into our functions.php file.

    function ids_subscribe_form( $atts ) {
    	//default trial period
    	$tp = 365;
    	//get current user eot time
    	$s2member_auto_eot_time = get_user_field ( 's2member_auto_eot_time', 525 );
    
    	$now = time();
    	//only do this if the eot time is larger than now, this should handle if the field is blank but also if there are old dates in the db after a user eot has passed and then they decide to subscribe again.
    	if($s2member_auto_eot_time > $now){
    		//get number of seconds between eot and current time
    		$datediff = $s2member_auto_eot_time - $now;
    		//get number of days till eot
    	    $days_to_eot = floor($datediff/(60*60*24));
    		$tp = $days_to_eot + 365;
    	}
    	//create array of attributes for form
    	$attr = array(
    			's2Member-Pro-AuthNet-Form level' => '2',
    			'ccaps' => '',
    			'desc' => 'Pay securely below',
    			'cc' => 'USD',
    			'custom' => 'example.com',
    			'ta' => '59.00',
    			'tp' => $tp,
    			'tt' => 'D',
    			'ra' => '59.00',
    			'rp' => '365',
    			'rt' => 'D',
    			'rr' => '1',
    			'rrt' => '' ,
    			'accept' => 'visa,mastercard,amex,discover',
    			'coupon' => '',
    			'accept_coupons' => '1',
    			'default_country_code' => 'US',
    			'captcha' => '0',
    			'success' => '/subscribe/thank-you' );
    	return c_ws_plugin__s2member_pro_authnet_form::sc_authnet_form( $attr );
    }
    add_shortcode( 'ids_subscribe', 'ids_subscribe_form' );

    Any help/pointers are appreciated!

    We are on s2Member Pro framework version 130617.

    https://www.ads-software.com/plugins/s2member/

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘s2Member Pro – Error on Trial period over a year’ is closed to new replies.