1

My Magento 1.9 store use 2 kinds of bundle items.

Some items use dynamic pricing which mean the pricing is adding up based on the clients selection.

I also have fixed price bundle, where there is a special pricing for a selection of item ( required items) with possibility to add fixed price add-on (not required options.)

Everything was working perfectly until I started using Onesaas to import transactions into Quickbooks.

Onesaas is only able to import either fixed or dynamic pricing but not both. It will import only options or only fixed price but will not calculate a mix of both correctly.

I could change my fixed price bundles into dynamic with a %discount but i don't want the customer to see the option price on that specific option. But option I need to be able to still see the price to the "not required" option on the same listing.

Long story short is there any way to hide the option pricing on required options while keeping it visible for non-required options within the same listing.

1

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 = '';
    }
}
  • Thank you. I,ll take the time to try this out this week ! – Emili Mar 20 '17 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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