Yes, I can see now. The PPOM plugin itself on your website is not customized but the script (what you call a macro) your previous developer created is what is causing your problem.
The offending code is here:
$.each($('#protein option'), function(ind) {
$(this).attr('id', '' + parseInt(ind + 1));
});
$.each($('#vegetable option:not(:first)'), function(ind) {
$(this).attr('id', '' + parseInt(ind + 1));
});
$.each($('#vegetable_size option'), function(ind) {
$(this).attr('id', '' + parseInt(ind + 1));
});
$.each($('#carb_grain option:not(:first)'), function(ind) {
$(this).attr('id', '' + parseInt(ind + 1));
});
$('#protein option:last-child').removeAttr('id');
$('#vegetable option:last-child').removeAttr('id');
$('#vegetable_size option:last-child').attr('id', '0');
$('#carb_grain option:last-child').removeAttr('id');
$('#carb_grain_size option:last-child').attr('id', '0');
The $.each
code traverses each individual select option and adds the ID field to each individual option under each select. Although the parseInt
is out of whack. It should be $(this).attr('id',(parseInt(ind)+1));
.
Then, for some reason, the last option ID is removed. This code:
$('#protein option:last-child').removeAttr('id');
This is exactly why you don’t see an ID on the last attribute.
Additionally, the reason that the calories and counts are out of whack is because the arrays for referencing the values have to be updated as well when you add a new PPOM meta field value for any of the options. So if you add a new protein, you have to update the var proteinArray
with a JSON-encoded value that matches the new value that you are adding in PPOM. This also applies to the vegetableArray
and carbArray
.
The script (macro) was written to return zeroes for everything if nothing was found. That is why you are seeing all zeroes for the new options you are adding.
Your problem is not a PPOM plugin issue. It is your custom script that interacts with the PPOM fields. It needs to be revised to work properly in-accordance-with the changes you are making to the PPOM selection fields.