Modx rev minishop2: edit event listener

I need to change the logic behavior when adding an item to the cart, I found it in the file mscarthandler.class.php such lines:

$response = $this->ms2->invokeEvent('msOnBeforeAddToCart', [
            'product' => $product,
            'count' => $count,
            'options' => $options,
            'cart' => $this,
        ]);
        if (!($response['success'])) {
            return $this->error($response['message']);
        }

An event is triggered here, and if the count in warehouse is 0, then an error will occur – I need to change this logic, my product has an additional field with count in another warehouse and I want to account for this count.

In the files core/cache/context_setting/{mgr, web}/conext.cache.php I found a string:

28 => 
    array (
      'id' => '28',
      'source' => '1',
      'property_preprocess' => '0',
      'name' => 'order',
      'description' => '',
      'editor_type' => '0',
      'category' => '0',
      'cache_type' => '0', 
      'plugincode' => 'switch($modx->event->name) {
    case \'msOnBeforeAddToCart\':
        if($product->get(\'in_stock\') <= 0) {
            $modx->event->output(\'Товар отсутствует на складе, заказ в данный момент недоступен\');
        }
        break;
}',
      'locked' => '0',
      'properties' => 'a:0:{}',
      'disabled' => '0',
      'moduleguid' => '',
      'static' => '0',
      'static_file' => '',
    ),

And where exactly the msOnBeforeAddToCart event handler is defined, I don’t understand. Where can I find the definition of the msOnBeforeAddToCart event and how can I change it?

I don’t know anything about minishop, but the code that responds to the event would normally be in a plugin – probably in the minishop category. You can confirm that it’s the right plugin by editing it and looking at the “Events” tab. You should see the msOnBeforeAddToCart event checked (and possibly other events as well).