Return Stock when Order Canceled ?
I have set a product to 3 pieces and made an order from the shop for 3 i recieved the order through admin then i cancelled the order from there checked the product quantiy its zero so the order for the whole quantity was 3 cancelled order no stock back doesn't the default should be restoring the quantity back as it was if orders cancelled?
i even deleted the whole order after cancellation still quantity zero and at the shop it shows out of stock.....
any suggestions to solve this??
I have set a product to 3 pieces and made an order from the shop for 3 i recieved the order through admin then i cancelled the order from there checked the product quantiy its zero so the order for the whole quantity was 3 cancelled order no stock back doesn't the default should be restoring the quantity back as it was if orders cancelled?
i even deleted the whole order after cancellation still quantity zero and at the shop it shows out of stock.....
any suggestions to solve this??
Used our FREE search?OpenM wrote:any suggestions to solve this??
Norman in 't Veldt
Moderator OpenCart Forums
_________________ READ and Search BEFORE POSTING _________________
Our FREE search: Find your answer FAST!.
[How to] BTW + Verzend + betaal setup.
This is normal behavior of OpenCart (although I wish it wasn't).
I agree that when you cancel an order then it should replace the stock that was taken out. It should also subtract the amount from your total sales figures as well. As of now it doesn't do either. Not sure if it ever will. I don't think there is an extension for it yet.
I agree that when you cancel an order then it should replace the stock that was taken out. It should also subtract the amount from your total sales figures as well. As of now it doesn't do either. Not sure if it ever will. I don't think there is an extension for it yet.
I do not know if this is a bug or some implementation that Daniel has not yet activated, but the solution is (But it only works if the order is deleted):
in admin/model/sale/order.php find
replace with:
in admin/model/sale/order.php find
Code: Select all
public function deleteOrder($order_id) {
if ($this->config->get('config_stock_subtract')) {
$order_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order` WHERE order_status_id > '0' AND order_id = '" . (int)$order_id . "'");
if ($order_query->num_rows) {
$product_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");
foreach($product_query->rows as $product) {
$this->db->query("UPDATE `" . DB_PREFIX . "product` SET quantity = (quantity + " . (int)$product['quantity'] . ") WHERE product_id = '" . (int)$product['product_id'] . "'");
$option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int)$order_id . "' AND order_product_id = '" . (int)$product['order_product_id'] . "'");
foreach ($option_query->rows as $option) {
$this->db->query("UPDATE " . DB_PREFIX . "product_option_value SET quantity = (quantity + " . (int)$product['quantity'] . ") WHERE product_option_value_id = '" . (int)$option['product_option_value_id'] . "' AND subtract = '1'");
}
}
}
}
$this->db->query("DELETE FROM `" . DB_PREFIX . "order` WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "order_history WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "order_download WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "order_total WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "customer_transaction WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "customer_reward WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "affiliate_transaction WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "coupon_history WHERE order_id = '" . (int)$order_id . "'");
}
Code: Select all
public function deleteOrder($order_id) {
$order_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order` WHERE order_status_id > '0' AND order_id = '" . (int)$order_id . "'");
if ($order_query->num_rows) {
$product_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");
foreach($product_query->rows as $product) {
$result = $this->db->query("SELECT subtract FROM " . DB_PREFIX . "product WHERE product_id = '" . (int)$product['product_id'] . "'");
if($result->row['subtract']){
$this->db->query("UPDATE `" . DB_PREFIX . "product` SET quantity = (quantity + " . (int)$product['quantity'] . ") WHERE product_id = '" . (int)$product['product_id'] . "'");
$option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int)$order_id . "' AND order_product_id = '" . (int)$product['order_product_id'] . "'");
foreach ($option_query->rows as $option) {
$this->db->query("UPDATE " . DB_PREFIX . "product_option_value SET quantity = (quantity + " . (int)$product['quantity'] . ") WHERE product_option_value_id = '" . (int)$option['product_option_value_id'] . "' AND subtract = '1'");
}
}
}
}
$this->db->query("DELETE FROM `" . DB_PREFIX . "order` WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "order_history WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "order_download WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "order_total WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "customer_transaction WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "customer_reward WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "affiliate_transaction WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "coupon_history WHERE order_id = '" . (int)$order_id . "'");
}
Has there been any attempt to fix this? I think stock should be updated on order status change as well, and as there are different product options with a stock number, it might get complicated to do so...
mine does not have this code to replace ? please help
V15.2.1
V15.2.1
Automotive Lighting upgrades
http://www.BriteLightLEDs.co.uk
Only when an order is deleted items will return to stock.
This is by design.
This is by design.
Norman in 't Veldt
Moderator OpenCart Forums
_________________ READ and Search BEFORE POSTING _________________
Our FREE search: Find your answer FAST!.
[How to] BTW + Verzend + betaal setup.
I am using 1.5.6 OC.i2Paq wrote:Only when an order is deleted items will return to stock.
This is by design.
I don't find there is an status of "Delete".
Please advice.
It is not a status: you must delete the order.garywinner wrote:I am using 1.5.6 OC.i2Paq wrote:Only when an order is deleted items will return to stock.
This is by design.
I don't find there is an status of "Delete".
Please advice.
Norman in 't Veldt
Moderator OpenCart Forums
_________________ READ and Search BEFORE POSTING _________________
Our FREE search: Find your answer FAST!.
[How to] BTW + Verzend + betaal setup.
You are right
Deleting the order makes things work. Tho it is not the best way.
Thankyou so much
Deleting the order makes things work. Tho it is not the best way.
Thankyou so much
i2Paq wrote:It is not a status: you must delete the order.garywinner wrote:I am using 1.5.6 OC.i2Paq wrote:Only when an order is deleted items will return to stock.
This is by design.
I don't find there is an status of "Delete".
Please advice.
By design or no, I for one (several it would seem) do find it helpful to have records of customers who order, then cancel....during processing. It's a way for me to easily see if a customer has ordered and canceled in the past. IMO, stock should be allowed to be zeroed out and leave an empty order.
Who is online
Users browsing this forum: No registered users and 12 guests