Cdr_OrderComment - Version 0.0.2

Version Notes

Added Order Comments to Onepage Checkout & Multi-shipping Checkout.

Order comment is displayed within the Orders Grid and orders comment history

Download this release

Release Info

Developer Cdr
Extension Cdr_OrderComment
Version 0.0.2
Comparing to
See all releases


Version 0.0.2

app/code/community/Cdr/OrderComment/Block/Checkout/Onepage/Review/Commentfield.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Cdr_OrderComment_Block_Checkout_Onepage_Review_Commentfield extends Mage_Core_Block_Template
5
+ {
6
+
7
+ public function getMaxCommentSize()
8
+ {
9
+ if ($this->limitTextArea())
10
+ {
11
+ return Mage::getStoreConfig('ordercomment/settings/limit');
12
+ }
13
+ return '';
14
+ }
15
+
16
+ public function limitTextArea()
17
+ {
18
+ $limit = Mage::getStoreConfig('ordercomment/settings/limit');
19
+ return (is_numeric($limit) && $limit > 0);
20
+ }
21
+
22
+ public function isActive()
23
+ {
24
+ return Mage::getStoreConfigFlag('ordercomment/settings/active');
25
+ }
26
+ }
app/code/community/Cdr/OrderComment/Block/Sales/Order/View/Ordercomment.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cdr_OrderComment_Block_Sales_Order_View_Ordercomment extends Mage_Core_Block_Template
4
+ {
5
+ public function isActive()
6
+ {
7
+ return Mage::getStoreConfigFlag('ordercomment/settings/active');
8
+ }
9
+
10
+ /**
11
+ * Retrieve current orders order comment
12
+ *
13
+ * @return string
14
+ */
15
+ public function getOrderComment()
16
+ {
17
+ return nl2br(Mage::registry('current_order')->getCdrOrderComment());
18
+ }
19
+ }
app/code/community/Cdr/OrderComment/Helper/Data.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Cdr_OrderComment_Helper_Data extends Mage_Core_Helper_Abstract
5
+ {
6
+
7
+ }
app/code/community/Cdr/OrderComment/Model/Observer.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Cdr_OrderComment_Model_Observer
4
+ {
5
+
6
+ /**
7
+ *
8
+ * @param Varien_Event_Observer $observer
9
+ * @return Varien_Event_Observer
10
+ */
11
+ public function saveOrderComment($observer)
12
+ {
13
+ if (Mage::getStoreConfigFlag('ordercomment/settings/active')) {
14
+ $comment = trim(Mage::app()->getRequest()->getPost('cdr_ordercomment'));
15
+
16
+ if (!empty($comment)) {
17
+ $limit = (int) Mage::getStoreConfig('ordercomment/settings/limit');
18
+ if (is_integer($limit) && $limit > 0 && strlen($comment) > $limit)
19
+ $comment = substr($comment, 0, $limit);
20
+
21
+ $order = $observer->getEvent()->getOrder();
22
+ /* @var $order Mage_Sales_Model_Order */
23
+
24
+ $order->setCdrOrderComment($comment);
25
+ $order->setCustomerComment($comment);
26
+ $order->setCustomerNoteNotify(true);
27
+ $order->setCustomerNote($comment);
28
+ }
29
+ }
30
+ return $this;
31
+ }
32
+
33
+ }
app/code/community/Cdr/OrderComment/etc/adminhtml.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <ordercomment>
12
+ <title>CDR Order Comment</title>
13
+ </ordercomment>
14
+ </children>
15
+ </config>
16
+ </children>
17
+ </system>
18
+ </children>
19
+ </admin>
20
+ </resources>
21
+ </acl>
22
+ </config>
app/code/community/Cdr/OrderComment/etc/config.xml ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Cdr_OrderComment>
5
+ <version>0.0.2</version>
6
+ </Cdr_OrderComment>
7
+ </modules>
8
+ <global>
9
+ <blocks>
10
+ <ordercomment>
11
+ <class>Cdr_OrderComment_Block</class>
12
+ </ordercomment>
13
+ </blocks>
14
+ <helpers>
15
+ <ordercomment>
16
+ <class>Cdr_OrderComment_Helper</class>
17
+ </ordercomment>
18
+ </helpers>
19
+ <models>
20
+ <ordercomment>
21
+ <class>Cdr_OrderComment_Model</class>
22
+ </ordercomment>
23
+ </models>
24
+ <resources>
25
+ <ordercomment_setup>
26
+ <setup>
27
+ <module>Cdr_OrderComment</module>
28
+ <class>Mage_Core_Model_Resource_Setup</class>
29
+ </setup>
30
+ </ordercomment_setup>
31
+ </resources>
32
+ </global>
33
+ <adminhtml>
34
+ <layout>
35
+ <updates>
36
+ <ordercomment>
37
+ <file>cdr_ordercomment.xml</file>
38
+ </ordercomment>
39
+ </updates>
40
+ </layout>
41
+ </adminhtml>
42
+ <frontend>
43
+ <layout>
44
+ <updates>
45
+ <ordercomment>
46
+ <file>cdr_ordercomment.xml</file>
47
+ </ordercomment>
48
+ </updates>
49
+ </layout>
50
+ <events>
51
+ <checkout_type_onepage_save_order>
52
+ <observers>
53
+ <saveOrderComment>
54
+ <class>ordercomment/observer</class>
55
+ <method>saveOrderComment</method>
56
+ </saveOrderComment>
57
+ </observers>
58
+ </checkout_type_onepage_save_order>
59
+ <checkout_type_multishipping_create_orders_single>
60
+ <observers>
61
+ <saveOrderComment>
62
+ <class>ordercomment/observer</class>
63
+ <method>saveOrderComment</method>
64
+ </saveOrderComment>
65
+ </observers>
66
+ </checkout_type_multishipping_create_orders_single>
67
+ </events>
68
+ </frontend>
69
+ </config>
app/code/community/Cdr/OrderComment/etc/system.xml ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <tabs>
4
+ <cdr_config translate="label">
5
+ <label>CDR</label>
6
+ <sort_order>1</sort_order>
7
+ </cdr_config>
8
+ </tabs>
9
+ <sections>
10
+ <ordercomment translate="label" module="ordercomment">
11
+ <label>Order Comment</label>
12
+ <tab>cdr_config</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>10</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <settings translate="label">
20
+ <label>Settings</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>10</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <fields>
27
+ <active translate="label">
28
+ <label>Enable Order Comment</label>
29
+ <frontend_type>select</frontend_type>
30
+ <source_model>adminhtml/system_config_source_yesno</source_model>
31
+ <sort_order>1</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ </active>
36
+ <limit translate="label">
37
+ <label>Character Limit</label>
38
+ <frontend_type>text</frontend_type>
39
+ <sort_order>10</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>1</show_in_store>
43
+ <comment><![CDATA[Leave blank for no limit]]></comment>
44
+ <depends>
45
+ <active>1</active>
46
+ </depends>
47
+ </limit>
48
+ <grid translate="label">
49
+ <label>Show Order Comment on Order Grid</label>
50
+ <frontend_type>select</frontend_type>
51
+ <source_model>adminhtml/system_config_source_yesno</source_model>
52
+ <sort_order>1</sort_order>
53
+ <show_in_default>1</show_in_default>
54
+ </grid>
55
+ </fields>
56
+ </settings>
57
+ </groups>
58
+ </ordercomment>
59
+ </sections>
60
+ </config>
app/code/community/Cdr/OrderComment/sql/ordercomment_setup/install-0.0.1.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+ $conn=$installer->getConnection();
7
+ /* @var $conn Varien_Db_Adapter_Pdo_Mysql */
8
+
9
+ $conn->addColumn($installer->getTable('sales/order'),
10
+ 'cdr_order_comment',
11
+ array(
12
+ 'nullable' => true,
13
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
14
+ 'length' => '64k',
15
+ 'comment' => 'Order Comment'
16
+ ));
17
+
18
+ $this->endSetup();
app/code/community/Cdr/OrderComment/sql/ordercomment_setup/upgrade-0.0.1-0.0.2.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+ $conn=$installer->getConnection();
7
+ /* @var $conn Varien_Db_Adapter_Pdo_Mysql */
8
+
9
+ $conn->addColumn($installer->getTable('sales/order_grid'),
10
+ 'cdr_order_comment',
11
+ array(
12
+ 'nullable' => true,
13
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
14
+ 'length' => '64k',
15
+ 'comment' => 'Order Comment'
16
+ ));
17
+
18
+ $select = $this->getConnection()->select();
19
+ $select->join(
20
+ array('order'=>$this->getTable('sales/order')),
21
+ $this->getConnection()->quoteInto(
22
+ 'order.entity_id = order_grid.entity_id'
23
+ ),
24
+ array('cdr_order_comment' => 'cdr_order_comment')
25
+ );
26
+ $this->getConnection()->query(
27
+ $select->crossUpdateFromSelect(
28
+ array('order_grid' => $this->getTable('sales/order_grid'))
29
+ )
30
+ );
31
+
32
+ $this->endSetup();
app/design/frontend/base/default/layout/cdr_ordercomment.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <checkout_onepage_review>
4
+ <reference name="checkout.onepage.review.info.items.after">
5
+ <block type="ordercomment/checkout_onepage_review_commentfield" name="cdr_order_comment" template="cdr/ordercomment/onepage/review/commentfield.phtml" />
6
+ </reference>
7
+ </checkout_onepage_review>
8
+
9
+ <checkout_multishipping_overview>
10
+ <reference name="checkout.multishipping.overview.items.after">
11
+ <block type="ordercomment/checkout_onepage_review_commentfield" name="cdr_order_comment" template="cdr/ordercomment/onepage/review/commentfield.phtml" />
12
+ </reference>
13
+ </checkout_multishipping_overview>
14
+
15
+ <sales_order_view>
16
+ <reference name="my.account.wrapper">
17
+ <block type="ordercomment/sales_order_view_ordercomment" name="cdr_ordercomment_info" after="sales.order.info" template="cdr/ordercomment/sales/order/view/ordercomment.phtml" />
18
+ </reference>
19
+ </sales_order_view>
20
+ </layout>
app/design/frontend/base/default/template/cdr/ordercomment/onepage/review/commentfield.phtml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php /* @var $this Cdr_OrderComment_Block_Checkout_Onepage_Review_Commentfield */ ?>
2
+
3
+ <?php if ($this->isActive()) : ?>
4
+ <div id="cdr_ordercomment-form">
5
+ <div class="buttons-set">
6
+ <ul class="form-list">
7
+ <li>
8
+ <fieldset>
9
+ <ul>
10
+ <li class="wide">
11
+ <label for="cdr_ordercomment"><?php echo Mage::helper('ordercomment')->__('CDR Order Comment') ?></label>
12
+ <div class="input-box">
13
+ <textarea id="cdr_ordercomment" class="input-text validation-passed" name="cdr_ordercomment" title="<?php echo $this->__('CDR Order Comment') ?>" rows="5" cols="10" maxlength="<?php echo $this->getMaxCommentSize(); ?>"></textarea>
14
+ <?php if ($this->limitTextArea()): ?>
15
+ <p><span id="cdr_ordercomment-max-len"><?php echo $this->getMaxCommentSize(); ?></span> <?php echo Mage::helper('ordercomment')->__('Chars Remaining'); ?></p>
16
+ <?php endif; ?>
17
+ </div>
18
+ </li>
19
+ </ul>
20
+ </fieldset>
21
+ </li>
22
+ </ul>
23
+ </div>
24
+ </div>
25
+ <script>
26
+ if ($('checkout-agreements'))
27
+ $('checkout-agreements').appendChild($('cdr_ordercomment-form'));
28
+
29
+ <?php if ($this->limitTextArea()): ?>
30
+ $('cdr_ordercomment').observe('keyup', function(event) {
31
+ var max = <?php echo $this->getMaxCommentSize(); ?>;
32
+ var current = event.element().value.length;
33
+ $('cdr_ordercomment-max-len').innerHTML = (max - current);
34
+ });
35
+ <?php endif; ?>
36
+ </script>
37
+ <?php endif; ?>
app/design/frontend/base/default/template/cdr/ordercomment/sales/order/view/ordercomment.phtml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php /* @var $this Cdr_OrderComment_Block_Sales_Order_View_Ordercomment */ ?>
2
+
3
+ <?php if($this->isActive()) : ?>
4
+ <div class="col1-set order-info-box">
5
+ <div class="col-1">
6
+ <div class="box">
7
+ <div class="box-title">
8
+ <h2>Order Comment</h2>
9
+ </div>
10
+ <div class="box-content">
11
+ <?php echo $this->getOrderComment(); ?>
12
+ </div>
13
+ </div>
14
+ </div>
15
+ </div>
16
+ <?php endif; ?>
app/etc/modules/Cdr_OrderComment.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Cdr_OrderComment>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Cdr_OrderComment>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Cdr_OrderComment</name>
4
+ <version>0.0.2</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Customers can add an Order Comment at time of checkout.</summary>
10
+ <description>Order Comment can be added to the order by the customer at the time of checkout for both onepage checkout and checkout with multiple addresses.&#xD;
11
+ &#xD;
12
+ The admin orders grid can display the order comment with full filter and sorting capabilities without overriding the sales order grid block. &#xD;
13
+ This means that it will be compatible with any other module that alters the sales order grid.</description>
14
+ <notes>Added Order Comments to Onepage Checkout &amp; Multi-shipping Checkout.&#xD;
15
+ &#xD;
16
+ Order comment is displayed within the Orders Grid and orders comment history&#xD;
17
+ </notes>
18
+ <authors><author><name>Cdr_Software</name><user>PaulKetelle</user><email>paul@ketelle.co.uk</email></author></authors>
19
+ <date>2014-02-18</date>
20
+ <time>14:50:24</time>
21
+ <contents><target name="mageetc"><dir name="modules"><file name="Cdr_OrderComment.xml" hash="9787f0ac2363120a6ed4432833d42428"/></dir></target><target name="magecommunity"><dir name="Cdr"><dir name="OrderComment"><dir><dir name="Block"><dir name="Checkout"><dir name="Onepage"><dir name="Review"><file name="Commentfield.php" hash="d7e95f809fb5bae7e0586fad2d69b9ab"/></dir></dir></dir><dir name="Sales"><dir name="Order"><dir name="View"><file name="Ordercomment.php" hash="4a5b4ca1950038facaacdd78382b22de"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="37da67c151f7da560e7d98084a883821"/></dir><dir name="Model"><file name="Observer.php" hash="f8632302b82651f2a0118a89ee2b8a9a"/></dir><dir name="etc"><file name="adminhtml.xml" hash="0d103e251b0e2d2216ba4906bd6ab41c"/><file name="config.xml" hash="065a6c0c3492fae94812222eab88cf54"/><file name="system.xml" hash="ab78872ea76a77c4ccf13e63c273051b"/></dir><dir name="sql"><dir name="ordercomment_setup"><file name="install-0.0.1.php" hash="e14626ce4cfb4962c1397792b6e27cb5"/><file name="upgrade-0.0.1-0.0.2.php" hash="cbff0ca491fb00179cc571965adc654e"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="cdr_ordercomment.xml" hash="fb262c270f7dcbe901e6b2a95bc6df85"/></dir><dir name="template"><dir name="cdr"><dir name="ordercomment"><dir><dir name="onepage"><dir name="review"><file name="commentfield.phtml" hash="20baa7497cc46cd800802cf59ef440e2"/></dir></dir><dir name="sales"><dir name="order"><dir name="view"><file name="ordercomment.phtml" hash="5ff233b5996ab70d046c5bbf7c93fc5c"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="cdr"><file name="cdr_ordercomment.xml" hash=""/></dir></dir></dir></dir></dir></target></contents>
22
+ <compatible/>
23
+ <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
24
+ </package>