6

I'm attempting to setup proration on fixed memberships via the civicrm_membershipTypeValues hook. I'm assuming that once the minimum_fee value is modified, this new amount should display on the contribution form.

In using the basic test code, with some debug messages inserted, I can see the hook is called, and the minimum fee value is updated, however the radio button selections for the membership types, retains its original "full period" price.

Currently testing with the following on Drupal 7.37/Civi 4.6.3 to test the ability to update the amount without success....

Appreciate any thoughts on how to implement proration....

function prorated_memberships_civicrm_membershipTypeValues( &$form, &$membershipTypeValues ) {
  require_once "CRM/Core/Error.php";

    foreach ( $membershipTypeValues as &$values) {
   CRM_Core_Error::debug( 'olddump', $values);
          if ( $values['name'] == 'General') {
              $values['minimum_fee'] = "5.55";

          }
          if ( $values['name'] == 'Family') {
              $values['minimum_fee'] = "2.22";

          }
   CRM_Core_Error::debug( 'newdump', $values);
    }
}
  • Code nitpick: CiviCRM uses a php class autoloader which makes lines like require_once "CRM/Core/Error.php"; redundant. – Coleman Jun 15 '15 at 0:21
2

Even if you don't use a price set on a contribution page, the options that get presented end up being treated as a price set in the database. Membership options in a price set don't need to be the minimum value of the membership itself, so my suspicion is that your hook isn't affecting the price options on the page, since they're set when you create the contribution page itself.

You'll need to use hook_civicrm_buildamount to change the actual price options' values on the form.

  • Appreciate the help Andrew...the buildAmount hook took care of it. – Ken Truesdale Jun 15 '15 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.