Home Forums General Issues How to show ACF fields on WooCommerce Checkout page


How to show ACF fields on WooCommerce Checkout page

  • Hello,

    I’m working on a project where I have to add custom fields to my WooCommerce Checkout page, I don’t want to use the plugins like WooCommerce Checkout manager as it’s not suitable and limited in functions.

    I decided to use ACF to make it works, I’m looking for a way, if ACF supported, so we can add ACF fields to WooCommerce page.

    Can you please help me on that?

    Thank you!

  • You could create a page, then create an ACF group that appears only on this specific page, and then finally edit the WC checkout template to call upon these fields, using the page’s ID – get_field( ‘field_name’, $page_id ).

    If creating a page for this purpose seems inelegant, you could use this plugin that allows you to use ACF on widgets:

    Advanced Custom Fields: Widget

    In your theme’s functions.php, register a new widget area for use on your checkout, then create an ACF group for this widget, insert it in and configure it. The plugin’s documentation has some specific instructions on how to call the fields on your template, but feel free to ask if you have any doubts.

  • I have added the fields to the checkout page successfully; now I’m making it save data to Order detail, everything works file but for upload fields.

    It works perfectly for the logged-in user, but for not the logged-in user, it shows the basic upload file selector, when it POST and save to order detail, I only can see the path of the file is C://fakepath/filename.

    Do you know why it’s happening?

    You can take a look at demo here:

  • Accessing the original file path in the user’s computer is not possible, either through JavaScript or PHP’s $_POST, because it would pose an invasion to the user’s privacy.

    You can only access the file’s name and a few other properties after it already has been uploaded, using the $_FILES superglobal on your PHP script.

    You then have to complete the upload process by moving/renaming the uploaded file (which is stored in a temporary folder) into your chosen directory, otherwise it will be automatically deleted by PHP at the end of the script.

    For more:

    PHP Manual on File Uploads

    You can also use a built-in WordPress function:


  • The problem i’m facing is:

    Scence 1:

    + Not login, basic upload
    + Leave “First name” field of WooCommerce blank
    + Press checkout, the file you choosed will be uploaded.

    Scence 2:

    + Not login, basic upload
    + Fill all fields of WooCommerce
    + Press checkout, no file uploaded. You will be redirected to Order received page


    So I think that Scence 2 not working because it’s lacking of some function or a properly action/hook.

    It would be great if I can debug and see what’s missing but I can’t enable for not-logged-in user.

    Thank you

  • Hello Andrew,
    could you share your code?

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘How to show ACF fields on WooCommerce Checkout page’ is closed to new replies.