Dynamicweb 8 Documentation
UpdateStock(Order,OrderStockOperator) Method
Example 

Updates the stock.
Syntax
'Declaration
 
Public Overloads Shared Function UpdateStock( _ 
   ByVal order As Order, _ 
   ByVal operator As Product.OrderStockOperator _ 
) As Integer
public static int UpdateStock( 
   Order order,
   Product.OrderStockOperator operator 
)

Parameters

order
operator

Return Value

The number of products that have had their Stock updated.
Example
class MyPage : System.Web.UI.Page
{
   private void DeleteOrders(string orderID)
   {
       Dynamicweb.eCommerce.Orders.OrderState deletedOrderState = null;

       //Check for a 'Deleted' Order state and use if exists
       Dynamicweb.eCommerce.Orders.OrderStateCollection orderStates = Dynamicweb.eCommerce.Orders.OrderState.getAllOrderstates(false);
       foreach (Dynamicweb.eCommerce.Orders.OrderState orderState in orderStates) {
           if (orderState.IsDeleted) {
               deletedOrderState = orderState;
           }
       }

       Dynamicweb.eCommerce.Orders.Order order = Dynamicweb.eCommerce.Orders.Order.Create(orderID);
       order.Deleted = true;
       order.StateID = deletedOrderState.ID;
       order.Save();

       if (order.Complete)
       {
           Product.UpdateStock(order, Product.OrderStockOperator.Positive);
       }
   }
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

Product Class
Product Members
Overload List

Send Feedback