<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Magento Coder &#187; Cart</title>
	<atom:link href="http://magentocoder.jigneshpatel.co.in/category/cart/feed/" rel="self" type="application/rss+xml" />
	<link>http://magentocoder.jigneshpatel.co.in</link>
	<description>hacks &#38; solutions for Magento Ecommerce development</description>
	<lastBuildDate>Sun, 19 Jun 2011 16:13:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Magento &#8211; Add custom comment box to each product in Cart</title>
		<link>http://magentocoder.jigneshpatel.co.in/magento-add-comment-box-to-each-product-in-cart/</link>
		<comments>http://magentocoder.jigneshpatel.co.in/magento-add-comment-box-to-each-product-in-cart/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 11:18:57 +0000</pubDate>
		<dc:creator>Jignesh</dc:creator>
				<category><![CDATA[Cart]]></category>

		<guid isPermaLink="false">http://magentocoder.jigneshpatel.co.in/?p=127</guid>
		<description><![CDATA[Are you looking for the solution i.e. customer can provide their inputs or comments along with the products they are going to order. To make it easier, one way is to allow them enter the comments for each individual item they order. On the other hand, admin should be able to view the comment on the order page. Adding a custom comment box for each item in the cart is actually very easy. First lets [...]]]></description>
			<content:encoded><![CDATA[<p>Are you looking for the solution i.e. customer can provide their inputs or comments along with the products they are going to order. To make it easier, one way is to allow them enter the comments for each individual item they order. </p>
<p>On the other hand, admin should be able to view the comment on the order page.</p>
<p>Adding a custom comment box for each item in the cart is actually very easy. First lets add the textarea field for each item.</p>
<p>In your theme, for the file: template/checkout/cart.phtml<br />
Add the new heading along with other heading for cart items.</p>
<pre class="brush: php; title: ;">&lt;th&gt;&lt;?php echo $this-&gt;__('Comments') ?&gt;&lt;/th&gt; </pre>
<p>In the file: template/checkout/cart/item/default.phtml<br />
Add a new column</p>
<pre class="brush: php; title: ;">
            &lt;td class=&quot;a-center&quot;&gt;
            &lt;textarea name=&quot;cart[&lt;?php echo $_item-&gt;getId() ?&gt;][comments]&quot; rows=&quot;3&quot; cols=&quot;20&quot;&gt;&lt;?php echo $_item-&gt;getItemcomment() ?&gt;&lt;/textarea&gt;
            &lt;/td&gt;
</pre>
<p>For Older version of Magento it would be:</p>
<pre class="brush: php; title: ;">
            &lt;td class=&quot;a-center&quot;&gt;
            &lt;textarea name=&quot;cart[&lt;?php echo $_item-&gt;getId() ?&gt;][comments]&quot; rows=&quot;3&quot; cols=&quot;20&quot;&gt;&lt;?php echo $this-&gt;getItemItemcomment($_item) ?&gt;&lt;/textarea&gt;
            &lt;/td&gt;
</pre>
<p>Doing upto this. shoul show the text area added </p>
<p><a href="http://magentocoder.jigneshpatel.co.in/wp-content/uploads/2010/08/CommentBoxAddedOnCartPage.png"><img src="http://magentocoder.jigneshpatel.co.in/wp-content/uploads/2010/08/CommentBoxAddedOnCartPage.png" alt="" title="CommentBoxAddedOnCartPage" width="531" height="278" class="alignnone size-full wp-image-140" /></a></p>
<p>The next step is to save the comment in DB, when customer update the cart.</p>
<p>So add a new field &#8216;itemcomment&#8217; in the tabel &#8216;sales_flat_quote_item&#8217;. (For older version of Magento the table would be &#8216;sales_quote_item&#8217;)</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:<br />
app/code/core/Mage/Checkout/Model/Cart.php (Note: If you are planning to upgrade your Magento setup, copy this file to local &#038; 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 class="brush: php; title: ;">
    public function updateItems($data)
    {
        Mage::dispatchEvent('checkout_cart_update_items_before', array('cart'=&gt;$this, 'info'=&gt;$data));

        foreach ($data as $itemId =&gt; $itemInfo) {

            $item = $this-&gt;getQuote()-&gt;getItemById($itemId);
            if (!$item) {
                continue;
            }

            if (!empty($itemInfo['remove']) || (isset($itemInfo['qty']) &amp;&amp; $itemInfo['qty']=='0')) {
                $this-&gt;removeItem($itemId);
                continue;
            }

            $qty = isset($itemInfo['qty']) ? (float) $itemInfo['qty'] : false;
            if ($qty &gt; 0) {
                $item-&gt;setQty($qty);
            }

        /* Start: Custom code added for comments */
        if(!empty($itemInfo['comments'])) {

        	$write = Mage::getSingleton('core/resource')-&gt;getConnection('core_write');

        	# make the frame_queue active
      		$query = &quot;UPDATE `sales_flat_quote_item` SET itemcomment = '&quot;.$itemInfo['comments'].&quot;' where item_id = $itemId&quot;;
			$write-&gt;query($query);

        	$item-&gt;setItemcomment($itemInfo['comments']);
        }
        /* End: Custom code added for comments */

        }

        Mage::dispatchEvent('checkout_cart_update_items_after', array('cart'=&gt;$this, 'info'=&gt;$data));
        return $this;
    }
</pre>
<p>Showing the comment in Admin -> View Order</p>
<p>Add a new function getItemcomment() to the file below:<br />
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.<br />
app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Items.php</p>
<pre class="brush: php; title: ;">

	public function getItemcomment($item) {
		$itemId = $item-&gt;getId();

		$write = Mage::getSingleton('core/resource')-&gt;getConnection('core_write');

    	$query = &quot;SELECT q.* FROM `sales_flat_order_item` o
	    LEFT JOIN `sales_flat_quote_item` q on o.quote_item_id = q.item_id
	    WHERE o.item_id = $itemId&quot;;

		# For older versions of Magento
/*	    $query = &quot;SELECT q.* FROM `sales_order_entity_int` o
	    LEFT JOIN `sales_flat_quote_item` q on o.value = q.entity_id
	    WHERE o.entity_id = $itemId AND o.attribute_id = 343&quot;;       */	    

		$res = $write-&gt;query($query);

		while ($row = $res-&gt;fetch() ) {
			if(key_exists('itemcomment',$row)) {
				echo nl2br($row['itemcomment']);
			}
		}
	}    
</pre>
<p>To add the comments column to the items edit the .phtml file below:<br />
app/design/adminhtml/default/default/template/sales/order/view/items.phtml</p>
<p>Adding header for items to make it look like below:</p>
<pre class="brush: php; title: ;">
.
.
&lt;tr class=&quot;headings&quot;&gt;
    &lt;th&gt;&lt;?php echo $this-&gt;helper('sales')-&gt;__('Product') ?&gt;&lt;/th&gt;
    &lt;th&gt;&lt;?php echo $this-&gt;helper('sales')-&gt;__('Comments') ?&gt;&lt;/th&gt;
    &lt;th&gt;&lt;?php echo $this-&gt;helper('sales')-&gt;__('Item Status') ?&gt;&lt;/th&gt;
.
.
.
</pre>
<p>Adding Column with comments. app/design/adminhtml/default/default/template/sales/order/view/items/renderer/default.phtml<br />
Add a column for item comments juts before status columns to make it look a like below.</p>
<pre class="brush: php; title: ;">
.
.
&lt;td&gt;&lt;?php echo $this-&gt;getItemcomment($_item) ?&gt;&lt;/td&gt; &lt;!-- New column added for item comments --&gt;
&lt;td class=&quot;a-center&quot;&gt;&lt;?php echo $_item-&gt;getStatus() ?&gt;&lt;/td&gt;
.
.
</pre>
<p>Doing upto this will show the comments column in the item table. It should look like image below.</p>
<p><a href="http://magentocoder.jigneshpatel.co.in/wp-content/uploads/2010/08/Items-Ordered-Admin.png"><img src="http://magentocoder.jigneshpatel.co.in/wp-content/uploads/2010/08/Items-Ordered-Admin.png" alt="" title="Items-Ordered-Admin" width="352" height="296" class="alignnone size-full wp-image-165" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://magentocoder.jigneshpatel.co.in/magento-add-comment-box-to-each-product-in-cart/feed/</wfw:commentRss>
		<slash:comments>34</slash:comments>
		</item>
		<item>
		<title>Magento 1.4.1 &#8211; Onepage checkout Paypal WPP bug</title>
		<link>http://magentocoder.jigneshpatel.co.in/magento-1-4-1-onepage-checkout-paypal-wpp-bug/</link>
		<comments>http://magentocoder.jigneshpatel.co.in/magento-1-4-1-onepage-checkout-paypal-wpp-bug/#comments</comments>
		<pubDate>Sun, 01 Aug 2010 07:09:26 +0000</pubDate>
		<dc:creator>Jignesh</dc:creator>
				<category><![CDATA[Cart]]></category>
		<category><![CDATA[Checkout]]></category>

		<guid isPermaLink="false">http://magentocoder.jigneshpatel.co.in/?p=112</guid>
		<description><![CDATA[Magento 1.4.1 having some issues, when using Paypal WPP payment method. It does not work properly when you press Continue even after you have put the card details correctly. As a solution, I replaced the version of file below from Magento 1.4.0 to Magento 1.4.1 js/prototype/validation.js Also disabled the Centinel Validation by commenting the line below in file : app/code/core/Mage/Payment/Model/Method/Cc.php this-&#62;getCentinelValidator()-&#62;validate($this-&#62;getCentinelValidationData());]]></description>
			<content:encoded><![CDATA[<p>Magento 1.4.1 having some issues, when using Paypal WPP payment method. It does not work properly when you press Continue even after you have put the card details correctly.</p>
<p>As a solution, I replaced the version of file below from Magento 1.4.0 to Magento 1.4.1</p>
<p><code>js/prototype/validation.js</code></p>
<p>Also disabled the Centinel Validation by commenting the line below in file : app/code/core/Mage/Payment/Model/Method/Cc.php</p>
<pre class="brush: php; title: ;">
this-&gt;getCentinelValidator()-&gt;validate($this-&gt;getCentinelValidationData());
</pre>
]]></content:encoded>
			<wfw:commentRss>http://magentocoder.jigneshpatel.co.in/magento-1-4-1-onepage-checkout-paypal-wpp-bug/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Add to Cart with custom attributes &amp; values</title>
		<link>http://magentocoder.jigneshpatel.co.in/add-to-cart-with-custom-attributes-values/</link>
		<comments>http://magentocoder.jigneshpatel.co.in/add-to-cart-with-custom-attributes-values/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 06:02:23 +0000</pubDate>
		<dc:creator>Jignesh</dc:creator>
				<category><![CDATA[Cart]]></category>

		<guid isPermaLink="false">http://magentocoder.jigneshpatel.co.in/?p=74</guid>
		<description><![CDATA[I want to display the custom price on the Shopping Cart page. By default if you add to cart the product it will take the price &#038; will show that price on the cart page. The data on the cart page is coming from the table &#8216;sales_flat_quote_item&#8217;. This table is having lot many fields. Some of them are product_id, name, description, qty, price. Those are the fields which basically reflects on the cart page. My [...]]]></description>
			<content:encoded><![CDATA[<p>I want to display the custom price on the Shopping Cart page. By default if you add to cart the product it will take the price &#038; will show that price on the cart page. </p>
<p>The data on the cart page is coming from the table &#8216;sales_flat_quote_item&#8217;. This table is having lot many fields. Some of them are product_id, name, description, qty, price. Those are the fields which basically reflects on the cart page. </p>
<p>My task was to display the custom image, custom price, custom description in the row of a product on the cart page.</p>
<p>So first of all we need to insert those values in the DB, while adding the product to the cart.</p>
<p>The phase of adding the product to cart is bit complicated to understand.</p>
<p>These are list of some functions involved in Add to cart phase.</p>
<p>app/code/core/Mage/Checkout/controllers/CartController.php: addAction()<br />
app/code/core/Mage/Checkout/Model/Cart.php: addProduct($product, $info)<br />
app/code/core/Mage/Sales/Model/Quote.php: addProduct(Mage_Catalog_Model_Product $product, $request=null)</p>
<p>In the above function, you can set the custom values for the product.</p>
<p>Find the for loop:<br />
foreach ($cartCandidates as $candidate) { &#8230; }<br />
Inside that custom fields can be set.</p>
<pre class="brush:php">

foreach ($cartCandidates as $candidate) {
            $item = $this->_addCatalogProduct($candidate, $candidate->getCartQty());
            ...
            ...
            ...
            $item->setCustomPrice('custom value goes here');
            $item->setCustomImage('custom value goes here');
            ...
            ...
}
</pre>
<p>I want the custom image as well. So I have added the one more field in the table &#8216;sales_flat_quote_item&#8217;.</p>
<p>Getting those custom values on the cart page is very easy. Go to template/checkout/cart/item/default.phtml.<br />
The below lines can get those values.</p>
<pre class="brush:php">
echo $_item->getCustomImage();
</pre>
<p>The price on the cart page will replaced automatically by custom_price value if that has been set.</p>
]]></content:encoded>
			<wfw:commentRss>http://magentocoder.jigneshpatel.co.in/add-to-cart-with-custom-attributes-values/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>

