Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CiviCRM Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
CiviCRM Core
Commits
2aa65a0f
Commit
2aa65a0f
authored
3 years ago
by
Eileen McNaughton
Browse files
Options
Downloads
Patches
Plain Diff
[REF] Remove unreachable code from order api
parent
44f9625f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
api/v3/Order.php
+5
-22
5 additions, 22 deletions
api/v3/Order.php
with
5 additions
and
22 deletions
api/v3/Order.php
+
5
−
22
View file @
2aa65a0f
...
...
@@ -73,8 +73,7 @@ function _civicrm_api3_order_get_spec(array &$params) {
*/
function
civicrm_api3_order_create
(
array
$params
):
array
{
civicrm_api3_verify_one_mandatory
(
$params
,
NULL
,
[
'line_items'
,
'total_amount'
]);
$entity
=
NULL
;
$entityIds
=
[];
$params
[
'contribution_status_id'
]
=
'Pending'
;
$order
=
new
CRM_Financial_BAO_Order
();
$order
->
setDefaultFinancialTypeID
(
$params
[
'financial_type_id'
]
??
NULL
);
...
...
@@ -115,14 +114,14 @@ function civicrm_api3_order_create(array $params): array {
if
(
$supportedEntity
)
{
$entityParams
[
'skipLineItem'
]
=
TRUE
;
$entityResult
=
civicrm_api3
(
$entity
,
'create'
,
$entityParams
);
$entityIds
[]
=
$params
[
$entity
.
'_id'
]
=
$entityResult
[
'id'
];
$params
[
$entity
.
'_id'
]
=
$entityResult
[
'id'
];
foreach
(
$lineItems
[
'line_item'
]
as
$innerIndex
=>
$lineItem
)
{
$lineIndex
=
$index
.
'+'
.
$innerIndex
;
$order
->
setLineItemValue
(
'entity_id'
,
$entityResult
[
'id'
],
$lineIndex
);
}
$lineIndex
=
$index
.
'+'
.
$innerIndex
;
$order
->
setLineItemValue
(
'entity_id'
,
$entityResult
[
'id'
],
$lineIndex
);
}
}
}
}
$priceSetID
=
$order
->
getPriceSetID
();
$params
[
'line_item'
][
$priceSetID
]
=
$order
->
getLineItems
();
}
...
...
@@ -146,22 +145,6 @@ function civicrm_api3_order_create(array $params): array {
$contribution
=
civicrm_api3
(
'Contribution'
,
'create'
,
$contributionParams
);
$contribution
[
'values'
][
$contribution
[
'id'
]][
'line_item'
]
=
$order
->
getLineItems
();
// add payments
if
(
$entity
&&
!
empty
(
$contribution
[
'id'
]))
{
foreach
(
$entityIds
as
$entityId
)
{
$paymentParams
=
[
'contribution_id'
=>
$contribution
[
'id'
],
$entity
.
'_id'
=>
$entityId
,
];
// if entity is pledge then build pledge param
if
(
$entity
===
'pledge'
)
{
$paymentParams
+=
$entityParams
;
// Pledges are not stored as entity_id in the line_item table.
CRM_Core_Error
::
deprecatedWarning
(
'This should be unreachable & tests show it is never tested.'
);
civicrm_api3
(
'PledgePayment'
,
'create'
,
$paymentParams
);
}
}
}
return
civicrm_api3_create_success
(
$contribution
[
'values'
]
??
[],
$params
,
'Order'
,
'create'
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment