Dynamicweb 8 Documentation
UpdateUnitCount Method
Example 

The product.
The unit counter.
Updates the unit counter.
Syntax
'Declaration
 
Public Shared Function UpdateUnitCount( _ 
   ByVal product As Product, _ 
   ByVal unitCount As Integer _ 
) As Integer
public static int UpdateUnitCount( 
   Product product,
   int unitCount 
)

Parameters

product
The product.
unitCount
The unit counter.
Example
class MyPage : System.Web.UI.Page
{
   private Product product;
   public void StockForUnits(Product prod)
   {
       if (Request["saveUnit"] == "1")
       {
           AddProdUnit(prod);

           Dynamicweb.eCommerce.Variants.VariantOptionCollection units = Dynamicweb.eCommerce.Variants.VariantOption.getVariantOptions(prod, 1);
           Product.UpdateUnitCount(prod, units.Count);
       }
   }

   private void AddProdUnit(Product prd)
   {
       string reqName = null;
       string reqValue = null;

       if (Base.ChkNumber(prd.Type) == 0)
       {
           Dynamicweb.eCommerce.Stocks.StockUnit su = new Dynamicweb.eCommerce.Stocks.StockUnit();
           su.Delete(prd.ID);

           foreach (string item in Request.Form)
           {
               reqName = item.ToString();
               reqValue = Request[item];

               if (reqName.IndexOf("PRODUNIT_ID") == 0)
               {
                   if (!string.IsNullOrEmpty(reqValue))
                   {
                       su.ProductID = prd.ID;
                       su.VariantID = "";
                       su.UnitID = reqValue;
                       su.Save(product.ID, "", reqValue);
                   }
               }
           }
       }
   }
}
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

Send Feedback