1. rewrite in config.xml:
<config> <helpers> <mysales> <class>Bysoft_Mysales_Helper</class> </mysales> </helpers> <frontend> <routers> <mysales> <use>standard</use> <args> <module>Bysoft_Mysales</module> <frontName>mysales</frontName> </args> </mysales> <sales> <args> <modules> <Bysoft_Mysales before="Mage_Sales">Bysoft_Mysales</Bysoft_Mysales> </modules> </args> </sales> </routers> </frontend> </config>
rewrite core sales order controller:
<?php require_once Mage::getModuleDir('controllers', 'Mage_Sales').DS.'OrderController.php'; class Bysoft_Mysales_OrderController extends Mage_Sales_OrderController { public function cancelAction() { // Retrieve order_id passed by clicking on "Cancel Order" in customer account $orderId = $this->getRequest()->getParam('id'); // Load Mage_Sales_Model_Order object $order = Mage::getModel('sales/order')->load($orderId); // Retrieve catalog session. // We must use catalog session as customer session messages are not initiated for sales order view // and this is where we want to redirect at the end of this action // @see Mage_Sales_Controller_Abstract::_viewAction() $session = Mage::getSingleton('catalog/session'); try { // Make sure that the order can still be canceled since customer clicked on "Cancel Order" if(!Mage::helper('mysales')->canCancel($order)) { throw new Exception('Order cannot be canceled anymore.'); } // Cancel and save the order $order->cancel(); $order->save(); // If sending transactionnal email is enabled in system configuration, we send the email if(Mage::getStoreConfigFlag('sales/cancel/send_email')) { $order->sendOrderUpdateEmail(); } $session->addSuccess($this->__('The order has been canceled.')); } catch (Exception $e) { Mage::logException($e); $session->addError($this->__('The order cannot be canceled.')); } // Redirect to current sale order view $this->_redirect('sales/order/history'); } }
Helper file for checking if the order can be canceled:
<?php class Bysoft_Mysales_Helper_Data extends Mage_Core_Helper_Abstract { public function canCancel(Mage_Sales_Model_Order $order) { // If Magento decides that this order cannot be canceled if(!$order->canCancel()) { return false; } // Else... return true return true; } }
Add link to template file:
<?php if (Mage::helper('mysales')->canCancel($_order)):?> <span class="separator">|</span> <a href="<?php echo $this->getUrl('sales/order/cancel', array('id'=>$_order->getId()));?>" class="link-cancel"><?php echo $this->__('Cancel') ?> </a> <?php endif;?>
相关推荐
Magento Order Export
content:deploy -f这是前端的结果 如果这个项目可以帮助您减少开发时间,那么可以给我一杯咖啡:)Magento产品滑块Magento产品横幅我们的Magento服务PSD到Magento 2主题转换Magento速度优化服务Magento安全补丁安装...
NULL 博文链接:https://justcoding.iteye.com/blog/1725217
10 predefined block positions on each page Ability to place any block in any position by easily changing CMS page layout Unlimited number of blocks inside each position Unlimited number of content...
magento2前端学习手册
在Magento 2中禁用前端 禁用Magento 2中的前端,以仅使用Admin和API路由。 1-禁用安装前端 手动安装 为Magento2安装禁用前端 下载扩展 解压缩文件 创建一个文件夹{Magento root} / app / code / Abelbm / ...
magento2-example-..../magento session:catalog:list --attributes "type_id,name,sku,price" --inventory_fields "qty,use_config_backorders" website --type "configurable" --type "simple" --order "type_id
magento数据结构分析 magento数据字典
一般magento是不可以删除订单的,有了这个就可以删除了,不过删除完就无法再恢复,此插件在1.7.0.2上可以使用
NULL 博文链接:https://justcoding.iteye.com/blog/2100394
Chapter 1, Installing Magento 2 on Apache and NGINX, is a totally different ballgame compared to Magento 1. Where Magento 1 could be installed through FTP or SSH, Magento 2 is installable only via the...
Magento全页缓存插件,适用于1.6-1.8社区版
magik shoes magento 模板, magento 1.7 模板
Magento 2 Beginners Guide by Gabriel Guarino English | 14 Mar. 2017 | ASIN: B01MS81BQX | 442 Pages | AZW3 | 31.84 MB Key Features Set up and manage your very first online store with a friendly and ...
magento的SMTP插件magento的SMTP插件magento的SMTP插件
Get a hands-on introduction to custom shipping and payment methods ☆ 出版信息:☆ [作者信息] Branko Ajzele [出版机构] Packt Publishing [出版日期] 2013年09月25日 [图书页数] 128页 [图书语言] 英语...
深入理解Magento 由精东博客下载下来制作成pdf
文献资料安装使用作曲家composer require magepal/magento2-edit-order-email贡献想要为这个扩展做贡献吗? 最快的方法是打开请求请求。 支持如果您遇到任何问题或错误,请在GitHub上打开一个问题。 需要设置帮助或...
Magento插件开发手册 Magento Extension Developers Guide