1. add new field to the database:
log into phpmyadmin
select the table: catalog_product_option_type_value
click ‘SQL’ and insert
click ‘go’
2. add new column in the admin area
app/design/adminhtml/default/default/template/catalog/product/edit/options/type/select.phtml
after this line:
insert:
after this line:
insert:
3. add the weight to the array
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Option.php
after this line:
insert:
4. add custom weight(s) to the main product when added to the cart
app/code/core/Mage/Sales/Model/Quote/Item.php
BEFORE this line:
insert
change this:
to:
for TEST purpose:
app/design/frontend/default/default/template/checkout/cart/item/default.phtml
after this line:
insert:
if you finished testing delete the inserted line from default.phtml…
log into phpmyadmin
select the table: catalog_product_option_type_value
click ‘SQL’ and insert
ALTER TABLE `catalog_product_option_type_value` ADD `weight` DECIMAL( 12, 2 ) DEFAULT '0.00' AFTER `option_id` ;
app/design/adminhtml/default/default/template/catalog/product/edit/options/type/select.phtml
after this line:
'<th class="type-type"><?php echo Mage::helper('catalog')->__('Price Type') ?></th>'+
'<th class="type-weight"><?php echo Mage::helper('catalog')->__('Weight') ?></th>'+
<td><?php echo $this->getPriceTypeSelectHtml() ?>{{checkboxScopePrice}}</td>+
'<td><input type="text" class="input-text validate-number product-option-weight" id="product_option_{{id}}_select_{{select_id}}_weight" name="product[options][{{id}}][values][{{select_id}}][weight]" value="{{weight}}"></td>'+
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Option.php
after this line:
'price_type' => $_value->getPriceType(),
'weight' => $_value->getWeight(),
app/code/core/Mage/Sales/Model/Quote/Item.php
BEFORE this line:
$this->setData('product', $product)
$optionsWeight = 0;$options = $this->getOptions();
if (is_array($options)) {unset($options[0]);unset($options[1]); $read = Mage::getSingleton('core/resource')->getConnection('core_read');
foreach ($options as $option) {
$temp = $read->fetchRow('SELECT * FROM `catalog_product_option_type_value` WHERE `option_type_id` = '.$option->getValue().' LIMIT 0, 1');
$optionsWeight += $temp['weight'];}
}// $optionsWeight = 0; //if you want to turn off
->setWeight($this->getProduct()->getWeight()
->setWeight($this->getProduct()->getWeight() + $optionsWeight)
app/design/frontend/default/default/template/checkout/cart/item/default.phtml
after this line:
<?php echo $this->getProductName() ?></a>
<strong>Weight: <?php echo $_item->getWeight() ?> RowWeight: <?php echo $_item->getRowWeight() ?></strong>
No comments:
Post a Comment