$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.