• I am adding an woocomerce action to “woocommerce_order_status_completed”.

    I just want to know how to get the text field content generated by your plugin.

    I tried the get_post_meta function with no success.

    I have the WC_Order object and the others too (WC_Item WC_Product), etc.

    I just need to know how to get this text info.

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter luiseduardops

    (@luiseduardops)

    I tried all these get_post_meta:

    
    
    					"Order ID - ".$order_id." <\br> ".
    					"Meta Order ID 1 > ".get_post_meta($order_id, 'instagram', true)." <\br> ".
    					"Meta Order ID 2 > ".get_post_meta($order_id, 'wccaf_instagram', true)." <\br> ".
    					"Meta Order ID 3 > ".get_post_meta($order_id, 'wccpf_instagram', true)." <\br> ".
    					"Meta Order ID 4 > ".get_post_meta($order_id, 'attribute_instagram', true)." <\br> ".
    					"Meta Order ID 5 > ".get_post_meta($order_id, 'attribute_wccaf_instagram', true)." <\br> ".
    					"Meta Order ID 6 > ".get_post_meta($order_id, 'attribute_wccpf_instagram', true)." <\br> ".
    
    					"Product ID - ".$product_id." <\br> ".
    					"Meta Product ID 1 > ".get_post_meta($product_id, 'instagram', true)." <\br> ".
    					"Meta Product ID 2 > ".get_post_meta($product_id, 'wccaf_instagram', true)." <\br> ".
    					"Meta Product ID 3 > ".get_post_meta($product_id, 'wccpf_instagram', true)." <\br> ".
    					"Meta Product ID 4 > ".get_post_meta($product_id, 'attribute_instagram', true)." <\br> ".
    					"Meta Product ID 5 > ".get_post_meta($product_id, 'attribute_wccaf_instagram', true)." <\br> ".
    					"Meta Product ID 6 > ".get_post_meta($product_id, 'attribute_wccpf_instagram', true)." <\br> ".
    
    					"Variation ID - ".$item['variation_id']." <\br> ".
    					"Meta Order ID 1 > ".get_post_meta($item['variation_id'], 'instagram', true)." <\br> ".
    					"Meta Order ID 2 > ".get_post_meta($item['variation_id'], 'wccaf_instagram', true)." <\br> ".
    					"Meta Order ID 3 > ".get_post_meta($item['variation_id'], 'wccpf_instagram', true)." <\br> ".
    					"Meta Order ID 4 > ".get_post_meta($item['variation_id'], 'attribute_instagram', true)." <\br> ".
    					"Meta Order ID 5 > ".get_post_meta($item['variation_id'], 'attribute_wccaf_instagram', true)." <\br> ".
    					"Meta Order ID 6 > ".get_post_meta($item['variation_id'], 'attribute_wccpf_instagram', true)

    The $product_id , $order_id and $item[‘variation_id’] are all ok, but all the get_post_meta did not show me anything.

    • This reply was modified 7 years, 2 months ago by luiseduardops.
    Thread Starter luiseduardops

    (@luiseduardops)

    get_post_meta($order_id, 'instagram', true)
    get_post_meta($order_id, 'wccaf_instagram', true)
    get_post_meta($order_id, 'wccpf_instagram', true)
    get_post_meta($order_id, 'attribute_instagram', true)
    get_post_meta($order_id, 'attribute_wccaf_instagram', true)
    get_post_meta($order_id, 'attribute_wccpf_instagram', true)
    
    get_post_meta($product_id, 'instagram', true)
    get_post_meta($product_id, 'wccaf_instagram', true)
    get_post_meta($product_id, 'wccpf_instagram', true)
    get_post_meta($product_id, 'attribute_instagram', true)
    get_post_meta($product_id, 'attribute_wccaf_instagram', true)
    get_post_meta($product_id, 'attribute_wccpf_instagram', true)
    
    get_post_meta($item['variation_id'], 'instagram', true)
    get_post_meta($item['variation_id'], 'wccaf_instagram', true)
    get_post_meta($item['variation_id'], 'wccpf_instagram', true)
    get_post_meta($item['variation_id'], 'attribute_instagram', true)
    get_post_meta($item['variation_id'], 'attribute_wccaf_instagram', true)
    get_post_meta($item['variation_id'], 'attribute_wccpf_instagram', true)
    
    $item['instagram']
    $item['wccaf_instagram']
    $item['wccpf_instagram']

    Tried all this to a wc Fields Factory text field named “instagram”

    Its not in wp_postmeta, its in wp_woocommerce_order_itemmeta, so:
    – get the order
    – get the array of order items
    – step through the order items to find the relevant order item, hence the item_id
    – use: wc_get_order_item_meta()
    – the meta-key seems to be the field label, not the field name

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Get text field content, how?’ is closed to new replies.