Hi Zentreon,
Please see responses below.
1) I presume you are adjusting stock quantities within administration rather than by purchasing products. Currently when an order is successfully placed the stock quantity is adjusted. If you have set a low stock activity has been set (i.e. disable button) and the new stock quantity is less than or equal to the min stock quantity, then the DisableBuyButton is set to true.
If you are modifying the product variant details within administration and explicitly setting a low stock quantity, then you may as well uncheck the Disable Buy Button checkbox or unpublish the product variant manually (since you have to edit the record to change the quantity anyway).
However, if you would like to do this automatically (depending on your low stock activity selection) you can add the following code to line 210 of administration/ProductVariantDetails.aspx.cs (just below the line "LowStockActivityEnum lowStockActivity = ...."):
bool productVariantPublished = cbPublished.Checked;
bool productVariantDisableBuyButton = cbDisableBuyButton.Checked;
if (txtMinStockQuantity.Value >= txtStockQuantity.Value)
{
switch (lowStockActivity)
{
case LowStockActivityEnum.DisableBuyButton:
productVariantDisableBuyButton = true;
break;
case LowStockActivityEnum.Unpublish:
productVariantPublished = false;
break;
default:
break;
}
}
You then need to change your ProductManager.UpdateProductVariant method call below to:
productVariant = ProductManager.UpdateProductVariant(ProductVariantID, productVariant.ProductID,
txtName.Text, txtSKU.Text, txtDescription.Value, txtAdminComment.Text, txtManufacturerPartNumber.Text,
cbIsDownload.Checked, productVariantDownloadID, cbIsShipEnabled.Checked, cbIsFreeShipping.Checked,
cbIsTaxExempt.Checked, int.Parse(this.ddlTaxCategory.SelectedItem.Value), txtStockQuantity.Value,
txtMinStockQuantity.Value, lowStockActivity,
int.Parse(this.ddlWarehouse.SelectedItem.Value), productVariantDisableBuyButton,
cbRequiresTextOption.Checked, txtTextOptionPrompt.Text,
txtPrice.Value, txtOldPrice.Value, txtWeight.Value, txtLength.Value,
txtWidth.Value, txtHeight.Value, productVariantPictureID, productVariantPublished,
productVariant.Deleted, txtDisplayOrder.Value, productVariant.CreatedOn, DateTime.Now);
This code just checks the new stock quantity and min stock quantity values and if you have set a low stock activity action, makes the necessary changes for you (i.e. disables buy button or unpublished product).
2) This bug is fixed in next release but I will tell you how to change for 1.10. In /modules/ProductBox1.ascx.cs and /modules/ProductBox2.ascx.cs add the following code at line 96:
if (btnAddToCart != null)
{
btnAddToCart.Visible = !productVariant.DisableBuyButton;
}
The complete block should look like:
if (productVariantCollection.Count > 0)
{
ProductVariant productVariant = productVariantCollection[0];
decimal oldPrice = productVariant.OldPrice;
decimal finalPriceWithoutDiscount = productVariant.GetFinalPrice(NopContext.Current.User, false);
decimal oldPriceConverted = CurrencyManager.ConvertCurrency(oldPrice, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
decimal finalPriceWithoutDiscountConverted = CurrencyManager.ConvertCurrency(finalPriceWithoutDiscount, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
if (finalPriceWithoutDiscountConverted != oldPriceConverted && oldPriceConverted != decimal.Zero)
{
lblOldPrice.Text = LocalizationManager.GetCurrencyString(oldPriceConverted, true, NopContext.Current.WorkingCurrency);
lblPrice.Text = LocalizationManager.GetCurrencyString(finalPriceWithoutDiscountConverted, true, NopContext.Current.WorkingCurrency);
}
else
{
lblOldPrice.Visible = false;
lblPrice.Text = LocalizationManager.GetCurrencyString(finalPriceWithoutDiscountConverted, true, NopContext.Current.WorkingCurrency);
}
if (btnAddToCart != null)
{
btnAddToCart.Visible = !productVariant.DisableBuyButton;
}
}
Please be aware that whilst this fixes one bug, it produces another (I am working on at the moment). If the product has more than one variant, and the first variant in the collection has it's DisableBuyButton property set to True, then the code above will disable the Add to Cart button on the product lists, even though the another variant in the Products ProductVariant collection, is available for purchase.
If you are not using multiple product variants then this will not affect you but I thought I would mention it.
Hope this helps,
Ben