0

I got the below code and I want to work on woocommerce api to work on orders. So I got the below code able to get all particular order details by order id. But I am not getting custom field value from orders which is added.

require __DIR__ . '/vendor/autoload.php';

use Automattic\WooCommerce\Client;
use Automattic\WooCommerce\HttpClient\HttpClientException;
$woocommerce = new Client(
    'www.abc.com',    // Your store URL
    'ck_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',          // Your consumer key
    'cs_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',       // Your consumer secret
    [
        'wp_api' => true, // Enable the WP REST API integration
        'version' => 'wc/v3' // WooCommerce WP REST API version

    ]
    );

$products = $woocommerce->get('products');
print_r( $woocommerce->orders->get( $order_id ) );

Thanks in advance for helping me out from this.

Praveen
  • 985
  • 8
  • 31
  • Check this: https://stackoverflow.com/questions/36369388/woocommerce-rest-api-custom-fields – Arif Khan Dec 28 '21 at 11:23
  • Also this: https://woocommerce.github.io/woocommerce-rest-api-docs/?php#list-all-orders, you will see 'meta_data' array on order data response. – Arif Khan Dec 28 '21 at 11:25
  • @ArifKhan Thanks but I tried the above but it did not worked. Can you suggest other methods with results. – Praveen Dec 28 '21 at 11:57

0 Answers0