Skip to content
Snippets Groups Projects
Commit e6b3f9a8 authored by Andie Hunt's avatar Andie Hunt
Browse files

hook_civicrm_membershipTypeValues: formatting fixes

parent 3f3298e1
No related branches found
No related tags found
No related merge requests found
......@@ -2,44 +2,49 @@
## Description
This hook is called when composing the array of membershipTypes and
their cost during a membership registration (new or renewal). Note the
hook is called on initial page load and also reloaded after submit (PRG
pattern). You can use it to alter the membership types when first
This hook is called when composing the array of membership types and
their costs during a membership registration (new or renewal). Note the
hook is called on initial page load and also reloaded after submit ([PRG
pattern](https://en.wikipedia.org/wiki/Post/Redirect/Get)). You can use it to alter the membership types when first
loaded, or after submission (for example if you want to gather data in
the form and use it to alter the fees).
## Definition
hook_civicrm_membershipTypeValues( &$form, &$membershipTypeValues ) {
```php
hook_civicrm_membershipTypeValues( &$form, &$membershipTypeValues ) {
```
## Parameters
- $form the form object that is presenting the page
- $membershipTypeValues the array of membership types and their
amount
- object `$form` - the form object that is presenting the page
- array `$membershipTypeValues` - the membership types and their amounts
## Examples
Give a 50% discount to some memberships in the sample data
function civitest_civicrm_membershipTypeValues( &$form, &$membershipTypeValues ) {
$membershipTypeValues[1]['name'] = 'General (50% discount)';
$membershipTypeValues[1]['minimum_fee'] = '50.00';
```php
function civitest_civicrm_membershipTypeValues( &$form, &$membershipTypeValues ) {
$membershipTypeValues[1]['name'] = 'General (50% discount)';
$membershipTypeValues[1]['minimum_fee'] = '50.00';
$membershipTypeValues[2]['name'] = 'Student (50% discount)';
$membershipTypeValues[2]['minimum_fee'] = '25.00';
}
$membershipTypeValues[2]['name'] = 'Student (50% discount)';
$membershipTypeValues[2]['minimum_fee'] = '25.00';
}
```
Modify specific fee values
function mymodule_civicrm_membershipTypeValues( &$form, &$membershipTypeValues ) {
foreach ( $membershipTypeValues as &$values) {
if ( $values['name'] == 'General') {
$values['minimum_fee'] = "5.55";
}
if ( $values['name'] == 'Student') {
$values['minimum_fee'] = "2.22";
}
}
}
\ No newline at end of file
```php
function mymodule_civicrm_membershipTypeValues(&$form, &$membershipTypeValues) {
foreach ($membershipTypeValues as &$values) {
if ($values['name'] == 'General') {
$values['minimum_fee'] = "5.55";
}
if ($values['name'] == 'Student') {
$values['minimum_fee'] = "2.22";
}
}
}
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment