Skip to content

Commit

Permalink
Merge pull request civicrm#22541 from braders/buildpremiumpreviewbloc…
Browse files Browse the repository at this point in the history
…k-refactor2

Refactor buildPremiumPreviewBlock function to make intended usage clearer
  • Loading branch information
eileenmcnaughton authored Jan 17, 2022
2 parents 9401c3b + f93837a commit d48ee52
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
17 changes: 7 additions & 10 deletions CRM/Contribute/BAO/Premium.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,22 +144,19 @@ public static function buildPremiumBlock(&$form, $pageID, $formItems = FALSE, $s
}

/**
* Build Premium B im Contribution Pages.
* Build Premium Preview block for Contribution Pages.
*
* @param CRM_Core_Form $form
* @param int $productID
* @param int $premiumProductID
* @param int|null $productID
*
* @return void
*/
public function buildPremiumPreviewBlock($form, $productID, $premiumProductID = NULL) {
if ($premiumProductID) {
$dao = new CRM_Contribute_DAO_PremiumsProduct();
$dao->id = $premiumProductID;
$dao->find(TRUE);
$productID = $dao->product_id;
}
public static function buildPremiumPreviewBlock($form, $productID) {
$productDAO = new CRM_Contribute_DAO_Product();
$productDAO->id = $productID;
$productDAO->is_active = 1;
$products = [];

if ($productDAO->find(TRUE)) {
CRM_Core_DAO::storeValues($productDAO, $products[$productDAO->id]);
}
Expand Down
7 changes: 6 additions & 1 deletion CRM/Contribute/Form/ContributionPage/AddProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,12 @@ public function buildQuickForm() {
}

if ($this->_action & CRM_Core_Action::PREVIEW) {
CRM_Contribute_BAO_Premium::buildPremiumPreviewBlock($this, NULL, $this->_pid);
$dao = new CRM_Contribute_DAO_PremiumsProduct();
$dao->id = $this->_pid;
$dao->find(TRUE);
$productID = $dao->product_id;

CRM_Contribute_BAO_Premium::buildPremiumPreviewBlock($this, $productID);
$this->addButtons([
[
'type' => 'next',
Expand Down

0 comments on commit d48ee52

Please sign in to comment.