Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Arne 10 posts 30 karma points
    Oct 19, 2012 @ 10:13
    Arne
    0

    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?

     

     


     

     

  • Anders Burla 2560 posts 8256 karma points
    Oct 19, 2012 @ 11:36
    Anders Burla
    0

    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

  • Arne 10 posts 30 karma points
    Oct 19, 2012 @ 13:06
    Arne
    0

    Thanks for your reply

    That will work, but is there a method to calculate/add the VAT to the oldPrice?

  • Anders Burla 2560 posts 8256 karma points
    Oct 22, 2012 @ 08:58
    Anders Burla
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft