所以我最近开始使用magento 1.9。我有一个具体的问题,我不知道如何解决。我创建了一个自定义支付模块,显示在付款选项中,当用户下订单时,它会重定向到我的自定义结帐成功消息。然而,这并不是我想要的。如果选择了任何付款方式,我希望能够将用户重定向到我的自定义网址,例如paypal或creditcard。
在我的自定义控制器中,我想将一些信息附加到表单,然后将其转发到网关。
我想问题与此类似。但我不想编辑magento的核心代码,我想从我的自定义模块覆盖。 Magento "place order" redirection for payment gateway
有没有人可以帮助或指出我正确的方向?
答案 0 :(得分:0)
参考此示例;
config.xml中(app/code/local/Test123/MyModule/etc/config.xml
):
<?xml version="1.0"?>
<config>
<modules>
<Test123_MyModule>
<version>1.0.1</version>
</Test123_MyModule>
</modules>
<frontend>
<routers>
<mymodule>
<use>standard</use>
<args>
<module>Test123_MyModule</module>
<frontName>mymodule</frontName>
</args>
</mymodule>
</routers>
<layout>
<updates>
<mymodule>
<file>mymodule.xml</file>
</mymodule>
</updates>
</layout>
</frontend>
<global>
<blocks>
<mymodule>
<class>Test123_MyModule_Block</class>
</mymodule>
<checkout>
<rewrite>
<onepage_success>Test123_MyModule_Block_Onepage_Success</onepage_success>
</rewrite>
</checkout>
</blocks>
</global>
</config>
mymodule.xml(app/design/frontend/Test123/default/layout/mymodule.xml
):
<?xml version="1.0"?>
<layout version="0.1.0">
<checkout_onepage_success translate="label">
<label>One Page Checkout Success</label>
<reference name="root">
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
</reference>
<reference name="checkout.success">
<action method="setTemplate"><template>mymodule/success.phtml</template></action>
</reference>
</checkout_onepage_success>
</layout>
success.phtml(app/design/frontend/Test123/default/template/mymodule/success.phtml
):
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magento.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magento.com for more information.
*
* @category design
* @package base_default
* @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
?>
<div class="page-title">
<h1><?php echo $this->__('Your order has been received.') ?></h1>
</div>
<?php echo $this->getMessagesBlock()->toHtml() ?>
<h2 class="sub-title"><?php echo $this->__('Thank you for your purchase!') ?></h2>
<?php if ($this->getOrderId()):?>
<?php if ($this->getCanViewOrder()) :?>
<p><?php echo $this->__('Your order # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getViewOrderUrl()), $this->escapeHtml($this->getOrderId()))) ?></p>
<?php else :?>
<p><?php echo $this->__('Your order # is: %s.', $this->escapeHtml($this->getOrderId())) ?></p>
<?php endif;?>
<p><?php echo $this->__('You will receive an order confirmation email with details of your order and a link to track its progress.') ?></p>
<?php if ($this->getCanViewOrder() && $this->getCanPrintOrder()) :?>
<p>
<?php echo $this->__('Click <a href="%s" onclick="this.target=\'_blank\'">here to print</a> a copy of your order confirmation.', $this->getPrintUrl()) ?>
<?php echo $this->getChildHtml() ?>
</p>
<?php endif;?>
<?php endif;?>
<?php if ($this->getAgreementRefId()): ?>
<p><?php echo $this->__('Your billing agreement # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getAgreementUrl()), $this->escapeHtml($this->getAgreementRefId())))?></p>
<?php endif;?>
<?php if ($profiles = $this->getRecurringProfiles()):?>
<p><?php echo $this->__('Your recurring payment profiles:'); ?></p>
<ul class="disc">
<?php foreach($profiles as $profile):?>
<?php $profileIdHtml = ($this->getCanViewProfiles() ? sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getProfileUrl($profile)), $this->escapeHtml($this->getObjectData($profile, 'reference_id'))) : $this->escapeHtml($this->getObjectData($profile, 'reference_id')));?>
<li><?php echo $this->__('Payment profile # %s: "%s".', $profileIdHtml, $this->escapeHtml($this->getObjectData($profile, 'schedule_description')))?></li>
<?php endforeach;?>
</ul>
<?php endif;?>
<?php echo "<b>hello</b>"; ?>
<div class="buttons-set">
<button type="button" class="button" title="<?php echo $this->__('Continue Shopping') ?>" onclick="window.location='<?php echo $this->getUrl() ?>'"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>
</div>
<script type="text/javascript">
var _vis_opt_revenue = <?php $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); echo $order['base_grand_total'];?>;
window._vis_opt_queue = window._vis_opt_queue || [];
window._vis_opt_queue.push(function() {_vis_opt_revenue_conversion(_vis_opt_revenue);});
</script>