Team23_OrderComment - Version 1.0.0

Version Notes

First stable release.

Download this release

Release Info

Developer David Danier
Extension Team23_OrderComment
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Team23/OrderComment/Block/Checkout/Comment.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Team23_OrderComment
5
+ *
6
+ * @category Team23
7
+ * @package Team23_OrderComment
8
+ * @version 1.0.0
9
+ * @copyright 2014 Team23 GmbH & Co. KG (http://www.team23.de)
10
+ * @license http://opensource.org/licenses/MIT The MIT License (MIT)
11
+ */
12
+
13
+
14
+ class Team23_OrderComment_Block_Checkout_Comment extends Mage_Core_Block_Template
15
+ {
16
+
17
+ /**
18
+ * Get label text for comment field
19
+ *
20
+ * @return string
21
+ */
22
+ public function getLabelText()
23
+ {
24
+ return $this->_getHelper()->__('Customer notice');
25
+ }
26
+
27
+ /**
28
+ * Get field id
29
+ *
30
+ * @return string
31
+ */
32
+ public function getCommentFieldId()
33
+ {
34
+ return Team23_OrderComment_Model_Observer::COMMENT_FIELD_ID;
35
+ }
36
+
37
+ /**
38
+ * Get module helper class
39
+ *
40
+ * @return Team23_OrderComment_Helper_Data
41
+ */
42
+ protected function _getHelper()
43
+ {
44
+ $helper = Mage::helper('ordercomment');
45
+
46
+ return $helper;
47
+ }
48
+ }
app/code/community/Team23/OrderComment/Helper/Data.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Team23_OrderComment
5
+ *
6
+ * @category Team23
7
+ * @package Team23_OrderComment
8
+ * @version 1.0.0
9
+ * @copyright 2014 Team23 GmbH & Co. KG (http://www.team23.de)
10
+ * @license http://opensource.org/licenses/MIT The MIT License (MIT)
11
+ */
12
+
13
+
14
+ class Team23_OrderComment_Helper_Data extends Mage_Core_Helper_Abstract
15
+ {
16
+
17
+ }
app/code/community/Team23/OrderComment/Model/Observer.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Team23_OrderComment
5
+ *
6
+ * @category Team23
7
+ * @package Team23_OrderComment
8
+ * @version 1.0.0
9
+ * @copyright 2014 Team23 GmbH & Co. KG (http://www.team23.de)
10
+ * @license http://opensource.org/licenses/MIT The MIT License (MIT)
11
+ */
12
+
13
+
14
+ class Team23_OrderComment_Model_Observer
15
+ {
16
+
17
+ const COMMENT_FIELD_ID = 'customer_order_comment';
18
+
19
+ /**
20
+ * Check if customer notice should be added to order.
21
+ *
22
+ * @param Varien_Event_Observer $observer
23
+ * @return $this
24
+ */
25
+ public function addCustomerCommentToOrder(Varien_Event_Observer $observer)
26
+ {
27
+ /** @var Mage_Sales_Model_Order $order */
28
+ $order = $observer->getEvent()->getOrder();
29
+
30
+ /** @var Mage_Core_Controller_Request_Http $request */
31
+ $request = Mage::app()->getRequest();
32
+
33
+ if (!is_object($order) || !$request)
34
+ return $this;
35
+
36
+ $comment = strip_tags($request->getParam(self::COMMENT_FIELD_ID));
37
+
38
+ if (!empty($comment))
39
+ $this->_addCustomerCommentToOrder($order, $comment);
40
+
41
+ return $this;
42
+ }
43
+
44
+ /**
45
+ * Add customer notice to order.
46
+ *
47
+ * @param Mage_Sales_Model_Order $order
48
+ * @param string $comment
49
+ * @return $this
50
+ */
51
+ protected function _addCustomerCommentToOrder($order, $comment)
52
+ {
53
+ $value = '<strong>' . Mage::helper('ordercomment')->__('Customer notice') . '</strong><br/>' . $comment;
54
+
55
+ $order->setCustomerNote($value);
56
+
57
+ return $this;
58
+ }
59
+ }
app/code/community/Team23/OrderComment/etc/config.xml ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <!--
4
+ /**
5
+ * Team23_OrderComment
6
+ *
7
+ * @category Team23
8
+ * @package Team23_OrderComment
9
+ * @version 1.0.0
10
+ * @copyright 2014 Team23 GmbH & Co. KG (http://www.team23.de)
11
+ * @license http://opensource.org/licenses/MIT The MIT License (MIT)
12
+ */
13
+ -->
14
+
15
+ <config>
16
+ <modules>
17
+ <Team23_OrderComment>
18
+ <version>1.0.0</version>
19
+ </Team23_OrderComment>
20
+ </modules>
21
+
22
+ <global>
23
+ <models>
24
+ <ordercomment>
25
+ <class>Team23_OrderComment_Model</class>
26
+ </ordercomment>
27
+ </models>
28
+
29
+ <blocks>
30
+ <ordercomment>
31
+ <class>Team23_OrderComment_Block</class>
32
+ </ordercomment>
33
+ </blocks>
34
+
35
+ <helpers>
36
+ <ordercomment>
37
+ <class>Team23_OrderComment_Helper</class>
38
+ </ordercomment>
39
+ </helpers>
40
+ </global>
41
+
42
+ <frontend>
43
+ <events>
44
+ <checkout_type_onepage_save_order>
45
+ <observers>
46
+ <ordercomment>
47
+ <type>singleton</type>
48
+ <class>ordercomment/observer</class>
49
+ <method>addCustomerCommentToOrder</method>
50
+ </ordercomment>
51
+ </observers>
52
+ </checkout_type_onepage_save_order>
53
+ </events>
54
+
55
+ <layout>
56
+ <updates>
57
+ <ordercomment>
58
+ <file>ordercomment.xml</file>
59
+ </ordercomment>
60
+ </updates>
61
+ </layout>
62
+
63
+ <translate>
64
+ <modules>
65
+ <Team23_OrderComment>
66
+ <files>
67
+ <default>Team23_OrderComment.csv</default>
68
+ </files>
69
+ </Team23_OrderComment>
70
+ </modules>
71
+ </translate>
72
+ </frontend>
73
+ </config>
app/design/frontend/base/default/layout/ordercomment.xml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <!--
4
+ /**
5
+ * Team23_OrderComment
6
+ *
7
+ * @category Team23
8
+ * @package Team23_OrderComment
9
+ * @version 1.0.0
10
+ * @copyright 2014 Team23 GmbH & Co. KG (http://www.team23.de)
11
+ * @license http://opensource.org/licenses/MIT The MIT License (MIT)
12
+ */
13
+ -->
14
+
15
+ <layout version="0.1.0">
16
+ <checkout_onepage_index>
17
+ <reference name="head">
18
+ <action method="addCss">
19
+ <stylesheet>css/team23/ordercomment.css</stylesheet>
20
+ </action>
21
+ </reference>
22
+
23
+ <reference name="checkout.onepage.review">
24
+ <action method="setTemplate">
25
+ <template>ordercomment/checkout/onepage/review.phtml</template>
26
+ </action>
27
+ </reference>
28
+ </checkout_onepage_index>
29
+
30
+ <checkout_onepage_review>
31
+ <setTemplate>
32
+
33
+ </setTemplate>
34
+ <reference name="checkout.onepage.review.info.items.before">
35
+ <block type="ordercomment/checkout_comment" name="order.comment" as="ordercomment" before="-"
36
+ template="ordercomment/checkout/onepage/comment.phtml"/>
37
+ </reference>
38
+ </checkout_onepage_review>
39
+ </layout>
app/design/frontend/base/default/template/ordercomment/checkout/onepage/comment.phtml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Team23_OrderComment
5
+ *
6
+ * @category Team23
7
+ * @package Team23_OrderComment
8
+ * @version 1.0.0
9
+ * @copyright 2014 Team23 GmbH & Co. KG (http://www.team23.de)
10
+ * @license http://opensource.org/licenses/MIT The MIT License (MIT)
11
+ */
12
+
13
+ ?>
14
+
15
+ <?php
16
+
17
+ /** @var Team23_OrderComment_Block_Checkout_Comment $this */
18
+ /** @var Team23_OrderComment_Helper_Data $_helper */
19
+ $_helper = Mage::helper('ordercomment');
20
+
21
+ ?>
22
+
23
+ <form id="co-customer-notice" action="">
24
+ <div class="customer-notice">
25
+ <div class="field customer-notice">
26
+ <label for="<?php print $this->getCommentFieldId(); ?>"><?php print $_helper->__('Customer notice'); ?></label>
27
+ <textarea id="<?php print $this->getCommentFieldId(); ?>" name="<?php print $this->getCommentFieldId(); ?>"></textarea>
28
+ </div>
29
+ </div>
30
+ </form>
app/design/frontend/base/default/template/ordercomment/checkout/onepage/review.phtml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Team23_OrderComment
5
+ *
6
+ * @category Team23
7
+ * @package Team23_OrderComment
8
+ * @version 1.0.0
9
+ * @copyright 2014 Team23 GmbH & Co. KG (http://www.team23.de)
10
+ * @license http://opensource.org/licenses/MIT The MIT License (MIT)
11
+ */
12
+
13
+ ?>
14
+
15
+ <script type="text/javascript" src="<?php print $this->getSkinUrl('js/team23/ordercomment.js') ?>"></script>
16
+
17
+ <div class="order-review" id="checkout-review-load">
18
+ <!-- Content loaded dynamically -->
19
+ </div>
app/etc/modules/Team23_OrderComment.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <!--
4
+ /**
5
+ * Team23_OrderComment
6
+ *
7
+ * @category Team23
8
+ * @package Team23_OrderComment
9
+ * @version 1.0.0
10
+ * @copyright 2014 Team23 GmbH & Co. KG (http://www.team23.de)
11
+ * @license http://opensource.org/licenses/MIT The MIT License (MIT)
12
+ */
13
+ -->
14
+
15
+ <config>
16
+ <modules>
17
+ <Team23_OrderComment>
18
+ <active>true</active>
19
+ <codePool>community</codePool>
20
+ <depends/>
21
+ </Team23_OrderComment>
22
+ </modules>
23
+ </config>
app/locale/de_DE/Team23_OrderComment.csv ADDED
@@ -0,0 +1 @@
 
1
+ "Customer notice","Bestellkommentar"
app/locale/en_US/Team23_OrderComment.csv ADDED
@@ -0,0 +1 @@
 
1
+ "Customer notice","Order comment"
package.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Team23_OrderComment</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/mit-license.php">MITL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>This extension allows your customers to add their comment or question to orders on checkout review page.</summary>
10
+ <description>&lt;p&gt;Team23 Customer Order Comment allows your customers to add their &lt;strong&gt;comment or question&lt;/strong&gt;before submitting any order. This extension adds a comment box to the last step in the checkout process. After the order has been placed, the comment will be added as customer notice and viewable in the order review page in Magento backend.&lt;/p&gt;&#xD;
11
+ &lt;h2&gt;Features&lt;/h2&gt;&#xD;
12
+ &lt;ul&gt;&lt;li&gt;Add comment box to the last step in checkout process&lt;/li&gt;&lt;li&gt;Comments were added as customer notice&lt;/li&gt;&lt;li&gt;Light and easy to use&lt;/li&gt;&lt;/ul&gt;&#xD;
13
+ &lt;h2&gt;Notes&lt;/h2&gt;&#xD;
14
+ &lt;p&gt;This module is tested with basic theme and OnePageCheckout.&lt;/p&gt;&#xD;
15
+ &lt;h2&gt;License&lt;/h2&gt;&#xD;
16
+ &lt;p&gt;This module is licensed under the &lt;a href="http://opensource.org/licenses/MIT"&gt;MIT license&lt;/a&gt;.&lt;/p&gt;</description>
17
+ <notes>First stable release.</notes>
18
+ <authors><author><name>Marc Rochow</name><user>team23</user><email>info@team23.de</email></author></authors>
19
+ <date>2014-04-04</date>
20
+ <time>16:13:04</time>
21
+ <contents><target name="magecommunity"><dir name="Team23"><dir name="OrderComment"><dir name="Block"><dir name="Checkout"><file name="Comment.php" hash="dc969f07ec43faafadd5a9f124b6fcac"/></dir></dir><dir name="Helper"><file name="Data.php" hash="b11fc5e99a335f05b29dc86999bf26b0"/></dir><dir name="Model"><file name="Observer.php" hash="2407e8707df5cdb0ebc9e319f14fc5aa"/></dir><dir name="etc"><file name="config.xml" hash="f3ca83cde166b3c96ce6dd4ed2d4f419"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="ordercomment.xml" hash="efd55f39ef6dc2ef99ba35badd7ceaae"/></dir><dir name="template"><dir name="ordercomment"><dir name="checkout"><dir name="onepage"><file name="comment.phtml" hash="a023a33bc3f5d5239cc43fdad5932e45"/><file name="review.phtml" hash="4c61f10662f834b544892cb1b3cc65cf"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Team23_OrderComment.xml" hash="c10dba9ec1a46dd5f238932ff4e08976"/></dir></target><target name="magelocale"><dir name="de_DE"><file name="Team23_OrderComment.csv" hash="b3996ba0fec8b80ac1722fca6485d4b6"/></dir><dir name="en_US"><file name="Team23_OrderComment.csv" hash="e57a01ecfeade9d7678fcba14c7ee02b"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="team23"><file name="ordercomment.css" hash="5ae6fbf59b4557357ec2319b5480d5aa"/></dir></dir><dir name="js"><dir name="team23"><file name="ordercomment.js" hash="e2e043182e6a574017a1abcfee27f3e6"/></dir></dir></dir></dir></dir></target></contents>
22
+ <compatible/>
23
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name>Magento_Core_Modules</name><channel>community</channel><min>1.6.0.0</min><max>1.8.1.0</max></package></required></dependencies>
24
+ </package>
skin/frontend/base/default/css/team23/ordercomment.css ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Team23_OrderComment
3
+ *
4
+ * @category Team23
5
+ * @package Team23_OrderComment
6
+ * @version 1.0.0
7
+ * @copyright 2014 Team23 GmbH & Co. KG (http://www.team23.de)
8
+ * @license http://opensource.org/licenses/MIT The MIT License (MIT)
9
+ */
10
+
11
+ .customer-notice.field {
12
+ border: 1px solid #d9dde3;
13
+ border-width: 0 1px;
14
+ padding: 10px 30px;
15
+ }
16
+
17
+ .customer-notice.field > label {
18
+ font-weight: bold;
19
+ color: #666;
20
+ display: block;
21
+ margin-bottom: 6px;
22
+ }
23
+
24
+ .customer-notice.field > textarea {
25
+ width: 98%;
26
+ min-height: 80px;
27
+ }
skin/frontend/base/default/js/team23/ordercomment.js ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Team23_OrderComment
3
+ *
4
+ * @category Team23
5
+ * @package Team23_OrderComment
6
+ * @version 1.0.0
7
+ * @copyright 2014 Team23 GmbH & Co. KG (http://www.team23.de)
8
+ * @license http://opensource.org/licenses/MIT The MIT License (MIT)
9
+ */
10
+
11
+
12
+ /**
13
+ * Override default review save method to append customer order comment
14
+ */
15
+ Review.addMethods({
16
+ save: function() {
17
+ if (checkout.loadWaiting!=false)
18
+ return;
19
+
20
+ var customerNoticeForm = $('co-customer-notice');
21
+ var customerNoticeParams = Form.serialize(customerNoticeForm);
22
+
23
+ checkout.setLoadWaiting('review');
24
+
25
+ var params = Form.serialize(payment.form);
26
+
27
+ if (this.agreementsForm)
28
+ params += '&'+Form.serialize(this.agreementsForm);
29
+
30
+ if (customerNoticeParams)
31
+ params += '&'+customerNoticeParams;
32
+
33
+ params.save = true;
34
+
35
+ var request = new Ajax.Request(
36
+ this.saveUrl,
37
+ {
38
+ method:'post',
39
+ parameters:params,
40
+ onComplete: this.onComplete,
41
+ onSuccess: this.onSave,
42
+ onFailure: checkout.ajaxFailure.bind(checkout)
43
+ }
44
+ );
45
+ }
46
+ });