Welcome, Guest. Please login or register.
Login with username, password and session length


VirtueMart 1.1.8 - [SECURITY RELEASE] is available! Read more....

  Advanced search

247031 Posts in 67504 Topics- by 258313 Members - Latest Member: Matej.iStraxx
Pages: [1]   Go Down
Print
Author Topic: Credit Card Type in Admin  (Read 1473 times)
mike420
Newbie
*
Posts: 23



« on: July 07, 2010, 02:37:55 am »

After searching though many posts here and not finding a solution I manage to create a hack to show credit card types on the orders page in the VM admin area.

I am by no means a coder and there may be a better way of doing this, but this is what I have come up with.

Firstly you will need to add a column to the "vm_order_payment" table in your database.

You can use the following SQL query to do that:

ALTER TABLE `jos_vm_order_payment` ADD `order_payment_cctype` VARCHAR( 70 ) NOT NULL;

Next open administrator/components/com_virtuemart/classes/ps_checkout.php

Find this:
Code:
/**
   * Insert the Order payment info
   */
$payment_number = ereg_replace(" |-", "", @$_SESSION['ccdata']['order_payment_number']);

$d["order_payment_code"] = @$_SESSION['ccdata']['credit_card_code'];

and add underneath:
Code:
$d['order_payment_cctype'] = @$_SESSION['ccdata']['creditcard_code'];

Then find this:
Code:
// Store Credit Card Information only if the Store Owner has decided to do so
$fields['order_payment_code'] = $d["order_payment_code"];

and add underneath this:
Code:
$fields['order_payment_cctype'] = $d["order_payment_cctype"];

Next open administrator/components/com_virtuemart/html/order.order_print.php

find this:
Code:
 
<table class="adminlist">
<tr>
   <td valign="top" width="300">
     <table class="adminlist">
      <tr>
       <th ><?php 
      
echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_SHIPPING_LBL'?>

       </th>
      </tr>
      <tr>
      <td align="left">
         <?php
                    
if( $db->f("ship_method_id") ) { 
                      
$details explode"|"$db->f("ship_method_id"));
                    }
                  
?>

        <strong><?php echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_SHIPPING_CARRIER_LBL'?>: </strong>
      <?php  echo $details[1]; ?>&nbsp;
                </td>
            </tr>
      <tr>
      <td align="left">
        <strong><?php echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_SHIPPING_MODE_LBL'?>: </strong>
        <?php echo $details[2]; ?>
                </td>
      </tr>
      <tr>
      <td align="left">
        <strong><?php echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_SHIPPING_PRICE_LBL'?>: </strong>
        <?php echo $GLOBALS['CURRENCY_DISPLAY']->getFullValue($details[3], ''$db->f('order_currency')); ?>
      </td>
      </tr>
              <?php $ps_order_change_html->html_change_shipping() ?>  
     </table>
    </td>

    <?php
  
    $dbpm = new ps_DB;
  
$q  "SELECT * FROM #__{vm}_payment_method, #__{vm}_order_payment WHERE #__{vm}_order_payment.order_id='$order_id' ";
  
$q .= "AND #__{vm}_payment_method.payment_method_id=#__{vm}_order_payment.payment_method_id";
  
$dbpm->query($q);
  
$dbpm->next_record();
  
   
  
// DECODE Account Number
  
$dbaccount = new ps_DB;
  
    $q "SELECT ".VM_DECRYPT_FUNCTION."(order_payment_number,'".ENCODE_KEY."')
   AS account_number, order_payment_code FROM #__{vm}_order_payment  
   WHERE order_id='"
.$order_id."'";
  
$dbaccount->query($q);
  
$dbaccount->next_record();
  
?>

    <!-- Payment Information -->
    <td valign="top" width="*">
     <table class="adminlist">
      <tr class="sectiontableheader">
       <th width="13%"><?php echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_PAYMENT_LBL'?></th>
       <th width="40%"><?php echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_ACCOUNT_NAME'?></th>
       <th width="30%"><?php echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_ACCOUNT_NUMBER'); ?></th>
       <th width="17%"><?php echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_EXPIRE_DATE'?></th>
      </tr>
      <tr>
       <td width="13%">
                  <?php $ps_order_change_html->html_change_payment($dbpm->f("payment_method_id")) ?>
                </td>
       <td width="40%"><?php $dbpm->p("order_payment_name");?></td>
       <td width="30%"><?php 
        
echo ps_checkout::asterisk_pad$dbaccount->f("account_number"), 4true );
        
if( $dbaccount->f('order_payment_code')) {
        
echo '<br/>(' $VM_LANG->_('VM_ORDER_PAYMENT_CCV_CODE') . ': '.$dbaccount->f('order_payment_code').') ';
        
}
        
?>

                </td>
       <td width="17%"><?php echo $dbpm->f("order_payment_expire") ? vmFormatDate$dbpm->f("order_payment_expire"), '%b-%Y') : ''?></td>
      </tr>
      <tr class="sectiontableheader">
       <th colspan="4"><?php echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_PAYMENT_LOG_LBL'?></th>
      </tr>
      <tr>
       <td colspan="4"><?php if($dbpm->f("order_payment_log")) echo $dbpm->f("order_payment_log"); else echo "./."?></td>
      </tr>
      <tr>
        <td colspan="2" align="center">
                  <?php $ps_order_change_html->html_change_discount() ?>
                </td>
                <td colspan="2" align="center">
                  <?php $ps_order_change_html->html_change_coupon_discount() ?>
                </td>
              </tr>
     </table>
    </td>
   </tr>
   <tr>
    <!-- Customer Note -->
    <td valign="top" width="30%" colspan="2">
     <table class="adminlist">
      <tr>
      <th><?php echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_CUSTOMER_NOTE'?></th>
      </tr>
      <tr>
        <td valign="top" align="center" width="50%">
                  <?php $ps_order_change_html->html_change_customer_note() ?>  
      </td>
      </tr>
     </table>
    </td>
 </tr>
 </table>
<?php
}
else {
  echo $VM_LANG->_('VM_ORDER_NOTFOUND');
}
}
?>

and replace with this:
Code:
&nbsp;
<table class="adminlist">
<tr>
        <td>
<table class="adminlist">
   <tr>
      <th><?php echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_SHIPPING_LBL'?></th>
   </tr>
   <tr>
     <td align="left">
         <?php
               
if( $db->f("ship_method_id") ) { 
               
$details explode"|"$db->f("ship_method_id"));
               }
            
?>

     <strong><?php echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_SHIPPING_CARRIER_LBL'?>: </strong>
     <?php  echo $details[1]; ?>&nbsp;
        </td>
    </tr>
    <tr>
     <td align="left">
     <strong><?php echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_SHIPPING_MODE_LBL'?>: </strong>
     <?php echo $details[2]; ?>
        </td>
    </tr>
    <tr>
     <td align="left">
     <strong><?php echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_SHIPPING_PRICE_LBL'?>: </strong>
     <?php echo $GLOBALS['CURRENCY_DISPLAY']->getFullValue($details[3], ''$db->f('order_currency')); ?>
     </td>
    </tr>
        <?php $ps_order_change_html->html_change_shipping() ?>  
</table>
</td>
 </tr>
</table>
&nbsp;    
<table class="adminlist">
<tr>
   <?php
  
    $dbpm = new ps_DB;
  
$q  "SELECT * FROM #__{vm}_payment_method, #__{vm}_order_payment WHERE #__{vm}_order_payment.order_id='$order_id' ";
  
$q .= "AND #__{vm}_payment_method.payment_method_id=#__{vm}_order_payment.payment_method_id";
  
$dbpm->query($q);
  
$dbpm->next_record();
  
   
  
// DECODE Account Number
  
$dbaccount = new ps_DB;
  
    $q "SELECT ".VM_DECRYPT_FUNCTION."(order_payment_number,'".ENCODE_KEY."')
   AS account_number, order_payment_code FROM #__{vm}_order_payment  
   WHERE order_id='"
.$order_id."'";
  
$dbaccount->query($q);
  
$dbaccount->next_record();
  
?>

    <!-- Payment Information -->
    <td valign="top" width="*">
     <table class="adminlist">
      <tr class="sectiontableheader">
       <th width="13%"><?php echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_PAYMENT_LBL'?></th>
       <th width="40%"><?php echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_ACCOUNT_NAME'?></th>
       <th width="30%"><?php echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_ACCOUNT_NUMBER'); ?></th>
       <th width="17%"><?php echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_EXPIRE_DATE'?></th>
      </tr>
      <tr>
       <td width="13%">
                  <?php $ps_order_change_html->html_change_payment($dbpm->f("payment_method_id")) ?>
                </td>
       <td width="40%"><?php $dbpm->p("order_payment_name");?></td>
       <td width="30%">
<div style="float:left;">
<?php 
        
echo ps_checkout::asterisk_pad$dbaccount->f("account_number"), 4true );
        
if( $dbaccount->f('order_payment_code')) {
        
echo '<br/>(' $VM_LANG->_('VM_ORDER_PAYMENT_CCV_CODE') . ': '.$dbaccount->f('order_payment_code').') ';
        
}
?>

                        </div>
                        <?php
if( $dbpm->f('order_payment_cctype')) {

if( $dbpm->f('order_payment_cctype') == 'VISA') { 
echo '<div style="float:left;">';
echo '&nbsp;&nbsp;&nbsp;&nbsp;<img src="'IMAGEURL .'ps_image/visa.png" alt="Visa" align="absmiddle" />';
echo '</div>';
}
if( $dbpm->f('order_payment_cctype') == 'MC') { 
echo '<div style="float:left;">';
echo '&nbsp;&nbsp;&nbsp;&nbsp;<img src="'IMAGEURL .'ps_image/mastercard.png" alt="Mastercard" align="absmiddle" />';
echo '</div>';
}
if( $dbpm->f('order_payment_cctype') == 'MAESTRO') { 
echo '<div style="float:left;">';
echo '&nbsp;&nbsp;&nbsp;&nbsp;<img src="'IMAGEURL .'ps_image/maestro.png" alt="Maestro" align="absmiddle" />';
echo '</div>';
}
if( $dbpm->f('order_payment_cctype') == 'UKE') { 
echo '<div style="float:left;">';
echo '&nbsp;&nbsp;&nbsp;&nbsp;<img src="'IMAGEURL .'ps_image/visae.png" alt="Visa Electron" align="absmiddle" />';
echo '</div>';
}
if( $dbpm->f('order_payment_cctype') == 'DELTA') { 
echo '<div style="float:left;">';
echo '&nbsp;&nbsp;&nbsp;&nbsp;<img src="'IMAGEURL .'ps_image/visad.png" alt="Visa Delta" align="absmiddle" />';
echo '</div>';
}

}
?>

                            
                 </td>
       <td width="17%"><?php echo $dbpm->f("order_payment_expire") ? vmFormatDate$dbpm->f("order_payment_expire"), '%b-%Y') : ''?></td>
      </tr>
     </table>
    </td>
   </tr>
 </table>
<?php
}
else {
  echo $VM_LANG->_('VM_ORDER_NOTFOUND');
}
}
?>

The last part seperates the shipping info and payment info in to seperate tables to make space for the images.

As you can see from the following part of the code I only accept Visa, Mastercard, Maestro, Visa Electron and Visa Delta.

If you accept different cards then this is the part to edit.

Code:
<?php
if( $dbpm->f('order_payment_cctype')) {

if( $dbpm->f('order_payment_cctype') == 'VISA') { 
echo '<div style="float:left;">';
echo '&nbsp;&nbsp;&nbsp;&nbsp;<img src="'IMAGEURL .'ps_image/visa.png" alt="Visa" align="absmiddle" />';
echo '</div>';
}
if( $dbpm->f('order_payment_cctype') == 'MC') { 
echo '<div style="float:left;">';
echo '&nbsp;&nbsp;&nbsp;&nbsp;<img src="'IMAGEURL .'ps_image/mastercard.png" alt="Mastercard" align="absmiddle" />';
echo '</div>';
}
if( $dbpm->f('order_payment_cctype') == 'MAESTRO') { 
echo '<div style="float:left;">';
echo '&nbsp;&nbsp;&nbsp;&nbsp;<img src="'IMAGEURL .'ps_image/maestro.png" alt="Maestro" align="absmiddle" />';
echo '</div>';
}
if( $dbpm->f('order_payment_cctype') == 'UKE') { 
echo '<div style="float:left;">';
echo '&nbsp;&nbsp;&nbsp;&nbsp;<img src="'IMAGEURL .'ps_image/visae.png" alt="Visa Electron" align="absmiddle" />';
echo '</div>';
}
if( $dbpm->f('order_payment_cctype') == 'DELTA') { 
echo '<div style="float:left;">';
echo '&nbsp;&nbsp;&nbsp;&nbsp;<img src="'IMAGEURL .'ps_image/visad.png" alt="Visa Delta" align="absmiddle" />';
echo '</div>';
}

}
?>

I have attached the images used.

* cards.zip (15.64 KB - downloaded 98 times.)
« Last Edit: July 07, 2010, 02:41:16 am by mike420 » Logged
lumo
Newbie
*
Posts: 19



WWW
« Reply #1 on: June 01, 2011, 14:09:06 pm »

Thanks Mike, works perfectly...
Logged

Pages: [1]   Go Up
Print
Jump to: