[*] BO : Not increment stock if statut change fom Error to Canceled
Not increment stock if statut change fom Error => Canceled or Canceled => Error (stock should stay the same). Add a code simplification too
This commit is contained in:
1 parent
0928efb112
commit
1c960da57a
1 file changed
+7
-3
@@ -161,6 +161,9 @@ class OrderHistoryCore extends ObjectModel
|
|||||||
$manager = null;
|
$manager = null;
|
||||||
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'))
|
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'))
|
||||||
$manager = StockManagerFactory::getManager();
|
$manager = StockManagerFactory::getManager();
|
||||||
|
|
||||||
|
$errorOrCanceledStatuses = array(Configuration::get('PS_OS_ERROR'), Configuration::get('PS_OS_CANCELED'));
|
||||||
|
|
||||||
// foreach products of the order
|
// foreach products of the order
|
||||||
if (Validate::isLoadedObject($old_os))
|
if (Validate::isLoadedObject($old_os))
|
||||||
foreach ($order->getProductsDetail() as $product)
|
foreach ($order->getProductsDetail() as $product)
|
||||||
@@ -171,7 +174,7 @@ class OrderHistoryCore extends ObjectModel
|
|||||||
ProductSale::addProductSale($product['product_id'], $product['product_quantity']);
|
ProductSale::addProductSale($product['product_id'], $product['product_quantity']);
|
||||||
// @since 1.5.0 - Stock Management
|
// @since 1.5.0 - Stock Management
|
||||||
if (!Pack::isPack($product['product_id']) &&
|
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::dependsOnStock($product['id_product'], (int)$order->id_shop))
|
||||||
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], -(int)$product['product_quantity'], $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
|
// @since 1.5.0 - Stock Management
|
||||||
if (!Pack::isPack($product['product_id']) &&
|
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::dependsOnStock($product['id_product']))
|
||||||
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], (int)$product['product_quantity'], $order->id_shop);
|
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], (int)$product['product_quantity'], $order->id_shop);
|
||||||
}
|
}
|
||||||
// if waiting for payment => payment error/canceled
|
// if waiting for payment => payment error/canceled
|
||||||
elseif (!$new_os->logable && !$old_os->logable &&
|
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::dependsOnStock($product['id_product']))
|
||||||
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], (int)$product['product_quantity'], $order->id_shop);
|
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 :
|
// @since 1.5.0 : if the order is being shipped and this products uses the advanced stock management :
|
||||||
|
|||||||
Reference in new issue
Block a user