Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In your theme, for the file: template/checkout/cart.phtml Add the new heading along with other heading for cart items.</p> <pre><code>1 &lt;th&gt;&lt;?php echo $this-&gt;__('Comments') ?&gt;&lt;/th&gt; In the file: template/checkout/cart/item/default.phtml </code></pre> <p>Add a new column</p> <pre><code>1 &lt;td class="a-center"&gt; 2 &lt;textarea name="cart[&lt;?php echo $_item-&gt;getId() ?&gt;][comments]" rows="3" cols="20"&gt;&lt;?php echo $_item-&gt;getItemcomment() ?&gt;&lt;/textarea&gt; 3 &lt;/td&gt; </code></pre> <p>For Older version of Magento it would be:</p> <pre><code>1 &lt;td class="a-center"&gt; 2 &lt;textarea name="cart[&lt;?php echo $_item-&gt;getId() ?&gt;][comments]" rows="3" cols="20"&gt;&lt;?php echo $this-&gt;getItemItemcomment($_item) ?&gt;&lt;/textarea&gt; 3 &lt;/td&gt; </code></pre> <p>The next step is to save the comment in DB, when customer update the cart.</p> <p>So add a new field ‘itemcomment’ in the tabel ‘sales_flat_quote_item’. (For older version of Magento the table would be ‘sales_quote_item’)</p> <p>Now we are going to add the code which will do the DB operation. For this we will need to modify the file: app/code/core/Mage/Checkout/Model/Cart.php (Note: If you are planning to upgrade your Magento setup, copy this file to local &amp; modify.)</p> <p>Here we need to add some code to the function updateItems(), such a way that the function should now look like below:</p> <pre><code>01 public function updateItems($data) 02 { 03 Mage::dispatchEvent('checkout_cart_update_items_before', array('cart'=&gt;$this, 'info'=&gt;$data)); 04 05 foreach ($data as $itemId =&gt; $itemInfo) { 06 07 $item = $this-&gt;getQuote()-&gt;getItemById($itemId); 08 if (!$item) { 09 continue; 10 } 11 12 if (!empty($itemInfo['remove']) || (isset($itemInfo['qty']) &amp;&amp; $itemInfo['qty']=='0')) { 13 $this-&gt;removeItem($itemId); 14 continue; 15 } 16 17 $qty = isset($itemInfo['qty']) ? (float) $itemInfo['qty'] : false; 18 if ($qty &gt; 0) { 19 $item-&gt;setQty($qty); 20 } 21 22 /* Start: Custom code added for comments */ 23 if(!empty($itemInfo['comments'])) { 24 25 $write = Mage::getSingleton('core/resource')-&gt;getConnection('core_write'); 26 27 # make the frame_queue active 28 $query = "UPDATE `sales_flat_quote_item` SET itemcomment = '".$itemInfo['comments']."' where item_id = $itemId"; 29 $write-&gt;query($query); 30 31 $item-&gt;setItemcomment($itemInfo['comments']); 32 } 33 /* End: Custom code added for comments */ 34 35 } 36 37 Mage::dispatchEvent('checkout_cart_update_items_after', array('cart'=&gt;$this, 'info'=&gt;$data)); 38 return $this; 39 } </code></pre> <p>Showing the comment in Admin -> View Order</p> <p>Add a new function getItemcomment() to the file below: app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Items.php</p> <p>If you are on verstion 1.5 or later.. add it to the file below. app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Items.php</p> <pre><code>01 public function getItemcomment($item) { 02 $itemId = $item-&gt;getId(); 03 04 $write = Mage::getSingleton('core/resource')-&gt;getConnection('core_write'); 05 06 $query = "SELECT q.* FROM `sales_flat_order_item` o 07 LEFT JOIN `sales_flat_quote_item` q on o.quote_item_id = q.item_id 08 WHERE o.item_id = $itemId"; 09 10 # For older versions of Magento 11 /* $query = "SELECT q.* FROM `sales_order_entity_int` o 12 LEFT JOIN `sales_flat_quote_item` q on o.value = q.entity_id 13 WHERE o.entity_id = $itemId AND o.attribute_id = 343"; */ 14 15 $res = $write-&gt;query($query); 16 17 while ($row = $res-&gt;fetch() ) { 18 if(key_exists('itemcomment',$row)) { 19 echo nl2br($row['itemcomment']); 20 } 21 } 22 } To add the comments column to the items edit the .phtml file below: app/design/adminhtml/default/default/template/sales/order/view/items.phtml Adding header for items to make it look like below: 1 . 2 . 3 &lt;tr class="headings"&gt; 4 &lt;th&gt;&lt;?php echo $this-&gt;helper('sales')-&gt;__('Product') ?&gt;&lt;/th&gt; 5 &lt;th&gt;&lt;?php echo $this-&gt;helper('sales')-&gt;__('Comments') ?&gt;&lt;/th&gt; 6 &lt;th&gt;&lt;?php echo $this-&gt;helper('sales')-&gt;__('Item Status') ?&gt;&lt;/th&gt; 7 . 8 . 9 . Adding Column with comments. app/design/adminhtml/default/default/template/sales/order/view/items/renderer/default.phtml Add a column for item comments juts before status columns to make it look a like below. view sourceprint? 1 . 2 . 3 &lt;td&gt;&lt;?php echo $this-&gt;getItemcomment($_item) ?&gt;&lt;/td&gt; &lt;!-- New column added for item comments --&gt; 4 &lt;td class="a-center"&gt;&lt;?php echo $_item-&gt;getStatus() ?&gt;&lt;/td&gt; 5 . 6 . </code></pre> <p>Doing upto this will show the comments column in the item table. This will add a text box with the name as comments(change the name ASAP).Hope this helps. Note:This will add a box only if the item is added to cart and as you said the price doesn't change I think this would be more appropriate.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload