当我在Magento下订单时,如何覆盖提交URL



所以我最近开始使用Magento 1.9。而且我有一个特定的问题,我不确定如何解决。我创建了一个自定义付款模块,该模块显示在付款选项中,当用户下订单时,它将其重定向到我的自定义结帐成功消息。但是,这并不是我想要的。如果选择了任何付款选项,例如PayPal或CreditCard,我希望能够将用户重定向到我的自定义URL。

在我的自定义控制器中,我想将一些信息附加到表单上,然后将其转发到网关。

我猜这个问题与此相似。但是我不想编辑Magento的核心代码,我想从自定义模块中覆盖。Magento"放置订单"付款网关的重定向

是否有人可以帮助我朝正确的方向指向我?

请参阅此示例;

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>

最新更新