0

How to set certain number when the product page loads up. Default level when you click on a product the add to basket quarry is always one how to change that to different value for each store. I know we can put the value in phtml but we can always change it to one if we enter lower number

I want to add a check of customer change the new value e.g from 2 to 1 I want a error to be shown

I was planning to override list.phtml

Magento 2 I am after

4 Answers 4

0

You haven't said what Magento version

Something like this should work with Magento 1

https://www.magespider.com/how-to-add-quantity-box-on-product-list-page-in-magento/

<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
<?php $product_id=$_product->getId() ?>
<?php $base_url=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);?>
<label for="qty"><?php echo $this->__('Qty:') ?></label>
<input type="text" name="qty" id="<?php echo $product_id ?>" maxlength="12" value="1" title="<?php echo $this->__('Qty') ?>" class="input-text qty"></input>
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onClick="addToCart('<?php echo $product_id ?>','<?php echo $base_url?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
<script type="text/javascript">
function addToCart(pid,purl)
{
    var qty=document.getElementById(pid).value;
    var action=purl+"checkout/cart/add/product/"+pid+"/qty/"+qty;
    window.location=action;
}
</script>
1
  • Hi. Thank you for that and I am after magento 2 I want to create a module. I know we can change it from admin area by changing product stock option but still I can change the value Commented May 22, 2019 at 20:51
0

Just thought of another answer which involves no programming.

You could create a group product and assign a single product to that group.

Like this product. This is Magento 2. But Magento 1 works the same.

https://magento.nublue.co.uk/set-of-sprite-yoga-straps.html

But with just one

3
  • This product page shows 0 as the starting qty I want to change it to 2 and if customer try to lower it to 1 give a error message Commented May 22, 2019 at 20:52
  • There is this on the cart magento.stackexchange.com/q/148398/70343 Commented May 22, 2019 at 20:54
  • That’s for all store I have 7 stores and I am just trying to add it for 1 of them that’s why I was planning to create a module but not 100 percent sure if it’s a good idea Commented May 22, 2019 at 20:57
0

enter image description here

So the current value is 0. I want to change it to 2 or higher, incase if someone (customer) put it 1 don’t allow them to add to basket

0

Okay so I believe this is what you want

  • Edit a simple product
  • Click Advanced Inventory
  • Change 'Minimum Qty Allowed in Shopping Cart' option
8
  • I want to edit any product. On my stores I have simple and configurable product so I want to set the starting qty value to be 2 and if customer try to put 1 as the value give an error Commented May 22, 2019 at 20:59
  • If for a specific store scope you will have to change to that store Commented May 22, 2019 at 21:00
  • Still not showing the error, when I do it through admin and I wasn’t aware if I could do it by store scope Commented May 22, 2019 at 21:06
  • Have you got inventory management turned off? Commented May 22, 2019 at 21:12
  • How do I check this and I have checked now I can’t change the minimum qty allowed in shopping cart option in scope store Commented May 22, 2019 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.