Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
vijay09-dev opened this issue May 21, 2020 · 2 comments
Closed

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

vijay09-dev opened this issue May 21, 2020 · 2 comments

Comments

@vijay09-dev
Copy link

vijay09-dev commented May 21, 2020

 {{##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)}}
                    
@vijay09-dev
Copy link
Author

vijay09-dev commented May 21, 2020

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}}

@epoberezkin
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants