Support

Account

Home Forums Front-end Issues Display Custom Fields At Thank You WOOComerce Page Reply To: Display Custom Fields At Thank You WOOComerce Page

  • Hi @vicmar

    If you’ve added custom fields to the billing form, this information is store against the order ID.

    So on the thank you page, you need to access the order ID, then you should be able to access your custom field data.

    For example:
    $variable2 = get_field(‘billing_wooccm11’,$order_id);

    I also believe this line is wrong:
    add_action(‘woocommerce_thankyou’, ‘action_woocommerce_before_checkout_form’);

    You’re trying to use a hook for the thank you page but mixed with an action on the checkout page (I may be wrong here!)

    I think this is the correct hook:

    
    function action_woocommerce_thankyou( $order_get_id ) { 
    // your code goes here
    }; 
    add_action( 'woocommerce_thankyou', 'action_woocommerce_thankyou', 10, 1 ); 
    

    Or you could copy the thank-you.php file to your theme and add the code directly – obviously you need to still