Post by kylelnsn » Thu May 03, 2012 5:27 am

There seems to be an issue where if you create and order manually in the backend then when you set the order to complete the stock quantity does not decrease?

New member

Posts

Joined
Mon Apr 09, 2012 9:52 pm

Post by inactiveaccount9912 » Fri May 04, 2012 12:54 am

Its not actually an issue, the orders created via admin dont have the substract stock feature yet. maybe it will be added in the next release.

Expert Member

Posts

Joined
Fri May 14, 2010 2:36 am

Post by straightlight » Fri May 04, 2012 7:08 am

In admin/model/sale/order.php file,

find twice:

Code: Select all

$order_product_id = $this->db->getLastId();
add after both:

Code: Select all

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

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by lDouglas » Thu Dec 06, 2012 9:49 pm

firstly sorry for my horrible english :\ .

I put this code on my store and solve my problem partially.

Code: Select all

$this->db->query("UPDATE `" . DB_PREFIX . "product` SET `quantity` = (quantity - " . (int)$order_product['quantity'] . ") WHERE `product_id` = '" . (int)$order_product_id . "' AND `quantity` > '0'");
when i create the order the quantity does not decrease, but when i delete an order created ,the quantity of product increases

maybe i put this code in wrong place ?

Code: Select all

$order_product_id = $this->db->getLastId();
				$this->db->query("UPDATE `" . DB_PREFIX . "product` SET `quantity` = (quantity - " . (int)$order_product['quantity'] . ") WHERE `product_id` = '" . (int)$order_product_id . "' AND `quantity` > '0'"); 
				if (isset($order_product['order_option'])) {
					foreach ($order_product['order_option'] as $order_option) {
						$this->db->query("INSERT INTO " . DB_PREFIX . "order_option SET order_id = '" . (int)$order_id . "', order_product_id = '" . (int)$order_product_id . "', product_option_id = '" . (int)$order_option['product_option_id'] . "', product_option_value_id = '" . (int)$order_option['product_option_value_id'] . "', name = '" . $this->db->escape($order_option['name']) . "', `value` = '" . $this->db->escape($order_option['value']) . "', `type` = '" . $this->db->escape($order_option['type']) . "'");
					}
				}
Thanks for helping, and sorry again for my english :/

Newbie

Posts

Joined
Thu Dec 06, 2012 9:18 pm

Post by KollanH » Sat Dec 08, 2012 11:23 am

This code

Code: Select all

$order_product_id = $this->db->getLastId();
Is located in your file twice. Once on line 173 and another time on line 278 (OpenCart 1.5.4) At both these locations you have to add

Code: Select all

$this->db->query("UPDATE `" . DB_PREFIX . "product` SET `quantity` = (quantity - " . (int)$order_product['quantity'] . ") WHERE `product_id` = '" . (int)$order_product_id . "' AND `quantity` > '0'"); 
in the other location as well.

The problem you are having is easily solved if you put the code in the right place..

Hope this helps!

Donate | Confirm Email when registering or during guest checkout | Print Order Information


New member

Posts

Joined
Fri Dec 07, 2012 6:19 am

Post by Pamella » Tue Mar 05, 2013 4:55 am

florinsith wrote:Its not actually an issue, the orders created via admin dont have the substract stock feature yet. maybe it will be added in the next release.
Fixed ;-) including option(s) support... with v1.5.5.1 is not ?

OC 3.0.3.7 EN (default theme) running on PHP 7.3 MariaDB 10.3 Linux / Apache 2.4


New member

Posts

Joined
Tue Oct 25, 2011 4:22 am

Post by fume711 » Tue Aug 06, 2013 12:01 pm

in case people are still looking for the answer like i was:

solution with mod files in thread here:
http://forum.opencart.com/viewtopic.php ... der+delete

New member

Posts

Joined
Tue Oct 06, 2009 2:15 pm
Who is online

Users browsing this forum: No registered users and 58 guests