I'm wondering how can i call a function from functions.php and print it with Ajax in a specific place (woocommerce_before_add_to_cart_button).
I know i can simply add my function in add_action like what i did below but i though that ajax is the way to go because my function output got cached (full page caching) so i though that ajax can be a solution for that issue.
<?php
add_action( 'woocommerce_before_add_to_cart_button', 'hello_world', 10);
function hello_world()
{
$var1 = 'Hello World!';
echo $var1;
echo "The time is " . date("h:i:sa");
}
?>
I would appreciate if the answers was very simplified since i'm totally new to coding. Thanks in advance