├── .gitignore ├── CONTRIBUTING.md ├── LICENSE_AFL.txt ├── README.md ├── app ├── code │ └── community │ │ └── Magemaven │ │ └── OrderComment │ │ ├── Block │ │ ├── Adminhtml │ │ │ └── Sales │ │ │ │ └── Order │ │ │ │ └── Grid.php │ │ └── Checkout │ │ │ └── Agreements.php │ │ ├── Helper │ │ └── Data.php │ │ ├── Model │ │ ├── Mysql4 │ │ │ └── Order │ │ │ │ └── Grid │ │ │ │ └── Collection.php │ │ ├── Observer.php │ │ └── Resource │ │ │ └── Order │ │ │ └── Grid │ │ │ └── Collection.php │ │ └── etc │ │ └── config.xml ├── design │ └── frontend │ │ └── base │ │ └── default │ │ └── template │ │ └── ordercomment │ │ └── checkout │ │ └── agreements.phtml └── etc │ └── modules │ └── Magemaven_OrderComment.xml ├── composer.json └── modman /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | 3 | I appreciate any kind of contributions. Please feel free to submit issue reports, feature suggestions and especially pull requests. But please take a moment to review following guidelines. 4 | 5 | ## Got a Question? 6 | 7 | Please don't use Github Issues for asking questions. This project uses Github Issues for bug tracking and feature management only, not as some kind of support forum. 8 | If you have personal support request or any questions about how to use this project, please feel free to send an email to project maintainer. You may find the email address in maintainer's Github profile. 9 | 10 | ## Reporting bugs 11 | 12 | Please make sure that issue is reproducible on the latest code in `develop` branch in the repository. 13 | 14 | Be sure to include enough of information so that your issue can be recreated. 15 | 16 | Make sure that no other similar issues already exist. 17 | 18 | ## Submitting pull requests 19 | 20 | ### Branches 21 | 22 | This repository is using [git flow](http://nvie.com/posts/a-successful-git-branching-model/) branching model. If you're not familiar with it, please take a moment to read the text by the link. 23 | 24 | Generally it means that all new branches should be forked from `develop` branch, not from `master`. 25 | 26 | ### Pull request workflow 27 | 28 | 1. Fork the repo. 29 | 2. Checkout your new branch from `develop` branch. 30 | 3. Push your changes to your branch in your fork of repository. 31 | 4. Submit a pull request to the upstream repository. 32 | -------------------------------------------------------------------------------- /LICENSE_AFL.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magemaven/magento-order-comment/6ae09378535fda0adc29e474c12ead489302dc73/LICENSE_AFL.txt -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [UNMAINTAINED] Magemaven OrderComment 2 | ===================================== 3 | 4 | **This module is no longer maintained** 5 | 6 | Simple extension that adds new field to order review checkout section, where customers can leave comments to their orders. 7 | 8 | It doesn't require heavy manual template edits and uses Magento core order comments functionality. The main goal during development was to make lightweight and simple extension, that needs minimum admin interaction while install. 9 | 10 | * Download from Magento Connect: [http://www.magentocommerce.com/magento-connect/catalog/product/view/id/10860/](http://www.magentocommerce.com/magento-connect/catalog/product/view/id/10860/) 11 | * Support Forum: [http://magemaven.com/forum/#/categories/magemaven-ordercomment](http://magemaven.com/forum/#/categories/magemaven-ordercomment) 12 | * Bugtracker: [http://github.com/r8/magento-order-comment/issues](http://github.com/r8/magento-order-comment/issues) 13 | 14 | Installation 15 | ------------ 16 | 17 | In most cases this extension will work out of the box. But if you have installed custom theme, that doesn't support all Magento features, you may need to make some changes in your layout files. 18 | 19 | Basically, you need to locate checkout.xml file in your theme, find block with type 'checkout/onepage_review_info' and make sure, that it contains following code near its end: 20 | 21 | 22 | 23 | In case you don't see it, please add this code just before the block with the name 'checkout.onepage.review.button' 24 | -------------------------------------------------------------------------------- /app/code/community/Magemaven/OrderComment/Block/Adminhtml/Sales/Order/Grid.php: -------------------------------------------------------------------------------- 1 | 11 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 12 | */ 13 | class Magemaven_OrderComment_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid 14 | { 15 | /** 16 | * Columns, that become ambiguous after join 17 | * 18 | * @var array 19 | */ 20 | protected $_ambiguousColumns = array( 21 | 'status', 22 | 'created_at', 23 | ); 24 | 25 | /** 26 | * Retrieve collection class 27 | * 28 | * @return string 29 | */ 30 | protected function _getCollectionClass() 31 | { 32 | return 'ordercomment/order_grid_collection'; 33 | } 34 | 35 | /** 36 | * Prepare grid columns 37 | * 38 | * @return Magemaven_OrderComment_Block_Adminhtml_Sales_Order_Grid 39 | */ 40 | protected function _prepareColumns() 41 | { 42 | parent::_prepareColumns(); 43 | 44 | // Add order comment to grid 45 | $this->addColumn('ordercomment', array( 46 | 'header' => Mage::helper('ordercomment')->__('Last Comment'), 47 | 'index' => 'ordercomment', 48 | 'filter_index' => 'ordercomment_table.comment', 49 | )); 50 | 51 | // Fix integrity constraint violation in SELECT 52 | foreach ($this->_ambiguousColumns as $index) { 53 | if (isset($this->_columns[$index])) { 54 | $this->_columns[$index]->setFilterIndex('main_table.' . $index); 55 | } 56 | } 57 | 58 | return $this; 59 | } 60 | 61 | /** 62 | * Prepare grid massactions 63 | * 64 | * @return Magemaven_OrderComment_Block_Adminhtml_Sales_Order_Grid 65 | */ 66 | protected function _prepareMassaction() 67 | { 68 | parent::_prepareMassaction(); 69 | 70 | // VERY dirty hack to resolve conflict with Seamless Delete Order 71 | $modules = (array)Mage::getConfig()->getNode('modules')->children(); 72 | if (isset($modules['EM_DeleteOrder']) && $modules['EM_DeleteOrder']->is('active')) { 73 | $this->getMassactionBlock()->addItem('delete_order', array( 74 | 'label'=> Mage::helper('sales')->__('Delete order'), 75 | 'url' => $this->getUrl('*/sales_order/deleteorder'), 76 | )); 77 | } 78 | return $this; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /app/code/community/Magemaven/OrderComment/Block/Checkout/Agreements.php: -------------------------------------------------------------------------------- 1 | 11 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 12 | */ 13 | class Magemaven_OrderComment_Block_Checkout_Agreements extends Mage_Checkout_Block_Agreements 14 | { 15 | /** 16 | * Override block template 17 | * 18 | * @return string 19 | */ 20 | protected function _toHtml() 21 | { 22 | $this->setTemplate('ordercomment/checkout/agreements.phtml'); 23 | return parent::_toHtml(); 24 | } 25 | } -------------------------------------------------------------------------------- /app/code/community/Magemaven/OrderComment/Helper/Data.php: -------------------------------------------------------------------------------- 1 | 11 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 12 | */ 13 | class Magemaven_OrderComment_Helper_Data extends Mage_Core_Helper_Abstract 14 | { 15 | 16 | } -------------------------------------------------------------------------------- /app/code/community/Magemaven/OrderComment/Model/Mysql4/Order/Grid/Collection.php: -------------------------------------------------------------------------------- 1 | 11 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 12 | */ 13 | class Magemaven_OrderComment_Model_Mysql4_Order_Grid_Collection extends Mage_Sales_Model_Resource_Order_Grid_Collection 14 | { 15 | } -------------------------------------------------------------------------------- /app/code/community/Magemaven/OrderComment/Model/Observer.php: -------------------------------------------------------------------------------- 1 | 11 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 12 | */ 13 | class Magemaven_OrderComment_Model_Observer extends Varien_Object 14 | { 15 | /** 16 | * Current comment 17 | * 18 | * @var bool|string 19 | */ 20 | protected $_currentComment = false; 21 | 22 | /** 23 | * Save comment from agreement form to order 24 | * 25 | * @param $observer 26 | */ 27 | public function saveOrderComment($observer) 28 | { 29 | $orderComment = Mage::app()->getRequest()->getPost('ordercomment'); 30 | if (is_array($orderComment) && isset($orderComment['comment'])) { 31 | $comment = trim($orderComment['comment']); 32 | $comment = nl2br(Mage::helper('ordercomment')->stripTags($comment)); 33 | 34 | if (!empty($comment)) { 35 | $order = $observer->getEvent()->getOrder(); 36 | $order->setCustomerNoteNotify(true); 37 | $order->setCustomerNote($comment); 38 | $this->_currentComment = $comment; 39 | } 40 | } 41 | } 42 | 43 | /** 44 | * Show customer comment in 'My Account' 45 | * 46 | * @param $observer 47 | */ 48 | public function setOrderCommentVisibility($observer) 49 | { 50 | if ($this->_currentComment) { 51 | $statusHistory = $observer->getEvent()->getStatusHistory(); 52 | 53 | if ($statusHistory && $this->_currentComment == $statusHistory->getComment()) { 54 | $statusHistory->setIsVisibleOnFront(1); 55 | } 56 | } 57 | 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /app/code/community/Magemaven/OrderComment/Model/Resource/Order/Grid/Collection.php: -------------------------------------------------------------------------------- 1 | 11 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 12 | */ 13 | class Magemaven_OrderComment_Model_Resource_Order_Grid_Collection extends Mage_Sales_Model_Mysql4_Order_Grid_Collection 14 | { 15 | protected function _afterLoad() 16 | { 17 | parent::_afterLoad(); 18 | if (count($this->_items) > 0) { 19 | $ids = array(); 20 | 21 | foreach ($this->_items as $item) { 22 | $ids[] = $item->getId(); 23 | } 24 | $ids = implode(',', $ids); 25 | 26 | $select = $this->getConnection() 27 | ->select() 28 | ->from($this->getTable('sales/order_status_history')) 29 | ->where("parent_id IN ($ids)") 30 | ->order('created_at ASC'); 31 | 32 | $items = $this->getConnection()->fetchAll($select); 33 | 34 | foreach($items as $item) { 35 | $parent = $this->_items[$item['parent_id']]; 36 | $parent->setOrdercomment($item['comment']); 37 | } 38 | } 39 | 40 | return $this; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/code/community/Magemaven/OrderComment/etc/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 17 | 18 | 1.0.5.0 19 | 20 | 21 | 22 | 23 | 24 | Magemaven_OrderComment_Model 25 | ordercomment_resource 26 | 27 | 28 | Magemaven_OrderComment_Model_Resource 29 | ordercomment_mysql4 30 | 31 | 32 | 33 | Magemaven_OrderComment_Model_Mysql4_Order_Grid_Collection 34 | 35 | 36 | 37 | 38 | 39 | Magemaven_OrderComment_Helper 40 | 41 | 42 | 43 | 44 | Magemaven_OrderComment_Block 45 | 46 | 47 | 48 | Magemaven_OrderComment_Block_Checkout_Agreements 49 | 50 | 51 | 52 | 53 | Magemaven_OrderComment_Block_Adminhtml_Sales_Order_Grid 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | Magemaven_OrderComment_Model_Observer 64 | saveOrderComment 65 | 66 | 67 | 68 | 69 | 70 | 71 | Magemaven_OrderComment_Model_Observer 72 | saveOrderComment 73 | 74 | 75 | 76 | 77 | 78 | 79 | Magemaven_OrderComment_Model_Observer 80 | setOrderCommentVisibility 81 | 82 | 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /app/design/frontend/base/default/template/ordercomment/checkout/agreements.phtml: -------------------------------------------------------------------------------- 1 | 11 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 12 | */ 13 | ?> 14 |
15 |
16 |
    17 |
  • 18 |
    19 |
      20 |
    • 21 | 22 |
      23 | 24 |
      25 |
    • 26 |
    27 |
    28 |
  • 29 |
30 |
31 | 32 | getAgreements()): ?> 33 |
    34 | getAgreements() as $_a): ?> 35 |
  1. 36 |
    getContentHeight() ? ' style="height:' . $_a->getContentHeight() . '"' : '')?>> 37 | getIsHtml()):?> 38 | getContent() ?> 39 | 40 | htmlEscape($_a->getContent())) ?> 41 | 42 |
    43 |

    44 | 45 |

    46 |
  2. 47 | 48 |
49 | 50 |
51 | -------------------------------------------------------------------------------- /app/etc/modules/Magemaven_OrderComment.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 17 | 18 | true 19 | community 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "magemaven/order-comment", 3 | "description": "Magento extension that allows customer to specify optional comment during order placing.", 4 | "type": "magento-module", 5 | "homepage": "https://github.com/r8/magento-order-comment", 6 | "license": "AFL-3.0", 7 | "authors": [ 8 | { 9 | "name": "Sergey Storchay", 10 | "email": "r8@r8.com.ua" 11 | } 12 | ], 13 | "require": { 14 | "magento-hackathon/magento-composer-installer": "*" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /modman: -------------------------------------------------------------------------------- 1 | app/code/community/Magemaven/OrderComment app/code/community/Magemaven/OrderComment 2 | app/design/frontend/base/default/template/ordercomment app/design/frontend/base/default/template/ordercomment 3 | app/etc/modules/Magemaven_OrderComment.xml app/etc/modules/Magemaven_OrderComment.xml 4 | --------------------------------------------------------------------------------