We have custom code to handle calculations as follows:
// Put the code of your snippet below this comment.
add_shortcode('wpv-calculate', 'calculate_shortcode');
function calculate_shortcode($atts,$content=null) {
$content = wpv_do_shortcode($content);
$content = eval("return $content;");
return round($content);
}
The Total Points field is showing "NaN" on all the teams that made the playoff rounds in that tournament. The playoff matches included ones that did not have games for Men's Doubles, Women's Doubles, Mixed Doubles A, and Mixed Doubles B, which is what the calculation field is based on. Those playoff matches only used the TeamMaker points system and those do not get added to the Total Points calculation.
We have the code to execute the calculation in a view as follows;
<td class="score-[wpv-post-id item='@team-1-match.parent']">[wpv-conditional if="( $(wpcf-team-1-score-mens-doubles) gt '0' )"][wpv-calculate][types field="team-1-score-mens-doubles"][/types]+[types field="team-1-score-womens-doubles"][/types]+[types field="team-1-score-mixed-doubles-1"][/types]+[types field="team-1-score-mixed-doubles-2"][/types] [/wpv-calculate][/wpv-conditional]</td>
See how we're calculating the sum of scores in four different game types within a match - men's doubles, women's doubles, mixed doubles 2 and mixed doubles 2. This was working fine previously.
But subsequently, we've added another game called TeamMaker. Most games do not use the TeamMaker fields and those are still working fine. But we have some playoff matches that ONLY use the TeamMaker fields. On those matches, the men's, women's, mixed 1 and mixed 2 score fields remain empty. The TeamMaker results are treated kind of like penalty kick shootout goals in soccer. They don't get added to the Total Points. So the calculation is getting thrown off by the presence of matches that do not include the men's, women's, mixed 1 and mixed 2 score fields. Whenever the calculation encounters matches with those fields empty, it is returning output of "NaN" on the page here:
hidden link
I'm not sure what I need to modify in the calculation code to prevent this result of "NaN". Note that it is also possible that the problem does not reside in the calculation code. This Standings by Session page has custom Javascript that Luo Yang set up for us that puts all the match results in the format needed on the page. It is possible that the Javascript is where this "NaN" output is coming from. I'm not sure there.
Any assistance here will be greatly appreciated.