WordCamp Europe 2023 Special Offer - Get 30% OFF any edition with coupon: WC30

My Account

Forums

Home Forums General Woocomerce fields.

Viewing 2 reply threads
  • Author
    Posts
    • #153284
      John Horton
      Participant

      I’m looking to pass the the fields from a form to the woocommerce checkout fields to save customer having to enter them in the form and then in the checkout.

      Any advise would be greatly appreciated

      I have created a snippet but it will not let me add the code here.

      add_action( ‘woocommerce_checkout_update_order_meta’, ‘ws_form_populate_checkout_billing_details’, 10, 1 );

      function ws_form_populate_checkout_billing_details( $order_id ) {
      $ws_form_id = 8;
      $ws_form_first_name = get_post_meta( $ws_form_id, ‘ws_form_first_name’, true );
      $ws_form_last_name = get_post_meta( $ws_form_id, ‘ws_form_last_name’, true );
      $ws_form_phone = get_post_meta( $ws_form_id, ‘ws_form_phone’, true );
      $ws_form_email = get_post_meta( $ws_form_id, ‘ws_form_email’, true );

      update_post_meta( $order_id, ‘_billing_first_name’, $ws_form_first_name );
      update_post_meta( $order_id, ‘_billing_last_name’, $ws_form_last_name );
      update_post_meta( $order_id, ‘_billing_phone’, $ws_form_phone );
      update_post_meta( $order_id, ‘_billing_email’, $ws_form_email );

    • #186018
      Maxime Duthoit
      Participant

      Hello,

      I’m also looking to retrieve the data entered in the form and insert it into the checkout fields (checkout page).

      Do you have a solution? To use Run WordPress Hook, you have to send the form, but the form is not sent when you arrive on the order page.

      Thanks !

    • #186990
      sindas
      Participant

      I think I’ve done this in the past by saving the data directly to the user’s account, that way it shows up on checkout if they are logged in.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.

Login