Line Items: different behaviour between order API and backend when registering price options not related to a membership type
When I create a membership with price sets, for the price options that not are related to a membership type, the entity table in line items is civicrm_contribution
.
But if I create a membership with Order API the entity table for all line items have to be civicrm_membership
otherwise the membership is not created.
For example, if I use civicrm_contribution
for "price_field_id = 16" in the following example, the membership is not created. If I replace to civicrm_membership
the membership is created correctly.
But I add the same membership in the backend, the entity_table for "price_field_id = 16" is civicrm_contribution
.
[return] => membership_id
[contact_id] => 178918
[financial_type_id] => 2
[contribution_status] => Pending
[total_amount] => 36
[receive_date] => 20231129084211
[payment_instrument_id] => 7
[invoice_id] => CH-a1dafa484b7dbbf1ea4aae1b
[trxn_id] =>
[payment_processor_id] => 2
[is_email_receipt] =>
[line_items] => Array
(
[0] => Array
(
[line_item] => Array
(
[0] => Array
(
[entity_table] => civicrm_membership
[price_field_id] => 15
[price_field_value_id] => 22
[qty] => 1
[unit_price] => 30
[line_total] => 30
)
[1] => Array
(
[entity_table] => civicrm_contribution
[price_field_id] => 16
[price_field_value_id] => 25
[qty] => 1
[unit_price] => 6
[line_total] => 6
)
)
[params] => Array
(
[id] =>
[membership_type_id] => 1
[contact_id] => 178918
[end_date] => 2024-12-31
[is_override] => 0
[status_id] => Pending
[max_related] => 0
[join_date] => 20231129084211
[start_date] => 2024-01-01
)
)
)
[debug] => 1
[is_test] => 0
It is important that the data is recorded in the same way. Also because if I have to make queries becomes very complicated (I have not yet found a way to do this with SearchKit).