Configuring Magento Configurable Products: Displaying Accurate Prices
Building eCommerce sites with Magento CE often involves leveraging configurable products to offer customers multiple variants of a single product. However, one common challenge faced by developers is ensuring that the price displayed in the dropdown matches the actual selected product’s price rather than showing price differences.
In your case, you’re using Magento CE 1.9 and have noticed that the product dropdown displays price changes as ”+ £xx.xx” or ”- £xx.xx”, which can indeed confuse customers. The goal is to either display the exact set price for each option or remove the pricing entirely from the dropdown.
Understanding the Current Behavior
Before diving into solutions, let’s understand why this issue occurs. Magento 1.9 uses JavaScript (specifically js/varien/configurable.js) to dynamically update the selected product options and prices on the frontend. The price displayed in the dropdown is calculated as the difference between the current selected option and the base configurable product.
Option 1: Modifying the Price Calculation
If you want to display the exact set price for each option, you’ll need to modify the price calculation logic. Open js/varien/configurable.js and locate this line around line 200:
priceDelta = newPrice - option.price;
Change it to:
priceDelta = option.price;
This will set the displayed price in the dropdown to the actual selected product’s price, regardless of its relationship to the base configurable product.
Option 2: Removing Pricing from Dropdown
If you prefer to remove all pricing information from the dropdown entirely and only display the product names, you can modify the product.js file. Around line 130, locate this section:
html = '<span class="price-notice">' + priceNotices + '</span>';
Replace it with:
html = '';
This will remove the pricing notice that appears below each option in the dropdown.
Option 3: Customizing via PHP
For a more robust solution, you can create a custom extension to override the product view. In your module’s app/code/local/YourCompany/CustomConfigurable/etc/config.xml, add the following configuration:
<config>
<modules>
<YourCompany_CustomConfigurable>
<version>1.0</version>
</YourCompany_CustomConfigurable>
</modules>
<global>
...
<blocks>
<catalog>
<rewrite>
<product_view_options_abstract>YourCompany_CustomConfigurable_Block_Product_View_Option_Abstract</product_view_options_abstract>
</rewrite>
</catalog>
</blocks>
</global>
</config>
Then, create the custom block app/code/local/YourCompany/CustomConfigurable/Block/Product/View/Option/Abstract.php and modify the `_renderPrice() method to display the desired pricing format.
Conclusion
While Magento’s built-in functionality can be limiting in this regard, with a bit of customization, it is possible to achieve your desired pricing behavior for configurable products. Whether you choose to modify JavaScript files directly or create an extension, understanding the underlying logic and leveraging Magento’s override capabilities will help ensure a seamless user experience for your customers.
Remember that modifying core files should be done cautiously, as upgrades may overwrite your changes. Consider using a custom extension for better maintainability and compatibility with future updates.
For more in-depth guides on Magento development and extensions, feel free to explore our library at Laravel Company.