// Fixed stock_available when ordering products

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@14656 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
bMancone
2012-04-16 13:39:15 +00:00
parent 5c6e33b72a
commit 285becae29
4 changed files with 47 additions and 12 deletions
+7 -2
View File
@@ -131,7 +131,7 @@ class OrderDetailCore extends ObjectModel
/** @var float $tax_rate **/
public $tax_rate;
/** @var int Id warehouse */
public $id_warehouse;
@@ -364,8 +364,13 @@ class OrderDetailCore extends ObjectModel
{
if ($id_order_state != Configuration::get('PS_OS_CANCELED') && $id_order_state != Configuration::get('PS_OS_ERROR'))
{
if (StockAvailable::updateQuantity($product['id_product'], $product['id_product_attribute'], -(int)$product['cart_quantity']))
$update_quantity = true;
if (!StockAvailable::dependsOnStock($product['id_product']))
$update_quantity = StockAvailable::updateQuantity($product['id_product'], $product['id_product_attribute'], -(int)$product['cart_quantity']);
if ($update_quantity)
$product['stock_quantity'] -= $product['cart_quantity'];
if ($product['stock_quantity'] < 0 && Configuration::get('PS_STOCK_MANAGEMENT'))
$this->outOfStock = true;
Product::updateDefaultAttribute($product['id_product']);