The way we have done it in a couple of cases is to add an extra field for the product document type - called oldPriceDKK (you need one for every currency). Then in your Razor/XSLT you look if this property has any value and write your discount splash with the old price. The real price field will have the new discounted price.
You need the VAT group to calc the price with and without vat. Here is what we do i in GetPrices method in Tea Commerce XSLT library. Hope it helps you.
public static XPathNodeIterator GetPrices( XPathNodeIterator node ) { XElement pricesEle = new XElement( "prices" );
if ( node.MoveNext() ) { long VATGroupId = SessionController.CurrentOrderId != null ? SessionController.CurrentOrder.VATGroupId : SessionController.CurrentCountry.VATGroupId;
Campaign price property
I want to add the ability to give products a campaign price in Tea commerce. Is there a best way to solve this?
Hi Arne
The way we have done it in a couple of cases is to add an extra field for the product document type - called oldPriceDKK (you need one for every currency). Then in your Razor/XSLT you look if this property has any value and write your discount splash with the old price. The real price field will have the new discounted price.
Kind regards
Anders
Thanks for your reply
That will work, but is there a method to calculate/add the VAT to the oldPrice?
Hi Arne
You need the VAT group to calc the price with and without vat. Here is what we do i in GetPrices method in Tea Commerce XSLT library. Hope it helps you.
public static XPathNodeIterator GetPrices( XPathNodeIterator node ) {
XElement pricesEle = new XElement( "prices" );
if ( node.MoveNext() ) {
long VATGroupId = SessionController.CurrentOrderId != null ? SessionController.CurrentOrder.VATGroupId : SessionController.CurrentCountry.VATGroupId;
//VAT Group property
if ( !string.IsNullOrEmpty( TeaCommerceSettings.VATGroupPropertyAlias ) ) {
string strVATGroup = XSLTHelper.GetProperty( node.Current, TeaCommerceSettings.VATGroupPropertyAlias );
if ( strVATGroup != null && !strVATGroup.Equals( string.Empty ) )
VATGroupId = strVATGroup.ParseToLong().Value;
}
decimal VAT = VATGroup.GetVATGroup( VATGroupId ).GetVAT( SessionController.CurrentCountry.Id );
//Prices
foreach ( var currency in Currency.GetCurrencies() ) {
XElement ISOCodeEle = new XElement( currency.ISOCode );
string price = XSLTHelper.GetProperty( node.Current, currency.PricePropertyAlias );
if ( price != null && !price.Equals( string.Empty ) ) {
decimal priceWithoutVAT = FormatHelper.CalcPriceWithoutVat( PriceHelper.ParsePrice( price, 0m ), VAT );
ISOCodeEle.Add( new XAttribute( "price", Math.Round( priceWithoutVAT * ( 1M + VAT ), 2 ) ) );
ISOCodeEle.Add( new XAttribute( "priceWithoutVAT", priceWithoutVAT ) );
pricesEle.Add( ISOCodeEle );
}
}
}
return pricesEle.CreateNavigator().Select( "/" );
}
Kind regards
Anders
is working on a reply...