Add 'Shipped' Status and make customer confirm receipt goods

1. Fist, Add a shipped status in backend



 

2.rewrite Mage_Adminhtml_Sales_Order_ShipmentController

<config>  
 <admin>
          <routers>
            <adminhtml>
                <args>
                    <modules>
                        <Bysoft_Mysales before="Mage_Adminhtml">Bysoft_Mysales</Bysoft_Mysales>
                    </modules>
                </args>
            </adminhtml>
          </routers>
      </admin>

 

<?php
include_once("Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php");
class Bysoft_Mysales_Sales_Order_ShipmentController extends Mage_Adminhtml_Sales_Order_ShipmentController {
	protected function _saveShipment($shipment)
	{
		$shipment->getOrder()->setIsInProcess(true);
	
		$order = $shipment->getOrder();
	
		$order = Mage::getModel('sales/order')->loadByIncrementId($order->getIncrementId());
		$state = 'processing';
		$status = 'shipped';
		$comment = 'Changing state to Processing and status to shipped Status';
		$isCustomerNotified = false;
		$order->setState($state, $status, $comment, $isCustomerNotified);
		$order->save();
	
		$transactionSave = Mage::getModel('core/resource_transaction')
		->addObject($shipment)
		->save();
	
		return $this;
	}
}

 3. add a confirm controller for frontend , make cusotmer to confirm the order

<config>
   <frontend>
        <routers>
            <mysales>
                <use>standard</use>
                <args>
                    <module>Bysoft_Mysales</module>
                    <frontName>mysales</frontName>
                </args>
            </mysales>
        </routers>  
    </frontend>

 

<?php
class Bysoft_Mysales_ConfirmController extends Mage_Core_Controller_Front_Action {
	public function saveAction() {
		$order_id = Mage::app()->getRequest()->getParam('order_id');
		if(Mage::getSingleton('customer/session')->isLoggedIn()) {
			$customerData = Mage::getSingleton('customer/session')->getCustomer();
			$customer_id = $customerData->getId();
			$order = Mage::getModel('sales/order')->load($order_id);
			if ( $order->getCustomerId() == $customer_id) {
				$order->setData('state', "complete");
				$order->setStatus("complete");
				$history = $order->addStatusHistoryComment('Order status to complete by customer confirm.', false);
				$history->setIsCustomerNotified(false);
				$order->save();
				$message = $this->__('You have confirmed the order.');
				Mage::getSingleton('core/session')->addSuccess($message);
				$this->_redirectReferer();
			} else {
				return ;
			}
		} else {
			return ;
		}				
	}
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值