1

I want to add a custom 'gift wrap' column under 'Items Ordered' so that I can add gift wrapping cost to the subtotal of the product. The page is present at admin panel->sales->orders->create new order->create new customer. The file to this page is present at (app\code\core\Mage\Adminhtml\Block\Sales\Order\Create\Items\Grid.php) Please find the screen shot of what I intend to do. I am unable to do this,please helpbeforeafter

1 Answer 1

3

This is the similar work I am just doing now.

You will need to change/overwrite following file:

design/adminhtml/default/default/template/sales/order/create/items/grid.phtml

Learn how to override template:

Basically you are adding <th> in <thead> and <td> in <tbody> section.

Hope this helps.

Update

In that file

add <col width="80" /> in <col> section.

and change

<thead>
                <tr class="headings">
                    <th class="no-link"><?php echo $this->helper('sales')->__('Product') ?></th>
                    <th class="no-link"><?php echo $this->helper('sales')->__('Price') ?></th>
                    <th class="no-link"><?php echo $this->helper('sales')->__('Qty') ?></th>
                    <th class="no-link"><?php echo $this->helper('sales')->__('Subtotal') ?></th>
                    <th class="no-link"><?php echo $this->helper('sales')->__('Discount') ?></th>
                    <th class="no-link"><?php echo $this->helper('sales')->__('Row Subtotal') ?></th>

                    <th class="no-link last"><?php echo $this->helper('sales')->__('Action') ?></th>
                </tr>
            </thead>

To

         <thead>
            <tr class="headings">
                <th class="no-link"><?php echo $this->helper('sales')->__('Product') ?></th>
                <th class="no-link"><?php echo $this->helper('sales')->__('Price') ?></th>
                <th class="no-link"><?php echo $this->helper('sales')->__('Qty') ?></th>
                <th class="no-link"><?php echo $this->helper('sales')->__('Gift wrap') ?></th>
                <th class="no-link"><?php echo $this->helper('sales')->__('Subtotal') ?></th>
                <th class="no-link"><?php echo $this->helper('sales')->__('Discount') ?></th>
                <th class="no-link"><?php echo $this->helper('sales')->__('Row Subtotal') ?></th>

                <th class="no-link last"><?php echo $this->helper('sales')->__('Action') ?></th>
            </tr>
        </thead>

and change

 <td><input name="item[<?php echo $_item->getId() ?>][qty]" class="input-text item-qty" value="<?php echo $_item->getQty()*1 ?>" maxlength="12" /></td>

to

<td><input name="item[<?php echo $_item->getId() ?>][qty]" class="input-text item-qty" value="<?php echo $_item->getQty()*1 ?>" maxlength="12" /></td>
<td><input name="item[<?php echo $_item->getId() ?>][gift_wrap]" class="input-text item-gift-wrap" value="<?php echo $_item->getGiftWrap() ?>" /></td>

Important

echo $_item->getGiftWrap() is coming from database table sales_flat_quote_item, so you must have a column named gift_wrap.

You can add that column like this (in your setup/sql file)

<?php
$installer = $this;

$installer->startSetup();
$installer->getConnection()
    ->addColumn($installer->getTable('sales_flat_quote_item'),
        'gift_wrap',
        array(
            'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
            'nullable' => true,
            'comment' => 'Gift Wrap'
        )
    );
$installer->endSetup();
5
  • Can u please share the edits in the file when you are done. I need this to be done urgently
    – sharad kr
    Jun 30, 2015 at 2:33
  • My file will not match with your, since I am doing other stuff, but file is same. Also see my updated answer. Jun 30, 2015 at 2:43
  • thanks a ton! I am new to magento,so I may need your further guidance If I am stuck.
    – sharad kr
    Jun 30, 2015 at 2:56
  • should I follow these steps to add column
    – sharad kr
    Jun 30, 2015 at 5:22
  • Yes, but you should add exactly my above code in that setup file. Jun 30, 2015 at 5:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.