Where is the variable defined? Can your template just call a function with a parameter and you define that function in functions.php?
Hello Steve Stern,
I am using one of the plugin – to implement payment form, I am using hook to update that amount value dynamically when page load.
That payment form, I am using in my custom page, and passing the Amount through URL of that payment page to hook I am updating the amount value when page load. Hook defined in funcion.php
I am trying to find a solution, without passing value from URL, if I can pass the value to that hook dynamically when page load. I tried to defined Global variable but it is not working for me.
Thanks,
Yeah, globals only are valid within the same request. Make a new request and all globals are forgotten. You have a few choices for storing values that persist between requests. Store as a cookie value, PHP session variable, or WP transient. Cookies work better with with JS than PHP. Transients require DB queries and are better for more extended but still temporary storage like into the following day. Thus session variables are probably your best bet.
http://php.net/manual/en/book.session.php