Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ready-for-core-team-review]CRM-19799, fixed contribution params to include line items #9580

Merged
merged 3 commits into from
Dec 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CRM/Contribute/Form/Contribution/Confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -2268,6 +2268,10 @@ protected function processFormSubmission($contactID) {
// Make it explict that we are letting the processConfirm function figure out the line items.
$paymentParams['skipLineItem'] = 0;

if (!isset($paymentParams['line_item'])) {
$paymentParams['line_item'] = $this->_lineItem;
}

if (!empty($paymentParams['onbehalf']) &&
is_array($paymentParams['onbehalf'])
) {
Expand Down
62 changes: 62 additions & 0 deletions tests/phpunit/api/v3/ContributionPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1354,4 +1354,66 @@ public function testSubmitPledgePayment() {
$this->assertEquals($pledgePayment['values'][2]['contribution_id'], $contribution['id']);
}

/**
* Test form submission with multiple option price set.
*/
public function testSubmitContributionPageWithPriceSet() {
$this->_priceSetParams['is_quick_config'] = 0;
$this->setUpContributionPage();
$submitParams = array(
'price_' . $this->_ids['price_field'][0] => reset($this->_ids['price_field_value']),
'id' => (int) $this->_ids['contribution_page'],
'amount' => 80,
'first_name' => 'Billy',
'last_name' => 'Gruff',
'email' => 'billy@goat.gruff',
'is_pay_later' => TRUE,
);
$this->addPriceFields($submitParams);

$this->callAPISuccess('contribution_page', 'submit', $submitParams);
$contribution = $this->callAPISuccessGetSingle('contribution', array(
'contribution_page_id' => $this->_ids['contribution_page'],
'contribution_status_id' => 2,
));
$this->callAPISuccessGetCount(
'LineItem',
array(
'contribution_id' => $contribution['id'],
),
3
);
}

/**
* Function to add additional price fields to priceset.
* @param array $params
*/
public function addPriceFields(&$params) {
$priceSetID = reset($this->_ids['price_set']);
$priceField = $this->callAPISuccess('price_field', 'create', array(
'price_set_id' => $priceSetID,
'label' => 'Chicken Breed',
'html_type' => 'CheckBox',
));
$priceFieldValue1 = $this->callAPISuccess('price_field_value', 'create', array(
'price_set_id' => $priceSetID,
'price_field_id' => $priceField['id'],
'label' => 'Shoe-eating chicken -1',
'financial_type_id' => 'Donation',
'amount' => 30,
));
$priceFieldValue2 = $this->callAPISuccess('price_field_value', 'create', array(
'price_set_id' => $priceSetID,
'price_field_id' => $priceField['id'],
'label' => 'Shoe-eating chicken -2',
'financial_type_id' => 'Donation',
'amount' => 40,
));
$params['price_' . $priceField['id']] = array(
$priceFieldValue1['id'] => 1,
$priceFieldValue2['id'] => 1,
);
}

}