woocommerce order get product weight 1

woocommerce order get product weight

$item_weight=wp_get_post_terms($post->ID, 'pa_weight', array("fields" => "names"));

$send_array[] = array(

    'id' => get_the_ID(),
    'title' => get_the_title(),
    'content' => get_the_content(),
    'regular_price' => get_post_meta( get_the_ID(), '_regular_price', true),
    'sale_price'=> get_post_meta( get_the_ID(), '_sale_price', true),
    'weight' => $item_weight[0]


Here is what the above code is Doing:
1. We’re creating an array called $send_array.
2. We’re looping through the posts and adding the post ID, title, content, regular price, sale price, and weight to the array.
3. We’re adding the array to the $send_array array.
4. We’re repeating steps 2 and 3 for each post.
5. We’re returning the $send_array array.

Now, let’s add the following code to the end of the file:

Similar Posts