【问题标题】:remove quantity box for specific product删除特定产品的数量框
【发布时间】:2017-10-01 17:13:56
【问题描述】:

早上好,我安装了 Magento 版本。 1.9.2.1 我只需要删除部分产品的盒子数量。例如,我在想,当最大数量设置为 1 时,而不是其他产品离开盒子。谢谢,有什么建议吗?

尼古拉

我尝试修改文件 addtochar.phtml 但没有成功。我附上代码 ?>getProduct(); ?> ('加入购物车'); ?> isSaleable()): ?> isGrouped()): ?> __('Qty:') ?> getProductDefaultQty() * 1 ?>" title="quoteEscape($this->('Qty' )) ?>" class="input-text qty" /> " id="product-addtocart-button" class="button btn-cart" onclick="productAddToCartForm.submit(this)"> getChildHtml('', true , true) ?> showButtonDesign(); ?>

【问题讨论】:

    标签: magento


    【解决方案1】:

    我希望这段代码对您有所帮助。

    <div class="add-to-cart">
        <?php if(!$_product->isGrouped()): ?>
        <?php $hiddenFlag = in_array($_product->getId(), array(10,20,30,40)) ? true : false; ?>
        <?php if (!$hiddenFlag): ?>
            <label for="qty"><?php echo $this->__('Qty:') ?></label>
        <?php endif;?>
        <input type="<?php echo $hiddenFlag ? 'hidden' : 'text' ?>" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Qty')) ?>" class="input-text qty" />
        <?php endif; ?>
        <button type="button" title="<?php echo $buttonTitle ?>" id="product-addtocart-button" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><span><?php echo $buttonTitle ?></span></span></button>
        <?php echo $this->getChildHtml('', true, true) ?>
    </div>
    

    请关注此行:<?php $hiddenFlag = in_array($_product->getId(), array(10,20,30,40)) ? true : false; ?> it will check if product eligible for a qty visibility.

    【讨论】:

    • 谢谢,我想知道您是否可以删除由 ID 定义的某些产品的盒子数量。例如,标明 ID 10、11、12、13、20、30 等,并从具有这些 ID 的产品中删除盒子数量。
    猜你喜欢
    • 2021-11-27
    • 2017-01-15
    • 1970-01-01
    • 2019-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-22
    相关资源
    最近更新 更多