Developer forum

Forum » Development » Split price at decimal seperator

Split price at decimal seperator


Reply
Hi there,

I need to show the Ecom.Price in to seperate parts like:
29<sup>95</sup>
How can I split the totalprice into two parts before and after the decimal separator?

Can be done with JS, but are there DWtags available to use?

Niek

Replies

 
Reply
Hi Niek,

You can use the ProdutTemplateExtender to manipulate the output, ie:

using Dynamicweb;
using Dynamicweb.eCommerce.Products;
 
namespace myModule
{
    public class ProductTemplateExtender1 : ProductTemplateExtender
    {
        public override void ExtendTemplate(Dynamicweb.Templatev2.Template Template)
        {
            if (Template.TagExists("Ecom:Product.Price"))
            { 
                Template.SetTag("Ecom:Product.Price",Product.Price.ToString().Replace(".","your stuff"));
            }
        }
    }
}

Notice that the Ecom:Product.Price also contains the currency at the beginning, so you may want to use another available tag (see available product tags at http://templates.dynamicweb.dk/eCommerce/Dynamicweb-eCommerce-template-tags/Product-Catalog/Product-detail.aspx). Though, the above should be able to get you along.


Regards /Snedker
 
Reply
Hi thanks, that works but can i do the same with <!--@Ecom:Product.ActualPriceWithoutVAT-->? 
It seems that this tag is not recognizes when building the project.

Niek
 
Nicolai Høeg Pedersen
Reply
The product.price is a Piceinfo object which has different properties, i.e. the price without VAT:

Product.Price.PriceWithoutVAT.ToString().Replace(".","your stuff"));

 

You must be logged in to post in the forum