Replace last tpl uses of contributeMode
authorEileen McNaughton <emcnaughton@wikimedia.org>
Fri, 22 Sep 2023 22:27:22 +0000 (10:27 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Tue, 14 Nov 2023 20:50:40 +0000 (09:50 +1300)
This adds the strings to what the processor can determin, allowing us to stop checkign contributeMode

CRM/Contribute/Form/AdditionalPayment.php
CRM/Core/Payment.php
CRM/Event/Form/Registration.php
CRM/Event/Form/Registration/Confirm.php
CRM/Event/Form/Registration/ThankYou.php
templates/CRM/Event/Form/Registration/Confirm.tpl
templates/CRM/Event/Form/Registration/ThankYou.tpl

index 370f41ad560ef80de37a0d79ca7524a465dc8831..25e0a275e2ea2b2f38480638c0405854f485e965 100644 (file)
@@ -321,7 +321,6 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
 
     if ($this->_mode) {
       // process credit card
-      $this->assign('contributeMode', 'direct');
       $this->processCreditCard();
     }
 
index 9e0f2a33a87ecba2938175e0fe59fa9b16555edb..c7fc98f3fe9706e8f17aa379306d516805681c4e 100644 (file)
@@ -609,6 +609,22 @@ abstract class CRM_Core_Payment {
         }
         return ts('Make Contribution');
 
+      case 'eventContinueText':
+        // This use of the ts function uses the legacy interpolation of the button name to avoid translations having to be re-done.
+        if ((int) $this->_paymentProcessor['billing_mode'] === self::BILLING_MODE_NOTIFY) {
+          return ts('Click <strong>%1</strong> to checkout with %2.', [1 => ts('Register'), 2 => $this->_paymentProcessor['frontend_title']]);
+        }
+        return ts('Click <strong>%1</strong> to complete your registration.', [1 => ts('Register')]);
+
+      case 'eventConfirmText':
+        if ((int) $this->_paymentProcessor['billing_mode'] === self::BILLING_MODE_NOTIFY) {
+          return ts('Your registration payment has been submitted to %1 for processing', [1 => $this->_paymentProcessor['frontend_title']]);
+        }
+        return '';
+
+      case 'eventConfirmEmailText':
+        return ts('A registration confirmation email will be sent to %1 once the transaction is processed successfully.', [1 => $params['email']]);
+
       case 'cancelRecurDetailText':
         if ($params['mode'] === 'auto_renew') {
           return ts('Click the button below if you want to cancel the auto-renewal option for your %1 membership. This will not cancel your membership. However you will need to arrange payment for renewal when your membership expires.',
index c10351632bf855ca45e025d33292519ffa640389..726eb3b9612f8e76451a941a5bfc3b0d0e6251f5 100644 (file)
@@ -382,10 +382,8 @@ class CRM_Event_Form_Registration extends CRM_Core_Form {
     }
     // The concept of contributeMode is deprecated.
     $this->_contributeMode = $this->get('contributeMode');
-    $this->assign('contributeMode', $this->_contributeMode);
-
-    $this->assign('paidEvent', $this->_values['event']['is_monetary']);
 
+    $this->assign('paidEvent', $this->getEventValue('is_monetary'));
     // we do not want to display recently viewed items on Registration pages
     $this->assign('displayRecent', FALSE);
 
index 04be4e89afbc8ecfa39c47778ae0c2b5ad887cc5..4c39c2869c7dd0cd2585194e1de2bce07ea3a874 100644 (file)
@@ -272,6 +272,8 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration {
       $this->assign('amounts', $this->_amount);
       $this->assign('totalAmount', $this->_totalAmount);
       $this->set('totalAmount', $this->_totalAmount);
+      // This use of the ts function uses the legacy interpolation of the button name to avoid translations having to be re-done.
+      $this->assign('verifyText', !$this->_totalAmount ? ts('Click <strong>%1</strong> to complete your registration.', [1 => ts('Register')]) : $this->getPaymentProcessorObject()->getText('eventContinueText', []));
 
       $showPaymentOnConfirm = (in_array($this->_eventId, \Civi::settings()->get('event_show_payment_on_confirm')) || in_array('all', \Civi::settings()->get('event_show_payment_on_confirm')));
       $this->assign('showPaymentOnConfirm', $showPaymentOnConfirm);
index 948294772a3f2790a208b889bd11ffacec00a24c..474e3d5f8d076c623ffad911c5996e0de2bfc3e9 100644 (file)
@@ -72,13 +72,17 @@ class CRM_Event_Form_Registration_ThankYou extends CRM_Event_Form_Registration {
   public function buildQuickForm() {
     // Assign the email address from a contact id lookup as in CRM_Event_BAO_Event->sendMail()
     $primaryContactId = $this->get('primaryContactId');
+    $email = NULL;
     if ($primaryContactId) {
       $email = CRM_Utils_Array::valueByRegexKey('/^email-/', current($this->_params));
       if (!$email) {
         $email = CRM_Contact_BAO_Contact::getPrimaryEmail($primaryContactId);
       }
-      $this->assign('email', $email);
     }
+    $this->assign('email', $email ?? NULL);
+    $this->assign('eventConfirmText', $this->getEventValue('is_monetary') ? $this->getPaymentProcessorObject()->getText('eventConfirmText', []) : '');
+    $this->assign('eventConfirmEmailText', ($email && $this->getEventValue('is_monetary')) ? $this->getPaymentProcessorObject()->getText('eventConfirmEmailText', ['email' => $email]) : '');
+
     $this->assignToTemplate();
 
     $invoicing = CRM_Invoicing_Utils::isInvoicingEnabled();
index 98dddde24bac7b66e432648bad3a28e914c50440..006f9e2c9fc801dc4ff2271f5f8c9b8981dfa66c 100644 (file)
         {ts 1=$register}Click <strong>%1</strong> to submit your registration for approval.{/ts}
     {else}
         {ts}Please verify your information.{/ts}
-        {if $contributeMode EQ 'notify' and !$is_pay_later and !$isAmountzero}
-            {ts 1=$register 2=$paymentProcessor.frontend_title}Click <strong>%1</strong> to checkout with %2.{/ts}
-        {else}
-            {ts 1=$register}Click <strong>%1</strong> to complete your registration.{/ts}
-        {/if}
+        {$verifyText}
     {/if}
     </p></div>
     {if $is_pay_later and !$isAmountzero and !$isOnWaitlist and !$isRequireApproval}
index 14fe56cfa54253e4718aaecf8a84c7ee6a508fec..a902988819eedbdc92ffa0acc772a0e61c582277 100644 (file)
             {if $is_email_confirm}
                 <p>{ts 1=$email}An email with event details has been sent to %1.{/ts}</p>
             {/if}
-        {* PayPal_Standard sets contribution_mode to 'notify'. We don't know if transaction is successful until we receive the IPN (payment notification) *}
-        {elseif $contributeMode EQ 'notify' and $paidEvent}
-            <p>{ts 1=$paymentProcessor.name}Your registration payment has been submitted to %1 for processing.{/ts}</p>
+        {* This text is determined by the payment processor *}
+        {elseif $eventConfirmText}
+            <p>{$eventConfirmText}</p>
             {if $is_email_confirm}
-                <p>{ts 1=$email}A registration confirmation email will be sent to %1 once the transaction is processed successfully.{/ts}</p>
+                <p>{$eventEmailConfirmText}</p>
             {/if}
         {else}
             <p>{ts}Your registration has been processed successfully.{/ts}</p>