Magento remove Incl Tax from configurable dropdown

喜夏-厌秋 提交于 2020-01-25 08:33:07

问题


I am using configurable products and I have set the option in the backend of Magento to show prices Incl TAX and Excl Tax.

My problem is that with this inside the dropdown for the configurable products options it also shows both Incl TAX and Excl TAX.

I need it to show both options in the price area on the product page but only Excl Tax in the dropdown so it removes the Incl TAX I have attahced a screenshot the areas in red need to be removed.


回答1:


I've had some external help with this and come up with a solution. This is based on Magento 1.5.1.0.

Locate the file configurable.phtml in app/design/frontend/default/YOURTEMPLATE/template/catalog/product/view/type/options/.

Replace this:

<script type="text/javascript">
    var spConfig = new Product.Config(<?php echo $this->getJsonConfig(); ?>);
</script>

With this:

<?php
// get current drop down string
$currentstring = $this->getJsonConfig();

// create new string with true set to false using str_replace function (string replace)
$newstring = str_replace( '"showBothPrices":true,"', '"showBothPrices":false,"', $currentstring );

?>
<!-- render dropdown but with new var ($newstring) -->
<script type="text/javascript">
    var spConfig = new Product.Config(<?php echo $newstring ?>);
</script>

This will only work for configurable products. If you want to do the same thing for custom options of simple products just change this:

<?php echo $this->getValuesHtml() ?>

For this:

<?php echo preg_replace("/\([^)]+\)/","", $this->getValuesHtml()); ?>

In this file: app/design/frontend/default/YOURTEMPLATE/template/catalog/product/view/options/type/select.phtml

Hope this helps



来源:https://stackoverflow.com/questions/11205223/magento-remove-incl-tax-from-configurable-dropdown

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!