Add custom field for all products for order line

How to add custom fields for Order Line Items in magento

 

 

Work Flow to add custom Field to Order line Item
Use this url to add to cart: Ex: http://magento.com/checkout/cart/add/?product=196&qty=2&training_location=California
1. checkout_cart_item_default.phtml:::
Add the following below product name
<dl class=”item-options Kiran” id=”checkout_cart_item_default”>
<dt>Training Location</dt>
<dd><?php echo $_item->getTrainingLocation(); ?></dd>
</dl>
2. Table: sales_flat_quote_item
Add field: training_location
3. Product Detailed Page: Add training_location text field as input
4. Code -> Core -> Mage -> Sales -> Model -> Quote.php
Find: public function addItem(Mage_Sales_Model_Quote_Item $item)
Add: $item->setTrainingLocation($_REQUEST[‘training_location’]);
Befoe: $item->setQuote($this);
—————
5. Table: sales_flat_order_item
Add field: training_location
6. XML: code_core_mage_sales_etc_config.xml
ADD: <training_location><to_order_item>*</to_order_item></training_location>
Between: <sales_convert_quote_item> and </sales_convert_quote_item>
Also Add:
<training_location><to_quote_item>*</to_quote_item><to_invoice_item>*</to_invoice_item><to_shipment_item>*</to_shipment_item><to_cm_item>*</to_
cm_item></training_location>
Between: <sales_convert_order_item> and </sales_convert_order_item>
—— Show The Info In Various Locations ——
To show in admin orders area
7. app_design_adminHTML_default_default_template_sales_order_view_items_renderer_default.phtml
Add:
<?php if($_item->getTrainingLocation()): ?>
<?php echo “<strong>Training Location:</strong> “.$_item->getTrainingLocation(); ?>
<?php endif; ?>
Below: <?php echo $this->getColumnHtml($_item, ‘name’) ?>
8. To Show in Checkout/Order review Page
frontend_template_checkout_onepage_review_item.phtml
Add: <?php if ($_item->getTrainingLocation()):?>
<dl class=”item-options Kiran” id=”checkout_cart_item_default”>
<dt>Training Location</dt>
<dd><?php echo $_item->getTrainingLocation(); ?></dd>
</dl>
<?php endif; ?>
Below: <h3 class=”product-name”><?php echo $this->htmlEscape($this->getProductName()) ?></h3>
9. To show in Myorders view page
frontend_template_sales_order_items_renderer_default.phtml
Add: <?php if ($_item->getTrainingLocation()):?>
<dl class=”item-options Kiran” id=”checkout_cart_item_default”>
<dt>Training Location</dt>
<dd><?php echo $_item->getTrainingLocation(); ?></dd>
</dl>
<?php endif; ?>
Below: <h3 class=”product-name”><?php echo $this->htmlEscape($_item->getName()) ?></h3>
10.
######################################
Usefull Links:
http://www.magentocommerce.com/boards/viewthread/19344/
http://magentocoder.jigneshpatel.co.in/add-to-cart-with-custom-attributes-values/
Use like below in product view page
<input type=”text”title=”Qty” value=”My Test Location” maxlength=”12″ id=”training_location” name=”training_location”>

Magento configrable product get child product by super attribute php code

Magento set phtml template in cntroller with block

Magento create block from controller php code


this code write in your controller you have to no write in xml layout

How to add custom fields for Order Line Items in magento

magento index rewright url create

hello this script for create your module rewrite URL, create script

Magento 2 Singleton Design Pattern

  Magento 2 Singleton Design Pattern In the realm of Magento 2 development, mastering design patterns is paramount, and one of the cornersto...

Popular Posts

Posts