• Hi

    I’m evaluating your Product Addons for Woocommerce.
    I’ve created a custom Text Field and it shows up as expected on my order page.
    I need to retrieve the value that the customer enter from my php code.
    I found an article in the forum that says to use the code below:

    $skus = $item_quantities = $line_item_totals = $items_meta_data = array();
    // Loop though order items
    foreach( $order->get_items() as $item_id => $item){
    $items_meta_data[] = $item->get_meta_data();
    }

    What I need is a way to retrieve the value the user entered in a Text Field. Can you please help with that?

    Thanks
    Ralph

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author acowebs

    (@acowebs)

    Hi,
    You want to access the text field in cart once the user submit the form? or after completing the order?

    Plugin Author acowebs

    (@acowebs)

    Find an example code below on how to get field value

     $order = wc_get_order(242);
        foreach ($order->get_items() as $item_id => $item) {
            $meta_data = $item->get_meta(WCPA_ORDER_META_KEY);
            // $meta_data this $meta_data will have all the user submited data. You can iterate through this and get the required value
    // see below example code
            $dataRequired= '';
            foreach ($meta_data as $v){
                if($v['name']=='number-1551176731967'){
                    $dataRequired = $v['value'];
                }
            }
         
    
        }

    As we haven’t heard back from you further, we assume that this issue has been resolved at your end and considering this ticket as closed. Please don’t hesitate to get back to us if you require any further assistance or clarifications from our end in the future. Thanks!

    WCPA_ORDER_META_KEY
    What mean by this
    What to add there?

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Retrieve custom field value’ is closed to new replies.