// When viewing an order, a warning is now displayed if one/some product(s) are out of stock - #PSTEST-821

This commit is contained in:
bMancone
2012-04-23 08:26:10 +00:00
parent c7be89d916
commit 10680a43cf
2 changed files with 12 additions and 0 deletions
@@ -1205,9 +1205,20 @@ class AdminOrdersControllerCore extends AdminController
$payment_methods[] = $module->displayName;
}
// display warning if there are products out of stock
$display_out_of_stock_warning = false;
$current_order_state = $order->getCurrentOrderState();
if ($current_order_state->delivery != 1 && $current_order_state->shipped != 1)
$display_out_of_stock_warning = true;
// products current stock (from stock_available)
foreach ($products as &$product)
{
$product['current_stock'] = StockAvailable::getQuantityAvailableByProduct($product['product_id'], $product['product_attribute_id'], $product['id_shop']);
// if the current stock requires a warning
if ($product['current_stock'] == 0 && $display_out_of_stock_warning)
$this->displayWarning($this->l('This product is out of stock: ').' '.$product['product_name']);
}
// Smarty assign
$this->tpl_view_vars = array(