• Hi, I’m trying to work out the easiest way to do the following,

    Basically I want all memberships options to be paid yearly on 1st Jan at £40/yr

    So my idea was have 4 options:
    Joined Jan – Mar: initial £40 then recurring £40
    Joined Apr – Jun: initial £30 then recurring £40
    Joined Jul – Sep: initial £20 then recurring £40
    Joined Oct – Dec: initial £10 then recurring £40

    So what I was thinking was set up the 4 subscription types, then in classes/class.memberorder.php function saveOrder() instead of using now() for the timestamp field use ‘” . strtotime(’01-01-‘.date(“Y”)) . “‘ which if I understand it right the code uses the timestamp field to see when it was last billed so by setting the timestamp to the 1st of jan of the current year it will bill again 1st jan the next year, would that be all I would have to change?

    https://www.ads-software.com/extend/plugins/paid-memberships-pro/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter kodestar

    (@kodestar)

    Ok, having another look, I’m thinking it might not actually be possible?

    Am I right in thinking that the timestamp field isn’t actually used for calculating the next bill date and that is handled by paypal?

    So if someone joined up June 1st for example, using the above it would do £30 for the first time then £40/yr but it would always bill on the 1st of June and there’s no way to change that?

    That’s a pain if that’s the case =/

    Thread Starter kodestar

    (@kodestar)

    Ok, 3rd post’s the charm, lol.

    So looking in classes/gateways/class.pmprogateway_paypalexpress.php in the function process there is:

    $order->ProfileStartDate = date(“Y-m-d”, strtotime(“+ ” . $order->BillingFrequency . ” ” . $order->BillingPeriod)) . “T0:0:0”;

    So if I changed that to :

    $order->ProfileStartDate = date(“Y-m-d”, strtotime((date(“y”)+1).”-01-01″)) . “T0:0:0”;

    Would that work?

    (also ignore the wrongly formatted date() in the first post, it’s very late, lol)

    Plugin Author Jason Coleman

    (@strangerstudios)

    FYI, this is a question I would typically answer on the paid support forums at https://www.paidmembershipspro.com.

    We’ve done this for other folks. I’ll try to give you some hints.

    When you see code like this:
    $order->ProfileStartDate = apply_filters("pmpro_profile_start_date", $order->ProfileStartDate, $order);

    That is PMPro using a “filer” to allow people to change things, like the ProfileStartDate, here without changing the actual code. Changing the code in the plugin is bad because we release updates every other week or so, and some of them are very important. You want to be able to upgrade without having to redo your plugin edits, etc.

    So to change the start dates for all new memberships to Jan 1, you would add something like this to your active theme’s functions.php or a custom plugin:

    function my_pmpro_profile_start_date($startdate, $order)
    {
        $next_year = strtotime(" + 1 Year");
        $startdate = date("Y", $next_year) . "-01-01T0:0:0";
    }
    add_filter("pmpro_profile_start_date", "my_pmpro_profile_start_date", 10, 2);

    You can do something similar to alter the initial payment of the level via the pmpro_checkout_level filter (view /preheaders/checkout.php to see how it is used)

    Good luck.

    Thread Starter kodestar

    (@kodestar)

    Thank you so much for that help, I haven’t used filters much before which is why I didn’t pick up on that, but this is a much better way, I added return $startdate; at the end, not 100% sure if that is required but another function I added didn’t work without returning, and returning $startdate; didn’t breat anything and the payment profile worked “Next payment due: 1 Jan 2013”

    Especially thanks for the idea with using filters for the payment amount, I used:

    function my_pmpro_checkout_level($pmpro_level)
    {
    $current = date(“n”);
    $splitfour = $pmpro_level->initial_payment/4;
    switch($current) {
    case “4”: case “5”: case “6”: $pmpro_level->initial_payment = $splitfour*3; break;
    case “7”: case “8”: case “9”: $pmpro_level->initial_payment = $splitfour*2; break;
    case “10”: case “11”: case “12”: $pmpro_level->initial_payment = $splitfour; break;
    }
    return $pmpro_level;
    }
    add_filter(“pmpro_checkout_level”, “my_pmpro_checkout_level”, 10, 1);

    It seems to work great and there’s no way I would have known where to start without those hints ??

    Plugin Author Jason Coleman

    (@strangerstudios)

    Yes. The return is needed. I missed that in my post. Wish I could go back and fix it.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: Paid Memberships Pro] Easiest way to add pro rata payments’ is closed to new replies.