You have to rewrite Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option
to adjust the methods getSelectionQtyTitlePrice()
and getSelectionTitlePrice()
.
I did that once for a similar requirement by adding an event to these methods (and hide the price if it is empty):
class SGH_BundleProductPriceDisplay_Block_Catalog_Product_View_Type_Bundle_Option
extends Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option
{
/**
* (non-PHPdoc)
* @see Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option::
* getSelectionQtyTitlePrice()
*/
public function getSelectionQtyTitlePrice(
$_selection, $includeContainer = true)
{
$price = $this->getProduct()->getPriceModel()
->getSelectionPreFinalPrice($this->getProduct(), $_selection);
// BEGIN Event Injection
Mage::dispatchEvent(
'bundle_format_selection_price_before',
array(
'option_block' => $this,
'selection' => $_selection,
'price_obj' => (object)array('price' => &$price)
)
);
// END Event Injection
$this->setFormatProduct($_selection);
return $_selection->getSelectionQty()*1 . ' x ' .
$_selection->getName() .
$this->_getPriceString($price, $includeContainer);
}
/* (non-PHPdoc)
* @see Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option::
* getSelectionTitlePrice()
*/
public function getSelectionTitlePrice(
$_selection, $includeContainer = true)
{
$price = $this->getProduct()->getPriceModel()
->getSelectionPreFinalPrice($this->getProduct(), $_selection);
// BEGIN Event Injection
Mage::dispatchEvent(
'bundle_format_selection_price_before',
array(
'option_block' => $this,
'selection' => $_selection,
'price_obj' => (object)array('price' => &$price)
)
);
// END Event Injection
$this->setFormatProduct($_selection);
return $_selection->getName() .
$this->_getPriceString($price, $includeContainer);
}
/*
* refactored original class: extract method
*/
protected function _getPriceString($price, $includeContainer)
{
// NEW: no price string if price is empty
if ($price == 0 ) {
return '';
}
// END
return ' ' .
($includeContainer ? '<span class="price-notice">' : '') . '+' .
$this->formatPriceString($price, $includeContainer) .
($includeContainer ? '</span>' : '');
}
}
You'll also have to rewrite all child classes, e.g.
class SGH_BundleProductPriceDisplay_Block_Catalog_Product_View_Type_Bundle_Option_Checkbox
extends SGH_BundleProductPriceDisplay_Block_Catalog_Product_View_Type_Bundle_Option
{
/**
* Set template
*
* @return void
*/
protected function _construct()
{
$this->setTemplate(
'bundle/catalog/product/view/type/bundle/option/checkbox.phtml'
);
}
}
so your config.xml looks like this:
<global>
<blocks>
<bundle>
<rewrite>
<catalog_product_view_type_bundle_option_checkbox>SGH_BundleProductPriceDisplay_Block_Catalog_Product_View_Type_Bundle_Option_Checkbox</catalog_product_view_type_bundle_option_checkbox>
<catalog_product_view_type_bundle_option_multi>SGH_BundleProductPriceDisplay_Block_Catalog_Product_View_Type_Bundle_Option_Multi</catalog_product_view_type_bundle_option_multi>
<catalog_product_view_type_bundle_option_radio>SGH_BundleProductPriceDisplay_Block_Catalog_Product_View_Type_Bundle_Option_Radio</catalog_product_view_type_bundle_option_radio>
<catalog_product_view_type_bundle_option_select>SGH_BundleProductPriceDisplay_Block_Catalog_Product_View_Type_Bundle_Option_Select</catalog_product_view_type_bundle_option_select>
</rewrite>
</bundle>
</blocks>
</global>
Now you can write an observer like this:
public function onBundleFormatSelectionPriceBefore(
Varien_Event_Observer $observer)
{
if ($observer->getOptionBlock()->getOption()->getRequired()) {
$price = $observer->getPriceObj();
$price->price = '';
}
}