限制一些添加到购物车的数量 [英] restrict some quantity for adding to cart
问题描述
我们需要预购/延期订购"功能[用户可以购买缺货的产品]
we needed "pre-order/Back order" feature [ user can buy out-of-stock Products ]
所以我们写了定制模块.它是如何工作的,如果我们设置值
so we wrote custom module. how it works is , if we set value
"是"作为预订属性,它将允许预订,
"yes" to pre order attribute, it will allow for pre-order,
对于"否",它不会在视图页面中显示预定"按钮.
for "NO", it will not show "Pre order" button in view page.
但问题是用户可以输入任意数量的数量&添加到购物车项目.
but problem is user can enter any number of quantity & add to cart items.
我们需要的是我们在后端输入的数量,只有它可以允许大量的数量添加到购物车中.
what we need is what quantity we enter in backend, only it should allow that much quantity to add-to-cart.
<?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
推荐答案
添加产品时,您需要在库存部分中设置购物车中允许的最大数量,如屏幕截图所示.
You need to set maximum qty allowed in shopping cart in inventory section when adding products as shown in screen shot.
这篇关于限制一些添加到购物车的数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!