Thanks for saving my time. Here is the code for 4.1.17 version, which is much shorter and simpler:
Code:
{assign var="paren" value=$order.payment_method|strpos:' ('}
{assign var="paymentMethod" value=$order.payment_method|substr:0:$paren}
{if $order.payment_method eq 'Credit Card'}
{php}
global $order;
#
# Custom function by moneysaver67
# Parse out the info after a given label
#
if( !function_exists( 'parseAfterLabel' ) )
{
function parseAfterLabel( $label, $details )
{
// Force to one line
$details = preg_replace( '/\n/',' ', $details );
if( !stristr( $details, $label ) )
{
$return = '';
}
else
{
$pattern = '/^.*'.$label.'\s{0,}(.*)\s{0,}.*$/';
$chunk = preg_replace( $pattern, '${1}', $details );
// return everything prior to first space (auth code)
$return = substr( $chunk, 0, strpos( $chunk, ' ' ) );
}
return $return;
}
}
// Do you store CC info in the details column?
if( $GLOBALS[store_cc] )
{
$cc_type = parseAfterLabel( '{CardType}:', $order["details"]);
$cc_num = parseAfterLabel( '{CardNumber}:', $order["details"]);
$cc_mask = str_repeat( 'x', strlen( $cc_num ) );
$cc_mask = substr( $cc_mask, 0, strlen( $cc_mask ) -4 ) . substr( $cc_num, -4, 4 );
if (!empty($cc_type) || !empty($cc_mask))
echo (': ' .$cc_type. ' ' . $cc_mask);
}
{/php}
{/if}