Magento - 让用户在包含税的排除税之间进行选择

时间:2013-06-27 09:51:28

标签: magento option product configure

我有一个有多种选择的产品。

用户选择他想要为产品支付多少钱。 首先,我创建了一个值为€5, - €10, - 等的下拉框。 我的产品价格为0欧元。

当我选择10欧元时,产品变为10欧元 - 这很好。

现在我想要一个复选框,用户可以选择排除税和包含税,所以如果我选择不含税,产品将被插入购物车,因为€10,00女巫可以(不含税)。 但是当我选择含税时,产品需要插入购物车中,因为10 /1.21 = 8,26欧元(不含税)。

我怎样才能做到这一点?

编辑:

我有以下代码:

$event = $observer->getEvent();
$quote_item = $event->getQuoteItem();

    if (is_array($quote_item->getOptions())) { 
        foreach ($quote_item->getOptions() as $optionValue) { 
            echo ???? . ' --> ' . $optionValue->getValue() . '<br />';
        } 
    } 

这将为我提供选项中的值。 但是我如何获得真正的option_id?我现在得到了option_type_id。

1 个答案:

答案 0 :(得分:0)

如果你看下面的页面     应用程序/设计/前端/默认/默认/模板/目录/产品/ price.phtml

you will find  below code

<?php if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 0)): // including ?>
        <span class="price-excluding-tax">
            <span class="label"><?php echo $_taxHelper->__('Excl. Tax:') ?></span>
            <span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
                <?php echo $_coreHelper->currency($_price+$_weeeTaxAmount,true,false) ?>
            </span>
        </span>
        <span class="price-including-tax">
            <span class="label"><?php echo $_taxHelper->__('Incl. Tax:') ?></span>
            <span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
                <?php echo $_coreHelper->currency($_finalPriceInclTax+$_weeeTaxAmount,true,false) ?>
            </span>
        </span>
    <?php elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 1)): // incl. + weee ?>
        <span class="price-excluding-tax">
            <span class="label"><?php echo $_taxHelper->__('Excl. Tax:') ?></span>
            <span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
                <?php echo $_coreHelper->currency($_price+$_weeeTaxAmount,true,false) ?>
            </span>
        </span>

实现你可以参考

Changing the price in quote while adding product to cart: magento