Custom Fields Not Available in Quote Web Template


#1

Version 1.5.9

Trying to build a custom template for quotes however when I include the $custom_fields variable I get an error that it is not defined. Is this a known bug or am I doing something wrong?


#2

I seem to have this problem as well. Just migrated from 1.4 and trying to solve this. Have read the docs on migrating & changes to custom fields.

For a custom variable called “ABN” in “user”, I’ve tried:

<?php if ($custom_fields['user']['ABN']) {
  echo 'ABN: ' . ($custom_fields['user']['ABN']) . '<br><br>'; } ?>

Which throws up a PHP error: “Undefined variable: custom_fields”

I’ve also tried:

<?php if (!empty($custom_fields['user']['ABN'])): ?>
  <?php echo 'ABN: ' . ($custom_fields['user']['ABN']) . '<br><br>'; ?>
<?php endif; ?>

Which doesn’t throw an error, but doesn’t print the custom variable.

Any ideas?


#3

I cannot reproduce this problem.
Adding

<?php
echo '<pre>';
var_dump($custom_fields);
echo '</pre>';
?>

prints out

array (size=3)
  'invoice' => 
    array (size=3)
      'Sent on' => string '2018-04-26' (length=10)
      'Test Custom Field 2' => null
      'Test Single Choice' => string '' (length=0)
  'client' => 
    array (size=0)
      empty
  'user' => 
    array (size=0)
      empty

which is correct for my testing setup.

Please verify that the contents of your file application/modules/guest/controllers/View.php matches this file.


$custom_fields is not available in invoice templates and email template
#4

Thanks for the reply. That code again just prints the same error for me.

And yes, checked my live production version of View.php and the one from Git and they are identical.

Mystery! What else could be causing this?


#5

that is weird indeed. If both files are identical, the custom_fields variable should be available in the templates. Have no idea why the var could be missing.