• Resolved kiberchaka

    (@kiberchaka)


    Hi!
    I try to get value of fields this way:

    add_action( 'woocommerce_checkout_order_processed', 'action_function_apinetua' );
    function action_function_apinetua( $order_id ){
        $order 		= wc_get_order($order_id);
        $order_data 	= $order->get_data();
        $urlMySite 	= 'https://tennis.com.ua';
        $orderUrl 	= '=HYPERLINK("'.$urlMySite.'/wp-admin/post.php?post='.$order_id.'&action=edit";"'.$order_id.'")'; // Номер заказа
        $phone		= $order_data['billing']['phone']; 
        $first_name	= $order_data['billing']['first_name'];
        $last_name	= $order_data['billing']['last_name'];
        $priceTotal	= str_replace('.',',',$order_data['total']);
        $payment_method = $order_data['payment_method'] == 'cod' ? 'НП получатель' : 'Получатель';
        $city 		= str_replace('город ','',$order_data['shipping']['city']); // Город
        $address	= $order_data['shipping']['address_1'];
        $email		= $order_data['billing']['email'];
        
        $wcity		= $order_data['billing']['wcity']; // Custom field
        $street		= $order_data['billing']['street']; // Custom field
        $house		= $order_data['billing']['house']; // Custom field
        if (!$address AND !$wcity) $payment_method = 'Самовывоз';
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter kiberchaka

    (@kiberchaka)

    Defauld fields are being getting good, but created with the plugin ones are empty.

    Thread Starter kiberchaka

    (@kiberchaka)

    In orders in admin page I can see all values, on thank you page values is also present, but programmatically – no values.

    Thread Starter kiberchaka

    (@kiberchaka)

    I found the solution, the problem was, that your data is saved in protected meta data. It is possible to get it this way:

    $order->get_meta('_billing_wcity');

    Plugin Author ThemeHigh

    (@themehigh)

    All the fields created using our plugin are saved as Order Meta Data.

    You can retrieve the data from the database using the below function:

    get_post_meta($order_id, ‘field_name’, true);

    We hope this will help.

    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Can’t get custom fields values programmatically’ is closed to new replies.