Support » Plugin: Checkout Fields Manager for WooCommerce » PHP read customize fields

  • I need read the customized fields at PHP, i use this code

    $order_additional1 =$order_data[‘billing’][‘wooccm11’];

    echo ‘1’ . $order_additional1 . ‘<br />’;

    where wooccm11 it’s a customized field, and Outcome ”, the field have content, where it’s wrong at my code?

    Thanks

    • This topic was modified 1 month, 3 weeks ago by julioplus.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi @julioplus

    Please try this to retrieve custom fields.

    $value = get_post_meta($order_id, 'billing_wooccm11');

    Since checkout fields are attached to orders, you will need to grab the order ID first: $order_id

    Thread Starter julioplus

    (@julioplus)

    Don’t functionally. I have de Order Id, because the action it’s on WC Thank You,

    $order = wc_get_order( $order );
    $order_data = $order->get_data(); // The Order data

    $order_billing_first_name = $order_data[‘billing’][‘first_name’];
    $order_billing_last_name = $order_data[‘billing’][‘last_name’];
    $order_billing_company = $order_data[‘billing’][‘company’];
    $order_additional1 =$order_data[‘billing’][‘wooccm11’];
    $order_additional2 =$order_data[‘billing’][‘wooccm12’];
    $order_additional3 =$order_data[‘billing’][‘wooccm13’];
    $order_additional4 =$order_data[‘billing’][‘wooccm14’];

    echo ” . get_post_meta($order, ‘billing_wooccm11’) . ‘<br />’;`

    Can you please share full code, or let me know which hook you are using on the thank you page?

    Also, having an idea of what are you exactly trying to achieve might be useful to help you

    Thread Starter julioplus

    (@julioplus)

    Hi, thanks to help me

    ok i explain,

    At my web has a new user sign up form. I complete the form, and when finish form I need send dates form to execute a procedure (it’s functionally and it’s on my sql server) to add user and create a new user tables etc. if you want see you at’s this link:

    https://213.4.36.179/wordpress/producto/activo-plus-inversor-particular/

    This php code it’s execute on Thank You WOOCOMERCE page, and I test code that not it’s functionally.

    My code update to day it’s this:

    add_action(‘woocommerce_thankyou’, ‘action_woocommerce_before_checkout_form’);
    function action_woocommerce_before_checkout_form( $order )
    {
    $servername = TO PREVEN ATTACKS I DELETE THIS INFORMATION TO SEND YOU THIS CODE;
    $username = TO PREVEN ATTACKS I DELETE THIS INFORMATION TO SEND YOU THIS CODE;
    $password = TO PREVEN ATTACKS I DELETE THIS INFORMATION TO SEND YOU THIS CODE;
    $dbname = TO PREVEN ATTACKS I DELETE THIS INFORMATION TO SEND YOU THIS CODE; $port = “3337”;

    $mysqli = new mysqli($servername, $username , $password, $dbname, $port);
    if ($mysqli->connect_errno) {
    echo “Falló la conexión a MySQL: (” . $mysqli->connect_errno . “) ” . $mysqli->connect_error;
    }

    /* EXECUTE PROCEDURE */
    /* PROCEDURE bdactivoplusbase.AltaNuevoCliente (value form1, value form2…) WHAT CAPTURE THE FORM FIELS AT WOOCOMERCE? */

    $resultado = $mysqli->query(‘CALL bdactivoplusbase.AltaNuevoCliente(“ACTVPLS33”, “12345678”,2,”PLUS CONTROLLER PMS S.L.” , “Julio1”, “Jorro Plaza1”, “44852524i”, “vmartinez33@asisolution.com”, “607606793”, “”, 25, 1, 1, 3, “User2041″,”12345678″)’);

    /* THIS IS THE RESULT VALUES TO PROCEDURE *7
    while ($fila = $resultado->fetch_row()) {
    $idCliente = $fila[0];
    echo ” . $idCliente . ‘<br />’;
    $idUsuarioNew = $fila[1];
    echo ” . $idUsuarioNew . ‘<br />’;
    $passwordUsuarioE = $fila[2];
    echo ” . $passwordUsuarioE . ‘<br />’;
    $clienteDataBase = $fila[3];
    echo ” . $clienteDataBase . ‘<br />’;
    }

    Thread Starter julioplus

    (@julioplus)

    this code not it’s functionally

    $order = wc_get_order( $order );
    $order_data = $order->get_data(); // The Order data

    $order_billing_first_name = $order_data[‘billing’][‘first_name’];
    $order_billing_last_name = $order_data[‘billing’][‘last_name’];
    $order_billing_company = $order_data[‘billing’][‘company’];

    $order_additional1 =$order_data[‘billing’][‘wooccm11’];
    $order_additional2 =$order_data[‘billing’][‘wooccm12’];
    $order_additional3 =$order_data[‘billing’][‘wooccm13’];
    $order_additional4 =$order_data[‘billing’][‘wooccm14’];`

    At my form web this fields at
    wooccm11 = Usuario Web
    wooccm12 = Password Web
    wooccm13 = Usuario APP
    wooccm14 = Password APP

    Thread Starter julioplus

    (@julioplus)

    The fields are added on WOOCOMERCE INVOICE FIELDS

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.