1

我正在寻找一种从结帐购物车中删除项目选项值的方法,只需删除如下突出显示的文本: 在此处输入图像描述

我相信这位于文件 app/design/frontend/base/default/template/checkout/cart/item/default.phtml 作为“item-option”

<?php if ($_options = $this->getOptionList()):?>
        <dl class="item-options">
            <?php foreach ($_options as $_option) : ?>
            <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
            <dt><?php echo $this->htmlEscape($_option['label']) ?></dt>
            <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated"<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
                <?php if (isset($_formatedOptionValue['full_view'])): ?>
                <div class="truncated_full_value">
                    <dl class="item-options">
                        <dt><?php echo $this->htmlEscape($_option['label']) ?></dt>
                        <dd><?php echo $_formatedOptionValue['full_view'] ?></dd>
                    </dl>
                </div>
                <?php endif; ?>
            </dd>
            <?php endforeach; ?>
        </dl>
        <?php endif;?>

谢谢您的帮助

4

2 回答 2

3

要解决此问题,您必须覆盖 *Mage_Bundle_Helper_Catalog_Product_Configuration* 类。

在您的本地池中创建一个新的Mage文件夹,其中包含帮助程序的相应子文件夹

/---app
|   /---code
|       /---local
|           /---Mage
|               /---Bundle
|                   /---Helper
|                       /---Catalog
|                           /---Product
|                               /---Configuration.php

复制帮助程序并编辑方法 getBundleOptions。您必须在 $option['value'] 中删除此代码

Mage::helper('core')->currency($this->getSelectionFinalPrice($item, bundleSelection)

获得这种新方法

   public function getBundleOptions(Mage_Catalog_Model_Product_Configuration_Item_Interface $item)
    {
        $options = array();
        $product = $item->getProduct();

        /**
         * @var Mage_Bundle_Model_Product_Type
         */
        $typeInstance = $product->getTypeInstance(true);

        // get bundle options
        $optionsQuoteItemOption = $item->getOptionByCode('bundle_option_ids');
        $bundleOptionsIds = $optionsQuoteItemOption ? unserialize($optionsQuoteItemOption->getValue()) : array();
        if ($bundleOptionsIds) {
            /**
            * @var Mage_Bundle_Model_Mysql4_Option_Collection
            */
            $optionsCollection = $typeInstance->getOptionsByIds($bundleOptionsIds, $product);

            // get and add bundle selections collection
            $selectionsQuoteItemOption = $item->getOptionByCode('bundle_selection_ids');

            $selectionsCollection = $typeInstance->getSelectionsByIds(
                unserialize($selectionsQuoteItemOption->getValue()),
                $product
            );

            $bundleOptions = $optionsCollection->appendSelections($selectionsCollection, true);
            foreach ($bundleOptions as $bundleOption) {
                if ($bundleOption->getSelections()) {
                    $option = array(
                        'label' => $bundleOption->getTitle(),
                        'value' => array()
                    );

                    $bundleSelections = $bundleOption->getSelections();

                    foreach ($bundleSelections as $bundleSelection) {
                        $qty = $this->getSelectionQty($product, $bundleSelection->getSelectionId()) * 1;
                        if ($qty) {
                            $option['value'][] = $qty . ' x ' . $this->escapeHtml($bundleSelection->getName());

                        }
                    }

                    if ($option['value']) {
                        $options[] = $option;
                    }
                }
            }
        }

        return $options;
    } 
于 2013-04-16T10:40:06.603 回答
0

您也可以通过纯 css 实现相同的结果。在您的 css 中尝试以下代码以删除捆绑产品项目的价格。

.item-options dd span.price{ display:none; }

于 2013-04-23T05:05:56.300 回答