Recommand · January 13, 2022 0

How to fix Fatal error: Uncaught Error: Class 'Automattic\WooCommerce\Client'

I am new to Woocomerce Rest API. I am trying to fetch all products and orders from woocomerce in my wordpress website. But something went wrong from fetching that data. Here is my basic code

<?php
require_once ('vendor\autoload.php');

use Automattic\WooCommerce\Client;

$woocommerce = new Client(
    'https://www.cotncurls.com',
    '*************************',
    '*************************',
    [
        'wp_api' => true,
        'version' => 'wc/v3'
    ]
);

print_r($woocommerce->get('products'));

?>

The above code is showing an error with
Fatal error: Uncaught Error: Class 'Automattic\WooCommerce\Client' not found in .... .
Can anyone please help me with the issue?