How to call a function from functions.php with ajax?

You mean need to display the custom code your ajax add to cart button right? . add this below code your current active function.php file add_action( ‘wp_ajax_woocommerce_before_add_to_cart_button’, ‘hello_world’, 10); add_action( ‘wp_ajax_nopriv_woocommerce_before_add_to_cart_button’, ‘hello_world’, 10); 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”); }

How to echo a PHP code into WooCommerce variation product?

I solved the issue, what i was missing is to convert the API return to string, here is the code hopefully it helps someone. <?php add_filter( ‘woocommerce_available_variation’, ‘custom_load_variation_settings_products_fields’ ); function custom_load_variation_settings_products_fields( $variations ) { // duplicate the line for each field $variations[‘wccaf_de_asin_var’] = get_post_meta( $variations[ ‘variation_id’ ], ‘wccaf_de_asin_var’, true ); $variations[‘wccaf_uk_asin_var’] = get_post_meta( $variations[ ‘variation_id’ … Read more