您的位置:首页 > 其它

magento 开发 -- 新增一个简单的退货流程

2014-05-14 14:56 218 查看
功能描述

顾客申请退货—>客服收到退货邮件—>客服电话确认—>操作系统—>财务退款

业务流程

1.在后台新增一个订单状态refunding

2.前台用户订单新增退货按钮

app/code/core/Mage/Sales/Block/Order/Recent.php

//退货链接
public function getRefundingUrl($order)
{
return $this->getUrl('sales/order/refunding',array('order_id'=> $order->getId()));
}


app/design/frontend/base/default/template/sales/order/recent.phtml
<?php if ($_order->getStatus() == 'complete') : ?>
<span class="separator">|</span> <a href="<?php echo $this->getRefundingUrl($_order) ?>"><?php echo $this->__('Refunding') ?></a>
<?php endif ?>


app/code/core/Mage/Sales/Controller/Abstract.php

//退货功能
public function refundingAction()
{
if (!$this->_loadValidOrder()) {
return;
}

$order = Mage::registry('current_order');

if ($this->_canViewOrder($order) && $order->getStatus()=='complete') {
//更改订单状态
$order->setData('status','refunding');
$order->save();
//发送邮件给客服
$storeId = $order->getStoreId();
$customerName = $order->getCustomer_lastname().' '.$order->getCustomer_firstname();
$increment_id = $order->getIncrement_id();
$shippingId = $order->getShipping_address_id();
$address = Mage::getModel('sales/order_address')->load($shippingId);
$telephone = $address->getTelephone();
$user_email = $address->getEmail();

//接收邮件在后台Custom Email 1里配置,默认发送邮给Custom Email 1里配置的邮件地址
$receiveEmail = Mage::getStoreConfig('trans_email/ident_custom1/email');
$receiveName = Mage::getStoreConfig('trans_email/ident_custom1/name');

$vars = array('user_name' => $customerName, 'increment_id' => $increment_id , 'user_email'=>$user_email, 'telephone'=>$telephone ,'receive_name'=>$receiveName);
try {
$templateId = "Order Refunding";
$emailTemplate = Mage::getModel('core/email_template')->loadByCode($templateId);

$emailTemplate->setSenderEmail(Mage::getStoreConfig('trans_email/ident_general/email', $storeId));
$emailTemplate->setSenderName(Mage::getStoreConfig('trans_email/ident_general/name', $storeId));
//echo $emailTemplate->getProcessedTemplate($vars);  //预览邮件效果
$emailTemplate->send($receiveEmail,$receiveName, $vars);
}catch (Exception $e){
Mage::log('The Order '.$increment_id.' is refunding,But not email to Customer Service');
Mage::getSingleton('catalog/session')
->addException($e, $this->__('Some emails were not sent.'));
}

}

$this->_redirect('*/*/history');
}


之后的操作,由客服去完成

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: