Have pricing rules be displayed as a percentage amount ABOVE the cost of goods for a product.
To start, I modified these 2 methods in the admin/products/specials/editspecial.aspx.cs file
Code: Select all
protected void BindSpecial()
{
LSDecimal hold=_Special.Price;
hold=( (hold/_Product.CostOfGoods)-1)*100;
Price.Text = string.Format("{0:0}", hold);
StartDate.SelectedDate = _Special.StartDate;
EndDate.SelectedDate = _Special.EndDate;
if (_Special.SpecialGroups != null && _Special.SpecialGroups.Count > 0)
{
SelectedGroups.Checked = true;
Groups.DataBind();
foreach (SpecialGroup group in _Special.SpecialGroups)
{
ListItem listItem = Groups.Items.FindByValue(group.GroupId.ToString());
if (listItem != null) listItem.Selected = true;
}
}
}
protected void SaveSpecial()
{
LSDecimal hold=AlwaysConvert.ToDecimal(Price.Text);
hold= _Product.CostOfGoods + ((hold/100)*_Product.CostOfGoods);
_Special.Price = hold;
_Special.StartDate = StartDate.SelectedDate;
_Special.EndDate = EndDate.SelectedEndDate;
_Special.SpecialGroups.DeleteAll();
if (SelectedGroups.Checked)
{
foreach (ListItem item in Groups.Items)
{
if (item.Selected) _Special.SpecialGroups.Add(new SpecialGroup(0, AlwaysConvert.ToInt(item.Value)));
}
if (_Special.SpecialGroups.Count == 0)
{
SelectedGroups.Checked = false;
AllGroups.Checked = true;
}
}
_Special.Save();
}
Code: Select all
protected void SaveButton_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
Special special = new Special();
special.ProductId = _ProductId;
LSDecimal hold=AlwaysConvert.ToDecimal(Price.Text);
hold= _Product.CostOfGoods + ((hold/100)*_Product.CostOfGoods);
special.Price = hold;
special.StartDate = StartDate.SelectedDate;
special.EndDate = EndDate.SelectedEndDate;
if (SelectedGroups.Checked)
{
foreach (ListItem item in Groups.Items)
{
if (item.Selected) special.SpecialGroups.Add(new SpecialGroup(0, AlwaysConvert.ToInt(item.Value)));
}
}
special.Save();
Response.Redirect("Default.aspx?ProductId=" + _ProductId.ToString());
}
}
After that, I realized that Able doesnt update pricing rules when you change the cost of goods on the edit product page. I then made the following modifications to the SaveButton_Click method on the admin/products/editproduct.aspx.cs file.
Starts around line 213 for us:
Code: Select all
//TAXES AND SHIPPING
_Product.ShippableId = (byte)AlwaysConvert.ToInt(IsShippable.SelectedIndex);
_Product.Weight = AlwaysConvert.ToDecimal(Weight.Text);
_Product.Length = AlwaysConvert.ToDecimal(Length.Text);
_Product.Width = AlwaysConvert.ToDecimal(Width.Text);
_Product.Height = AlwaysConvert.ToDecimal(Height.Text);
_Product.WarehouseId = AlwaysConvert.ToInt(Warehouse.SelectedValue);
_Product.WrapGroupId = AlwaysConvert.ToInt(WrapGroup.SelectedValue);
_Product.TaxCodeId = AlwaysConvert.ToInt(TaxCode.SelectedValue);
//FireFold Pre Mod
LSDecimal preCost=_Product.CostOfGoods;
_Product.CostOfGoods = AlwaysConvert.ToDecimal(CostOfGoods.Text); //Not a mod
//FireFold Mod
SpecialCollection specials=SpecialDataSource.LoadForProduct(_Product.ProductId);
foreach(Special _Special in specials){
LSDecimal percentage=( (_Special.Price/preCost)-1)*100; //calculate percentage over original cost
_Special.Price=_Product.CostOfGoods + ((percentage/100)*_Product.CostOfGoods); //apply percentage to new cost
_Special.Save();
}
_Product.VendorId = AlwaysConvert.ToInt(Vendor.SelectedValue); //not a mod