jeudi 26 mai 2016

Wordpress Woocommerce get custom data

Hi I need to get the product id, product variation id , and custom field text from each order. Ive retrieved all except the custom field text input data. Using

 $product_description = get_post_meta($item['product_id'])->post_content

Actually crashed the site altogether whereas all other parameters work well. See snippet below.

add_action('woocommerce_payment_complete', 'custom_process_order', 10, 1);
       function custom_process_order($order_id) {
       $order = new WC_Order( $order_id );
       $myuser_id = (int)$order->user_id;
       $user_info = get_userdata($myuser_id);
$items = $order->get_items();
foreach ($items as $item) {

       $product_name = $item['name'];
       $product_id = $item['product_id'];
       $product_variation_id = $item['variation_id'];
       $product_description = get_post_meta($item['product_id'])->post_content
       }
       return $order_id;
       } 

What might I be missing.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire