WooCommerce REST API - Get Order Attributes (Size / Color)

Using the WooCommerce REST Client Library I can easily pull out orders that are being processed, for example:

$response = $wc_api->get_orders( array( 'status' => 'processing' ) );


But the results DO NOT include attributes (color, size, etc.), although the purchased product was customized with the Size / Color attributes that correlate with product variations. Everything works fine in this part. Customer can choose the size and color of the product, but this information is NOT displayed with the request get_orders


Here's what it shows:

         <tax_class />
         <name>Cool T-Shirt You Just Bought!</name>


As you can see, although the client has selected the Large / Black option for the options, it does not appear in the data get_orders


I can pull the available attributes for a product using the same library, but I need to pull the user selected attributes for...


source to share

2 answers

I hate to answer my own question, but it turns out the answer is pretty simple:

The WooCommerce REST client client library has not been updated for the V2 API, although WooCommerce bundles it as a V2 resource. The solution is very simple:

Go to ~ / class-wc-api-client.php and change line 17 to:

const API_ENDPOINT = 'wc-api/v2/';

The API returned the correct data immediately when I made a get_orders () request.



again i say from magento background who would like to get that bounty :P

i think you should process each order separately from your list of orders you created above.

referring to the link

you can get the order items

$order = new WC_Order( $order_id );
$items = $order->get_items();


then if you go through them you can get all the relevant data:

foreach ( $items as $item ) {
    $product_name = $item['name'];
    $product_id = $item['product_id'];
    //// you had the product id now you can load the product and get all information  you might need 




All Articles