Magento付款不清空购物车并继续选择其他的付款方式提交订单

我们知道Magento程序在客户下单付款成功或是失败都会清空掉购物车,
来看看场景
如果我们有这样一个需求如下
当客户付款失败, 我们会跳到支付页面提示支付失败的原因,并让客户选择其他的支付方式,要实现这个需求的前提是购物车未清空.
修改,找到支付模块的saveOrderAction() 这里根据你的一页支付插件而定,这里我们以Firecheckout为例
找到/app/code/local/TM/FireCheckout/controllers/IndexController.php

 $quote->save();
 /**
   * when there is redirect to third party, we don't want to save order yet.
   * we will save the order in return action.
 */
 if (isset($redirectUrl)) {
    $result['redirect'] = $redirectUrl;
 }

更新后的代码

 //$quote->save();
 /**
   * when there is redirect to third party, we don't want to save order yet.
   * we will save the order in return action.
 */
  if (isset($redirectUrl)) {
     $result['redirect'] = $redirectUrl;
  }else{
	$quote->save();
  }

Magento提交订单会跳转到支付结果页面,我们需要将failure.phtml的内容修改成如下:
找到app/design/frontend/主题/default/template/checkout/onepage/failure.phtml

<?php if ($this->getRealOrderId()) : ?><p><?php echo $this->__('Order #') . $this->getRealOrderId() ?></p><?php endif ?>
<?php if ($error = $this->getErrorMessage()) : ?><p><?php echo $error ?></p><?php endif ?>
<?php
	$order_id = $this->getRealOrderId();
	header("Location: https://你的域名/firecheckout/?order_id=$order_id");
?>

在Checkout页面我们提示信用卡支付信息
找到/app/design/frontend/base/default/template/tm/firecheckout/checkout.phtml
添加如下代码

<?php if($_GET['order_id']):?>
<p style="color:red; height:25px;line-height:25px;">SORRY,TRANSACTION FAILURRE, order number: <?php echo $_GET['order_id'];?>, please choose other payment methods: PayPal or Western Union.</p>
<?php endif;?>

真正有需要的朋友可以去测试。。。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章