Support

Account

Home Forums Front-end Issues delivery date to checkout page + order + emails

Solved

delivery date to checkout page + order + emails

  • Hello,

    can someone help me to add custom fields (delivery date + time) to an order ?

    I would like that the customer select the delivery date + delivery time on the checkout page.
    Then these data are saved to the customer order, can be display on the backend and email sent.

    I’ve tried the following for a start but nothing is displayed :

    add_action( 'woocommerce_after_order_notes', 'my_custom_checkout_field' );
    function my_custom_checkout_field(){
    
    the_field('deliverydate',WC()->order->id);
    echo ' MY TEST FUNCTION 
    ';
    }

    who can help me please ?

    Cheers,

  • Hi @marc-bovetgmail-com

    Kindly check this page to learn how to customize the checkout page: https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/.

    Because this is not related to ACF, kindly get in touch with WooCommerce support for further support.

    I hope this makes sense πŸ™‚

  • Hi James,

    any tip is always welcome thank you.
    I’ve found this ressources as well, but I thaught I could use ACF to display my fields and store the correct values.

    Cheers,

    marc

  • Hi @marc-bovetgmail-com

    Because WooCommerce is the one that handles the checkout page, ACF won’t be able to do anything on that page.

    To add ACF input fields, you can use the acf_form() with ‘form’ option set to false. That way it will be integrated to the checkout form. But you need process this form manually.

    On the link I gave you before, it uses woocommerce_checkout_update_order_meta hook to process the form, so you need to do it here too. Using this hook, you can use the update_field() function to update the field for the order.

    I hope this makes sense πŸ™‚

  • Hi James,

    Thank you very much, I understand better now. I’m a newbie with ACF.
    In ACF backend, my fields groupe (delivery date + delivery time) have the post id 730.

    works fine with
    acf_form(array('form' => false,'fields_group' => 730));

    This first step jumps me to another question :
    how can I configure the date picker ?

    For example :
    – past dates are not allowed
    – max 10 days ahead
    – some days are not choosable (because shop is closed).

    Thank you for helping,

    Cheers,

    Marc

    Regards,

  • Hi @marc-bovetgmail-com

    ACF uses jQuery Datetimepicker to add the input fields. To modify it, you need to modify the arguments. This page should give you more idea about it: https://www.advancedcustomfields.com/resources/adding-custom-javascript-fields/.

    Hope this helps πŸ™‚

  • Hi James,

    Thank you for the info.

    cheers,

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

You must be logged in to reply to this topic.