我在opencart 2.0.0.1上工作 我有两种付款方式COD和一个支付网关,我想在结帐的步骤5:付款方式中添加支付网关徽标和COD图像。
我想在checkout / payment_method.tpl中添加图片代码,这里是代码..
<?php if ($payment_methods) { ?>
<p><?php echo $text_payment_method; ?></p>
<?php foreach ($payment_methods as $payment_method) { ?>
<div class="radio">
<label>
<?php if ($payment_method['code'] == $code || !$code)
{ ?>
<?php $code = $payment_method['code']; ?>
<input type="radio" name="payment_method" value="<?php echo $payment_method['code']; ?>" checked="checked" />
<?php
} else
{ ?>
<input type="radio" name="payment_method" value="<?php echo $payment_method['code']; ?>" />
<?php
} ?>
<?php echo $payment_method['title']; ?>
<?php if ($payment_method['terms']) { ?>
(<?php echo $payment_method['terms']; ?>)
<?php } ?>
</label>
</div>
<?php } ?>
<?php } ?>
答案 0 :(得分:2)
我刚刚在2.1.0.2下测试过基本相同的结构。 首先导航到 /catalog/model/payment/cheque.php 查找:
'title' => $this->language->get('text_title'),
并将其替换为:
'title' => $this->language->get('img_title') . $this->language->get('text_title'),
然后导航到 /language/english/payment/cheque.php 将其添加到底部:
$_['img_title'] = '<img src="' . HTTPS_SERVER . 'image/check.jpg" alt="Check" title="Check" /></a>';
更改您希望在上述代码中使用'和'之间使用的图像的名称/位置。还可以将alt =“”和title =“”更改为您工作的当前付款。alt =“COD “或alt =”PayPal“......
这适用于您添加的任何付款,或默认为opencart(cod,paypal,银行电汇等)
不要忘记使图像达到您想要的尺寸。希望这有帮助。
完成的结果
答案 1 :(得分:1)
我有一个解决方案
您可以手动检查付款方式代码并在结帐/付款方式控制器中添加图片
if ($method)
{
if($method['code']=="cod")
{
$method['image'] = "<img src='image/COD.jpg' style='width:200px; height:100px'/>";
}
else if($method['code']=="cheque")
{
$method['image'] = "<img src='image/payumoney.jpg' style='width:200px; height:100px'/>";
}
if ($recurring) {
if (method_exists($this->{'model_payment_' . $result['code']}, 'recurringPayments') && $this->{'model_payment_' . $result['code']}->recurringPayments()) {
$method_data[$result['code']] = $method;
}
} else {
$method_data[$result['code']] = $method;
}
//$method_data[$result['image']] = "<img src='image/payumoney.jpg' style='width:50px; height:50px'/>";
}
&#13;
并在视图中更改
<div class="radio payment_style" id="parent<?=$counter?>" for="radio<?=$counter?>">
<label>
<?php if ($payment_method['code'] == $code || !$code)
{ ?>
<?php $code = $payment_method['code']; ?>
<input id="radio<?=$counter?>" type="radio" name="payment_method" value="<?php echo $payment_method['code']; ?>" checked="checked" class="hide payment_radio" onclick="change_payment_method('<?=$counter?>')"/>
<?php
} else
{ ?>
<input type="radio" id="radio<?=$counter?>" class="hide payment_radio" name="payment_method" value="<?php echo $payment_method['code']; ?>" onclick="change_payment_method('<?=$counter?>')" />
<?php
} ?>
<div class="radimg"><?php echo $payment_method['image']; ?> </div>
<?php /* echo $payment_method['title']; */?>
<?php if ($payment_method['terms']) { ?>
(<?php echo $payment_method['terms']; ?>)
<?php } ?>
</label>
</div>
&#13;