Jump to content

Problem with updating residues when editing order


Recommended Posts

Hello! I'm use advanced stock management. Version of PrestaShop 1.5.6.1, but the problem was in 1.5.4.1.

 

Found a problem that when you add or remove items from your order does not occur synchronization stock.

 

Problem not solved, but isolated.

 

My diff for controllers/admin/AdminOrdersController.php:

[spam-filter] -1743,6 +1743,14 [spam-filter]
 
  // Get the last product
  $product = end($products);
+        
+        // synchronizes quantities if needed..
+        if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'))
+        {
+            StockAvailable::synchronize($order_detail->product_id, (int)$order_detail->id_shop);
+            $product['current_stock'] = StockAvailable::getQuantityAvailableByProduct($order_detail->product_id, $order_detail->product_attribute_id, (int)$order_detail->id_shop);
+        }
+        
  $resume = OrderSlip::getProductSlipResume((int)$product['id_order_detail']);
  $product['quantity_refundable'] = $product['product_quantity'] - $resume['product_quantity'];
  $product['amount_refundable'] = $product['total_price_tax_incl'] - $resume['amount_tax_incl'];
[spam-filter] -2062,6 +2070,12 [spam-filter]
  // Reinject quantity in stock
  $this->reinjectQuantity($order_detail, $order_detail->product_quantity);
 
+        // synchronizes quantities if needed..
+        if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'))
+        {
+            $product_id = (int)$order_detail->product_id;
+        }
+
  // Delete OrderDetail
  $res &= $order_detail->delete();
  
[spam-filter] -2075,6 +2089,13 [spam-filter]
  $order->weight = sprintf("%.3f ".Configuration::get('PS_WEIGHT_UNIT'), $order_carrier->weight); 
  }
 
+        // synchronizes quantities if needed..
+        if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'))
+        {
+            if (StockAvailable::dependsOnStock($product_id))
+                StockAvailable::synchronize($product_id, (int)$order->id_shop);
+        }
+
  if (!$res)
  die(Tools::jsonEncode(array(
  'result' => $res,
 

Essence of changes: update the stock after adding a product to the order and, after removal of goods from the order.

 

P.S. Sorry for my English. Use translator Google.

 

Для русских тема тут.

Link to comment
Share on other sites

×
×
  • Create New...