Reading field | WordPress.org

Hi CodePeople,

I have a calculated field (fieldname2) that either shows a number with % or a number with €:

IF(fieldname1==1,FORMAT(fieldname18, {prefix:””, suffix:”%”, groupingsymbol:”.”, decimalsymbol:”,”, currency:false}),
FORMAT(fieldname18, {prefix:””, suffix:” €”, groupingsymbol:”.”, decimalsymbol:”,”, currency:true}))

Works fine. Now when I add another calculated field, it is possible to “read” if its % or €? I tried the following things but it doesn’t show anything:

IF(INCLUDES(fieldname2, “€”), fieldname2,fieldname3)

function die(fieldname2) {
if (fieldname2.includes(“€”)) {
return fieldname2;
} else {
return fieldname3;
}
}

“Contains” instead of “includes” also doesn’t work … Any suggestions?

Thanks!

PS. I know I could simply repeat the if statement in the calculated field 2 but when its a more complex furmala, the reading would be just more simple 🙂

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer