Skip to content

Commit

Permalink
Merge pull request #19508 from mattwire/loadmemlineitems
Browse files Browse the repository at this point in the history
Fix display of membership dates on receipts when lineitems do not have a price_set_id
  • Loading branch information
eileenmcnaughton authored Feb 5, 2021
2 parents cfb46a9 + da5b850 commit 0436a94
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -3031,12 +3031,16 @@ public function _gatherMessageValues($input, &$values, $ids = []) {
$values['priceSetID'] = $priceSet['id'];
}
foreach ($lineItems as &$eachItem) {
if (isset($this->_relatedObjects['membership'])
&& is_array($this->_relatedObjects['membership'])
&& array_key_exists($eachItem['entity_id'] . '_' . $eachItem['membership_type_id'], $this->_relatedObjects['membership'])) {
$eachItem['join_date'] = CRM_Utils_Date::customFormat($this->_relatedObjects['membership'][$eachItem['entity_id'] . '_' . $eachItem['membership_type_id']]->join_date);
$eachItem['start_date'] = CRM_Utils_Date::customFormat($this->_relatedObjects['membership'][$eachItem['entity_id'] . '_' . $eachItem['membership_type_id']]->start_date);
$eachItem['end_date'] = CRM_Utils_Date::customFormat($this->_relatedObjects['membership'][$eachItem['entity_id'] . '_' . $eachItem['membership_type_id']]->end_date);
if ($eachItem['entity_table'] === 'civicrm_membership') {
$membership = reset(civicrm_api3('Membership', 'get', [
'id' => $eachItem['entity_id'],
'return' => ['join_date', 'start_date', 'end_date'],
])['values']);
if ($membership) {
$eachItem['join_date'] = CRM_Utils_Date::customFormat($membership['join_date']);
$eachItem['start_date'] = CRM_Utils_Date::customFormat($membership['start_date']);
$eachItem['end_date'] = CRM_Utils_Date::customFormat($membership['end_date']);
}
}
// This is actually used in conjunction with is_quick_config in the template & we should deprecate it.
// However, that does create upgrade pain so would be better to be phased in.
Expand Down

0 comments on commit 0436a94

Please sign in to comment.