In which .php file does the "subtract stock" happens after a successful order?

Viewed 147

I am using Opencart v.2.1.0.2 and I am trying to find the .php file where the "subtract stock" happens after a successful order.

Can anyone please help?

Thank you!

1 Answers

You can look for it in \catalog\model\checkout\order.php

The update of product quantity

$this->db->query("UPDATE " . DB_PREFIX . "product SET quantity = (quantity - " . (int)$order_product['quantity'] . ") WHERE product_id = '" . (int)$order_product['product_id'] . "' AND subtract = '1'");

The update of product options quantity

$this->db->query("UPDATE " . DB_PREFIX . "product_option_value SET quantity = (quantity - " . (int)$order_product['quantity'] . ") WHERE product_option_value_id = '" . (int)$option['product_option_value_id'] . "' AND subtract = '1'");

Although there are restock querys, if the order is cancelled.

Related