From: Matthew Wire Date: Tue, 2 Feb 2021 21:05:21 +0000 (+0000) Subject: Fix display of membership dates on receipts when lineitems do not have a price_set_id X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=da5b8504ffe5a0c6b036b2bbb1699dc511b7c6f7;p=civicrm-core.git Fix display of membership dates on receipts when lineitems do not have a price_set_id --- diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 6327b8ec3c..0b6c2366e1 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -3024,12 +3024,16 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac $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.