【问题标题】:Removing price from item-options in magento checkout cart从 magento 结帐购物车中的项目选项中删除价格
【发布时间】:2013-04-07 15:52:40
【问题描述】:

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

我相信这位于文件 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;?>

感谢您的帮助

【问题讨论】:

标签: php css magento shopping-cart


【解决方案1】:

要解决此问题,您必须重写 *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;
    } 

【讨论】:

    【解决方案2】:

    你也可以通过纯 css 达到同样的效果。尝试在您的 css 中使用以下代码来删除捆绑产品的价格。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-20
      • 2019-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多