Avoid undefined variable notices when calculating totals and saving attributes via AJAX.