Merge pull request #562 from axometeam/patch-14

[*] BO : Do not increment stock if statut change fom Error to Canceled
This commit is contained in:
Gregory Roussac
2013-07-12 07:22:50 -07:00
+7 -3
View File
@@ -161,6 +161,9 @@ class OrderHistoryCore extends ObjectModel
$manager = null;
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'))
$manager = StockManagerFactory::getManager();
$errorOrCanceledStatuses = array(Configuration::get('PS_OS_ERROR'), Configuration::get('PS_OS_CANCELED'));
// foreach products of the order
if (Validate::isLoadedObject($old_os))
foreach ($order->getProductsDetail() as $product)
@@ -171,7 +174,7 @@ class OrderHistoryCore extends ObjectModel
ProductSale::addProductSale($product['product_id'], $product['product_quantity']);
// @since 1.5.0 - Stock Management
if (!Pack::isPack($product['product_id']) &&
($old_os->id == Configuration::get('PS_OS_ERROR') || $old_os->id == Configuration::get('PS_OS_CANCELED')) &&
in_array($old_os->id, $errorOrCanceledStatuses) &&
!StockAvailable::dependsOnStock($product['id_product'], (int)$order->id_shop))
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], -(int)$product['product_quantity'], $order->id_shop);
}
@@ -182,13 +185,14 @@ class OrderHistoryCore extends ObjectModel
// @since 1.5.0 - Stock Management
if (!Pack::isPack($product['product_id']) &&
($new_os->id == Configuration::get('PS_OS_ERROR') || $new_os->id == Configuration::get('PS_OS_CANCELED')) &&
in_array($new_os->id, $errorOrCanceledStatuses) &&
!StockAvailable::dependsOnStock($product['id_product']))
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], (int)$product['product_quantity'], $order->id_shop);
}
// if waiting for payment => payment error/canceled
elseif (!$new_os->logable && !$old_os->logable &&
($new_os->id == Configuration::get('PS_OS_ERROR') || $new_os->id == Configuration::get('PS_OS_CANCELED')) &&
in_array($new_os->id, $errorOrCanceledStatuses) &&
!in_array($old_os->id, $errorOrCanceledStatuses) &&
!StockAvailable::dependsOnStock($product['id_product']))
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], (int)$product['product_quantity'], $order->id_shop);
// @since 1.5.0 : if the order is being shipped and this products uses the advanced stock management :