2016-12-05 11 views
0

所以我最近開始使用magento 1.9。我有一個具體的問題,我不知道如何解決。我創建了一個自定義付款模塊,顯示在付款選項中,當用戶下訂單時,它會重定向到我的自定義結賬成功消息。然而,這不完全是我想要的。如果選擇了任何付款選項,我希望能夠將用戶重定向到我的自定義網址,例如,貝寶或信用卡。當我在magento中下訂單時,如何覆蓋提交網址。

在我的自定義控制器中,我想將一些信息附加到表單,然後將其轉發到網關。

我想這個問題是類似的。但我不想編輯magento的核心代碼,我想重寫我的自定義模塊。 Magento "place order" redirection for payment gateway

有沒有人可以幫助或指向正確的方向?

回答

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 [email protected] 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>