Page 1 of 1

Products not substracted from stock

Posted: Mon Sep 21, 2015 7:31 pm
by Hare76
In Opencart 1.5.6.4 substracted.
In Opencart 2.0.3.1 not substracted (status order not write to database)

Re: Products not substracted from stock

Posted: Tue Sep 22, 2015 2:00 am
by sirszor
I have similar issue with OC2.0.3.1.
There is a strange issue with product quantity subtraction. If I select ’Process’ in admin-> Extensions-> Payments -> Order status, the quantity decrease when I get an order. It is ok.
But when I update order status to shipped, quantity reset to earlier status. I have tested it more time and I am sure this is existing. Is there any fix or good setting for this? I usually update my orders because I can follow my orders according their status. I would like to update my order status without the system automaticaly increase the product stock.

Re: Products not substracted from stock

Posted: Tue Sep 22, 2015 3:52 am
by sirszor
I guess I found the solution.
I have to select the correct order options in Admin->System->Settings->Option->Processing order status and Complete order status. If you select an ordering option that is not checked in Processing order list, the quantity will set the earlier value.

Re: Products not substracted from stock

Posted: Tue Sep 22, 2015 1:47 pm
by Hare76
Thank Sirszor. It works. I selected some values and products decreased from stock. But I think that it is not logical and it is not intuitive.
Thanks again. I hope that the developers will pay attention to this point.

Re: Products not substracted from stock

Posted: Tue Sep 22, 2015 1:53 pm
by Hare76
In the course of the experiments I found that different variants of choices lead to different results. For example:
"Complete" + "Pending" = "Out of stock"
"Complete" + "Processing" ( or "Processed" ) = "2-3 Days"
Where can I find all possible variants of choices and their results?

Re: Products not substracted from stock

Posted: Sat Sep 26, 2015 4:20 am
by sirszor
Hi, I thing it works logically.
The selected items in in Admin->System->Settings->Option->Processing order status will decrease the stock. The unselected items will reset to original state.
It is same in Complete order status settings, too.
My settings:

Processing status:
1. selected: Paid, Pending, Processing, Shipped, prepared for shipping, waiting for payment, waiting for supply, etc
2. unselected: cancelled, refunded, change, chargeback, failed, done

Complete order status settings:
1. selcted: only the Done
2. Others unselected.

It works for me.

Re: Products not substracted from stock

Posted: Sun Sep 27, 2015 12:43 am
by IP_CAM
It would be easier to understand, how all this works, if, finally, someone up TOP would decide, to
create a complete Owners Manual. It's been just about a Year now (October 1, 2014), since it's first debut... :-\
Very unique..., for something, different to handle, in so much, to it's predecessor.

(just thinking)
Ernie

PS: ...exept for iSense Lab's nice OC2 Info, just to mention it:
https://isenselabs.com/books/getacopy/47

Re: Products not substracted from stock

Posted: Sun Sep 27, 2015 9:08 am
by straightlight
In catalog/model/checkout/order.php file,

find:

Code: Select all

// If order status in the complete range create any vouchers that where in the order need to be made available.
			if (in_array($order_info['order_status_id'], $this->config->get('config_complete_status'))) {
				// Send out any gift voucher mails
				$this->load->model('checkout/voucher');

				$this->model_checkout_voucher->confirm($order_id);
			}
add after:

Code: Select all

if (!empty($order_info['order_id']) && !empty($order_info['order_status_id']) && (int)$order_info['order_status_id'] == (int)$this->config->get('config_complete_status_id')) {
				$order_product_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_product` WHERE `order_id` = '" . (int)$order_info['order_id'] . "' GROUP BY `product_id`");
				
				if ($order_product_query->num_rows) {
					foreach ($order_product_query->rows as $product) {
						$this->db->query("UPDATE `" . DB_PREFIX . "product` SET `quantity` = 'quantity - 1' WHERE `product_id` = '" . (int)$product['product_id'] . "' AND `quantity` > '0'");
					}
				}
			}
This should resolved the problem.

Re: Products not substracted from stock

Posted: Sun Sep 27, 2015 9:13 am
by straightlight
Post edited above.