Assign lineItems consistently in Confirm & ThankYou
authorEileen McNaughton <emcnaughton@wikimedia.org>
Mon, 20 Nov 2023 00:45:30 +0000 (13:45 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Mon, 20 Nov 2023 00:45:30 +0000 (13:45 +1300)
CRM/Contribute/Form/Contribution/Confirm.php
CRM/Contribute/Form/Contribution/ThankYou.php

index abf4e44b16d78554563a817b7c55fa4451237af6..ab1c9ad4164f351b3fed313a64ce1aad3030de3b 100644 (file)
@@ -498,7 +498,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
       $this->_params['is_quick_config'] = 1;
     }
     else {
-      $this->assignLineItemsToTemplate([$this->getPriceSetID() => $this->order->getLineItems()]);
+      $this->assign('lineItem', [$this->getPriceSetID() => $this->order->getLineItems()]);
     }
 
     if (!empty($params['selectProduct']) && $params['selectProduct'] !== 'no_thanks') {
index 546e57ee0c109f8faf46fc0df6d5f549aa860300..a8d7594e29ee5a6aab15ec009801534a497cac48 100644 (file)
@@ -41,7 +41,6 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont
     parent::preProcess();
 
     $this->_params = $this->get('params');
-    $this->_lineItem = $this->get('lineItem');
     $this->_useForMember = $this->get('useForMember');
     $this->assign('thankyou_title', CRM_Utils_Array::value('thankyou_title', $this->_values));
     $this->assign('thankyou_text', CRM_Utils_Array::value('thankyou_text', $this->_values));
@@ -95,31 +94,11 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont
     }
 
     $params = $this->_params;
-    $invoicing = CRM_Invoicing_Utils::isInvoicingEnabled();
-    // Make a copy of line items array to use for display only
-    $tplLineItems = $this->_lineItem;
-    if ($invoicing) {
-      $getTaxDetails = FALSE;
-      foreach ($this->_lineItem as $key => $value) {
-        foreach ($value as $k => $v) {
-          if (isset($v['tax_rate'])) {
-            if ($v['tax_rate'] != '') {
-              $getTaxDetails = TRUE;
-              // Cast to float to display without trailing zero decimals
-              $tplLineItems[$key][$k]['tax_rate'] = (float) $v['tax_rate'];
-            }
-          }
-        }
-      }
-    }
     $this->assign('getTaxDetails', (bool) $this->order->getTotalTaxAmount());
     $this->assign('totalTaxAmount', $this->order->getTotalTaxAmount());
     $this->assign('taxTerm', \Civi::settings()->get('tax_term'));
-
-    if ($this->_priceSetId && !CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) {
-      $this->assign('lineItem', $tplLineItems);
-    }
-    else {
+    $this->assign('lineItem', $this->isQuickConfig() ? NULL : $this->order->getLineItems());
+    if (!$this->isQuickConfig()) {
       if (is_array($membershipTypeID)) {
         $membershipTypeID = current($membershipTypeID);
       }