How to prevent PrestaShop from updating the quantity of goods after checking the order

I am new to prestashop and I am trying to create a payment module where I need to duplicate an order for statistical questions. My problem is that the duplicate order is also deducted from the product stock, and I need to know where, after checking the order, updateashop update is important to avoid calling the corresponding function. In a few words, I call validateOrder () twice, but I need StockAvailable to be updated once.

By the way, I looked at the entire validateOrder () function, which is looking for the section / update function, but I could not find it.

The only related code I could find was the following:

// updates stock in shops
    if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'))
    {
        $product_list = $order->getProducts();
        foreach ($product_list as $product)
        {
            // if the available quantities depends on the physical stock
            if (StockAvailable::dependsOnStock($product['product_id']))
            {
                // synchronizes
                StockAvailable::synchronize($product['product_id'], $order->id_shop);
            }
        }
    }

but this only works with advanced inventory management enabled.

Thank.

+4
1

, , OrderDetail::create, OrderDetail::checkProductStock, StockAvailable::updateQuantity

$update_quantity = StockAvailable::updateQuantity(...

,

if (!StockAvailable::dependsOnStock($product['id_product']))

true, .

, , true, .

override/classes/stock/StockAvailable.php

class StockAvailable extends StockAvailableCore 
{

  public static function dependsOnStock($id_product, $id_shop = null)
  {
    $no_quantity_update = isset($GLOBALS['no_quantity_update']) && $GLOBALS['no_quantity_update'];
    if ($no_quantity_update) 
      return true;
    else return parent::dependsOnStock($id_product, $id_shop = null);
  }

}

, cache/class_index.php,

:

//set to false just to be sure
$GLOBALS['no_quantity_update'] = false;
$this->module->validateOrder($cart->id, Configuration...
//set to true to prevent quantity update
$GLOBALS['no_quantity_update'] = true;
$this->module->validateOrder($cart->id, Configuration...

,

+2

All Articles