I have an array that looks like so:
Array ( [0] => Credit Card Type [1] => MasterCard )
Array ( [0] => Credit Card Number [1] => xxxx-1111 )
Array ( [0] => Processed Amount [1] => $106.91 )
Array ( [0] => Transaction Id [1] => 5011056094736597703015 )
Array ( [0] => AVS Response [1] => Z (Street address does not match, but 5-digit postal code matches.) )
Array ( [0] => CVN Response [1] => M (Card verification number matched.) )
Array ( [0] => Merchant Reference Code [1] => 25f11646823dc7488b48c04491335936 )
I’m using print_r(array($_label, $_value));
to display the above.
I want to swap out the Merchant reference code value which is the long alpha numeric number.
This is a magento build so I’m assuming I’d echo
$order = Mage::getModel('sales/order')->load($orderId);
echo $order->getIncrementId();
What will be the most appropriate way to ge the job done?
array_splice
or array_push
?
Any help would be greatly appreciated. thank you.
<div class="cards-list">
<?php if (!$this->getHideTitle()): ?>
<div class="bold"><?php echo $this->escapeHtml($this->getMethod()->getTitle()) ?></div>
<?php endif;?>
</div>
<?php
$cards = $this->getCards();
$showCount = count($cards) > 1;
?>
<?php foreach ($cards as $key => $card): ?>
<?php if ($showCount): ?>
<span><?php echo sprintf($this->__('Credit Card %s'), $key + 1); ?></span>
<?php endif;?>
<table class="info-table<?php if ($showCount):?> offset<?php endif;?>">
<tbody>
<?php foreach ($card as $_label => $_value):?>
<tr>
<td><?php echo $this->escapeHtml($_label)?>:</td>
<td><?php echo nl2br(implode($this->getValueAsArray($_value, true), "n"))?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endforeach; ?>
2
Answers
OK, so based on the print_r output that you have provided, I’m going to assume that you are looping through an array that looks like the below and printing the key ($_label) and value ($_value).
So why not just unset the Merchant Reference Code key and add what ever key/value you want into the array. eg:
I think you can replace:
with:
Note: maybe add
$this->__()
to translate “Order ID” and “Merchant Reference Code”Edit: to answer comment
If you template block class inherits from
Mage_Core_Block_Abstract
you can use$this->__('some String)
to use Magentos default method to translate something.So first thing is to replace
With
This makes this this check language indepented from being tranlated to the customers language. For german language it would be translated first to
<?php if ($_label === Refferenz Code) {
and it would still work. Same for “Order Id:”.To support different languages …
add
My_Module.csv
toapp/locale/{LANG_ISO}/
withmake tranlation file available in
app/code/{pool}/My/Module/ect/config.xml
add this toglobal
,frontend
oradminhtml
sectionadd helper to “enable” translations, add this to
app/code/{pool}/My/Module/Helpers/Data.php