【问题标题】:restrict some quantity for adding to cart限制一些添加到购物车的数量
【发布时间】:2016-05-06 20:32:51
【问题描述】:

我们需要“预购/延期交货”功能[用户可以购买缺货产品]

所以我们编写了自定义模块。如果我们设置值,它是如何工作的

"" 为预购属性,它会允许预购,

对于“NO”,它不会在视图页面中显示“预购”按钮。

但问题是用户可以输入任意数量的数量并添加到购物车中。

我们需要的是我们在后端输入的数量,只有它应该允许将那么多数量添加到购物车。

<?php $_collectionSize = $_productCollection->count() ?>
    <?php $_columnCount = $this->getColumnCount(); ?>
    <?php $i=0; foreach ($_productCollection as $_product): ?>
        <?php if ($i++%$_columnCount==0): ?>
        <ul class="products-grid">
        <?php endif ?>
            <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">

                <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h2>

                <?php echo $this->getPriceHtml($_product, true) ?>
                <div class="actions">
                    <?php if($_product->isSaleable()): ?>
                        <?php if($_product->getPreOrder()): ?>
                        <button type="button" title="<?php echo $this->__('Pre-Order') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Pre-Order') ?></span></span></button>

                        <?php endif; ?>
                    <?php else: ?>
                        <p class="availability out-of-stock"><span><?php echo $this->__('') ?></span></p>
                    <?php endif; ?>

                </div>
            </li>
        <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
        </ul>
        <?php endif ?>
        <?php endforeach ?>
        <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
    <?php endif; ?>

完整代码:http://pasted.co/8c8e0763

【问题讨论】:

    标签: magento


    【解决方案1】:

    添加产品时,您需要在库存部分设置购物车中允许的最大数量,如屏幕截图所示。

    link

    【讨论】:

    • 但是我们对不同的产品有不同的数量。
    • 针对个别产品。
    猜你喜欢
    • 2014-12-17
    • 2018-09-20
    • 2014-03-23
    • 2016-02-28
    • 1970-01-01
    • 2021-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多