I'm not sure what you mean by grand total on a variable, can you please explain in more detail.
To add the grand total to a hidden form element:
<input type="hidden" name="<Name for the form element>" value="<?php echo $CartName->GrandTotal(); ?>" />