Hi folks,
I'm doing my own preorder plugin and I want to keep product Out Of Stock but make it available to add to cart.
I know there is option for backorders with product In Stock with quantity 0 - but it's not the case. I want to keep status Out Of Stock and quantity 0.
I want to ignore quantity check when product is added to cart for Out Of Stock items.
Basically when $_product->isSaleable() return false or 0 it shows Place Preorder but it's trigger normal Add to cart quantity check.
I will appreciate any help in this matter!
Hello @connor_ferry
https://github.com/emizentech/magento2-pre-oder
check above module for same
hope it will help you.
For some reasons this plugin doesn't work for me so still trying to find out a way to ignore quantity check during add to cart...
Hello @connor_ferry
One more thing i know if you set
$productInfo->setIsSuperMode(true) ;
then it will skip qty check
more info
https://magento.stackexchange.com/questions/288227/how-to-add-out-of-stock-product-to-cart-programma...hope it will help you.
if works then mark as solution.
Before I've add
$productInfo->setIsSuperMode(true) ;
I'm receiving message:
We can't add this item to your shopping cart right now.
Where exactly to put this $productInfo->setIsSuperMode(true) ;
In my files?
Hello @connor_ferry
Magento\Checkout\Controller\Cart\Add.php
before this add line add
$product->setIsSuperMode(true) ;
$this->cart->addProduct($product, $params);
Hope it will help you.
Hi,
Thanks for quick reply.
So in file /vendor/magento/module-checkout/Controller/Cart/Add.php
I've add to line 111
$product->setIsSuperMode(true) ; $this->cart->addProduct($product, $params); if (!empty($related)) { $this->cart->addProductsByIds(explode(',', $related)); } $this->cart->save();
and now I'm receiving message:
Product that you are trying to add is not available.
What I'm missing?
Maybe another approach - how to disable changing status to Out Of Stock if quantity reach 0 and below?
I think it would be easier ro do