Could anyone shed some light on pricing calculations that are performed when an item is added to the cart? Running Gold R6, WSP.
We have some users with special pricing for certain product variants. They aren't a discount, from the users/customers perspective it is just the "price" (as you'll notice reading through my code snippet, they are stored in the db as percentages of the standard price). The out of the box special pricing doesn't work for us, because depending on the option/variant the user chooses, the price is different.
This has always been a little painful for us, but it is the way it is.
In any case, I have created a custom table with the special price rules in it. I can display the correct price on the product page, as I've added code to ConLib/Utility/ProductPrice.aspx to perform this. For anyone interested it is:
Code: Select all
//CUSTOMIZATION TO GET CUSTOMER SPECIAL PRICE AND DISPLAY IT WITHOUT SHOWING ANY KIND OF DISCOUNT ENERCO RLO 11/11/13
//find the right vcId (CustomerNumber)
IList<CommerceBuilder.Users.UserSetting> usersetting;
usersetting = UserSettingDataSource.LoadForUser(AbleContext.Current.User.Id);
string vcId = "";
decimal myprice = 0;
foreach (UserSetting setting in usersetting)
{
if (setting.FieldName == "customer_number")
{
vcId = setting.FieldValue;
}
}
//Get the records from the database
if (vcId.IsNotNullOrEmpty())
{
string sql = "SELECT CustomerNumber, ProductOptionID, PriceModifier FROM ac_UserCustSpecialPrice_Enerco WHERE CustomerNumber = '";
sql = sql + vcId + "'";
IList result = NHibernateHelper.CreateSQLQuery(sql).List();
foreach (object[] dataRow in result)
{
//if a record matched, adjust the price.
if (_OptionList.IndexOf(dataRow[1].ToString()) != -1) //it matches!
{
myprice = Math.Round(priceWithVAT * (1 + Convert.ToDecimal(dataRow[2].ToString())),0);
Price.Text = string.Format(_PriceFormat, myprice.LSCurrencyFormat("ulc"));
}
}
}
//END CUSTOMIZATION
But, when the item is added to the basket, the standard price for the variant is used. I can't seem to find where the price is calculated when the item is added to the basket. Could someone point me in the right place?
Thanks in advance,
Rudy
P.S. I don't have Able's source code...maybe it is needed for this function...