Jump to content

Control to check if a customer order more than in stock


jacksfregio

Recommended Posts

Hi,
 
my website allow backorder, but I want to add (I think in Cartcontroller.php) a control to check if a customer order more than in stock of a product and warn it of the delay.
 
At this time, if someone write directly the product quantity in the box and click to Add to Cart button, no message appears, and order proceed. Only in the e-mail thereis notification about the delay.
 
I wrote this override, but it does not work:
class CartController extends CartControllerCore
{
    $warning_qty = 0;
    $prod_qty = StockAvailable::getQuantityAvailableByProduct($this->id_product);
    
    // Check product quantity availability
        if ( $prod_qty < $qty_to_check ) {
             $warning_qty =   Tools::displayErrors('There isn\'t enough product in stock.', !Tools::getValue('ajax'));
            
            }
        
        
                
}

Thanks for the help

Edited by jacksfregio (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...