olado/doT

I want to display pricing based on cookies.. in doT.js template

vijay09-dev opened this issue · 2 comments

 {{##def.x_sellPrice1_SS: {{=value.x_sellPrice1_SS}} #}}
                        {{##def.x_sellPrice4_WA: {{=value.x_sellPrice4_WA}} #}}
                        {{##def.sellPrice1_SS: {{=value.sellPrice1_SS}} #}}
                        {{##def.sellPrice1_SSp: {{value.sellPrice1_SS}} #}}
                        {{##def.price = '' #}}
                        {{##def.salePrice = '' #}}
                        {{##def.fntest = function(str,tr,ss,ssp,aa,t,r) {
                            var region = "SOUTH STATES";
                            var sellPriceObj = {"SOUTH STATES": str};
                            var priceObj = {"SOUTH STATES": ss};
                            for (var property in sellPriceObj) { 
                                if(region == property) { 
                                    r = sellPriceObj[property];
                                } 
                            }
                            for (var property in priceObj) {
                                if(region == property) { 
                                    t = priceObj[property];
                                } 
                            }
                            console.log(r, t); 
                            if(t === r){ 
			    return '<div class="product-card__price"><small class="dynamicproductlabel">Our Price</small>'+'$'+ price.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}) + '</div>';
                            }
                            else{
                                 return "region : " + str + tr + sellPriceObj['SOUTH STATES'] + r + ss + t;
                            }
                        }
                        #}}
                        {{#def.fntest(def.x_sellPrice1_SS,def.x_sellPrice4_WA,def.sellPrice1_SS,def.sellPrice1_SSp, "\{\{value.sellPrice1_SS\}\}" , def.price)}}
                    

Getting printed price values in return statement but in console.log() it is getting output as {{value.sellPrice1_SS}} because of this it is not able to compare the sellprice and original price at the if condition. Could any one help me..?
console,log(r,t:)//{{=value.x_sellPrice1_SS}} {{=value.x_sellPrice1_SS}}

You have to include cookie in some way (depending on the environment) to the data that you pass to compiled dot template. It is not in scope of this library.