Jump to content

Archived

This topic is now archived and is closed to further replies.

zwak

Hiding change links in order confirmation when just one payment method available

Recommended Posts

Hi

 

In our shop we sometimes have multiple payment methods available for a customer, but quite often there is just one. The problem is that I don't find way to hide the change payment method link when there is just one available. This will cause redirect back to same page, as payment page was skipped using this code:

 

With this 

// skip if only 1 payment method available 
if (tep_count_payment_modules() < 2 ) {
 $payment_select = $payment_modules->selection();
 $payment = $payment_select[0]['id'];
 if (!tep_session_is_registered('payment')) tep_session_register('payment');
 tep_redirect(tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL'));
 
tep_count_payment_modules always returns 1 if payment is already selected.

Share this post


Link to post
Share on other sites

Found one solution:

 

In checkout_confirmation.php

 

Replaced:

​$payment_modules->update_status(); 

With:

/* CAPM Check available payment modules allows use of tep_count_payment_modules() to get number of payment modules in order confirmation  */
// $payment_modules->update_status(); 
foreach($payment_modules->modules as $value) {
  $class = substr($value, 0, strrpos($value, '.'));
  $$class->update_status();
}
//END CAPM*/

And later replaced 

         <tr>
            <td><?php echo '<strong>' . HEADING_PAYMENT_METHOD . '</strong> <a href="' . tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL') . '"><span class="orderEdit">(' . TEXT_EDIT . ')</span></a>'; ?></td>
          </tr>
          <tr>
            <td><?php echo $order->info['payment_method']; ?></td>
          </tr>

with

<?php if (tep_count_payment_modules() > 1) {  //CAPM Check available payment modules allows use of tep_count_payment_modules() to get number of payment modules in order confirmation ?>
          <tr>
            <td><?php echo '<strong>' . HEADING_PAYMENT_METHOD . '</strong> <a href="' . tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL') . '"><span class="orderEdit">(' . TEXT_EDIT . ')</span></a>'; ?></td>
          </tr>
          <tr>
            <td><?php echo $order->info['payment_method']; ?></td>
          </tr>
<? } // CAPM Check available payment modules allows use of tep_count_payment_modules() to get number of payment modules in order confirmation ?>

And in includes/classes/payment.php replaced this

 

       if ( (tep_not_null($module)) && (in_array($module . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)), $this->modules)) ) {
          $this->selected_module = $module;


          $include_modules[] = array('class' => $module, 'file' => $module . '.php');
        } else {
          reset($this->modules);
          while (list(, $value) = each($this->modules)) {
            $class = substr($value, 0, strrpos($value, '.'));
            $include_modules[] = array('class' => $class, 'file' => $value);
          }
        }

With this

/* CAPM Check available payment modules allows use of tep_count_payment_modules() to get number of payment modules in order confirmation  */
/* by Lauri 2015-11-21*/
        if ( (tep_not_null($module)) && (in_array($module . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)), $this->modules)) ) {
          $this->selected_module = $module;
          /* $include_modules[] = array('class' => $module, 'file' => $module . '.php'); //CAPM */
          
        } /* else { //CAPM */
          reset($this->modules);
          while (list(, $value) = each($this->modules)) {
            $class = substr($value, 0, strrpos($value, '.'));
            $include_modules[] = array('class' => $class, 'file' => $value);
          }
        /* } //END CAPM*/
 
 
 

Share this post


Link to post
Share on other sites

×